phalcon / cphalcon

High performance, full-stack PHP framework delivered as a C extension.
https://phalcon.io
BSD 3-Clause "New" or "Revised" License
10.79k stars 1.96k forks source link

[BUG]: Mysql descripe indexes #16157

Closed phptux closed 2 years ago

phptux commented 2 years ago

With the method Phalcon\Db\Adapter\Pdo\Mysql->describeIndexes() can I read the indexes for a database table. Internal create this method a Phalcon\Db\Index instance. If the index type NULL , then an error message:

Phalcon\Db\Index::__construct(): Passing null to parameter #3 ($type) of type string is deprecated

Backtrace:

Phalcon\Db\Index::__construct(): Passing null to parameter #3 ($type) of type string is deprecated:
#0 [internal function]: Azirax\Error\Runner->handleError(8192, '...', '...', 438)
#1 [internal function]: Phalcon\Db\Index->__construct('...', Array, NULL)
#2 /home/phptux/public_html/pmailer/application/libraries/Db/TableUpdater.php(438): Phalcon\Db\Adapter\Pdo\Mysql->describeIndexes('...', '...')
#3 /home/phptux/public_html/pmailer/application/libraries/Db/TableUpdater.php(307): Azirax\Db\TableUpdater->getIndexesFromDatabase()
#4 /home/phptux/public_html/pmailer/application/libraries/Db/TableUpdater.php(166): Azirax\Db\TableUpdater->modifyIndexes()
#5 /home/phptux/public_html/pmailer/application/libraries/Db/SchemaUpdater.php(462): Azirax\Db\TableUpdater->update()
#6 /home/phptux/public_html/pmailer/application/libraries/Db/SchemaUpdater.php(195): Azirax\Db\SchemaUpdater->getTableUpdater('...')
#7 /home/phptux/public_html/pmailer/application/commands/DatabaseCommand.php(86): Azirax\Db\SchemaUpdater->update()
#8 [internal function]: Azirax\Commands\DatabaseCommand->updateAction(NULL)
#9 /home/phptux/public_html/pmailer/application/libraries/Console/AbstractCommand.php(219): call_user_func_array(Array, Array)
#10 /home/phptux/public_html/pmailer/application/libraries/Application/CliApplication.php(113): Azirax\Console\AbstractCommand->dispatch()
#11 /home/phptux/public_html/pmailer/bin/azirax(28): Azirax\Application\CliApplication->send()
#12 {main}

In the class Phalcon\Db\Adapter\Pdo\Mysql->describeIndexes() in line 542:

let indexes[keyName]["type"] = null;

But the constructor from the class Phalcon\Db\Index required as third parameter only string.

    /**
     * Phalcon\Db\Index constructor
     */
    public function __construct(string! name, array! columns, string type = "")

Details

I change the line in the class Phalcon\Db\Adapter\Pdo\Mysql->describeIndexes() 542 to:

let indexes[keyName]["type"] = "";

This work.

Regards phptux

niden commented 2 years ago

Resolved in https://github.com/phalcon/cphalcon/pull/16158

Thank you @phptux