NOTICE: PHP message: PHP Fatal error: Uncaught TypeError: implode() expects parameter 2 to be array, null given in src/Utils/Routine.php:123
NOTICE: PHP message: PHP Fatal error: Uncaught TypeError: implode() expects parameter 2 to be array, null given in vendor/phpmyadmin/sql-parser/src/Utils/Routine.php:123"
Stack trace:"
#0 vendor/phpmyadmin/sql-parser/src/Utils/Routine.php(123): implode(',', NULL)"
#1 libraries/classes/Rte/RteList.php(304): PhpMyAdmin\SqlParser\Utils\Routine::getParameters(Object(PhpMyAdmin\SqlParser\Statements\CreateStatement))"
#2 libraries/classes/Rte/RteList.php(169): PhpMyAdmin\Rte\RteList->getRoutineRow(Array, '')"
#3 libraries/classes/Rte/Routines.php(131): PhpMyAdmin\Rte\RteList->get('routine', Array)"
#4 libraries/classes/Controllers/Database/RoutinesController.php(42): PhpMyAdmin\Rte\Routines->main('PROCEDURE')"
#5 db_routi..."
{
"name": {
"database": null,
"table": "foo",
"column": null,
"expr": "`foo`",
"alias": null,
"function": null,
"subquery": null
},
"entityOptions": {
"options": []
},
"fields": null,
"select": null,
"like": null,
"partitionBy": null,
"partitionsNum": null,
"subpartitionBy": null,
"subpartitionsNum": null,
"partitions": null,
"table": null,
"return": null,
"parameters": [
{
"name": "$",
"inOut": null,
"type": {
"name": "FOO",
"parameters": [],
"options": {
"options": []
}
}
},
{
"name": null,
"inOut": null,
"type": null
}
],
"body": [
{
"token": "select",
"value": "SELECT",
"keyword": "SELECT",
"type": 1,
"flags": 3,
"position": 54
},
{
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 60
},
{
"token": "$",
"value": "$",
"keyword": null,
"type": 0,
"flags": 0,
"position": 61
},
{
"token": "foo",
"value": "foo",
"keyword": null,
"type": 0,
"flags": 0,
"position": 62
},
{
"token": null,
"value": null,
"keyword": null,
"type": 9,
"flags": 0,
"position": null
}
],
"options": {
"options": {
"4": {
"name": "DEFINER",
"equals": true,
"expr": {
"database": null,
"table": null,
"column": "root@%",
"expr": "`root`@`%`",
"alias": null,
"function": null,
"subquery": null
},
"value": "`root`@`%`"
},
"6": "PROCEDURE"
}
},
"first": 0,
"last": 23
}
passed to getParameters
CREATE DEFINER=`root`@`%` PROCEDURE `$a`(IN `$a` INT)
NO SQL
SELECT $a
-- or
CREATE DEFINER=`root`@`%` PROCEDURE `foo`( $foo int )
select $foo
I had no success adding a test
public function testGetParametersFromCreateStatement()
{
//CREATE DEFINER=`root`@`%` PROCEDURE `$a`(IN `$a` INT)\n NO SQL\nSELECT $a
$parser = new Parser('CREATE DEFINER=`root`@`%` PROCEDURE `foo`( $foo int )\nselect $foo');
/**
* @var CreateStatement $stmt
*/
$stmt = $parser->statements[0];
$this->assertNotNull(Routine::getParameters($stmt));
}
@williamdes using the current master, I can't reproduced, and I experience 0 PHP error by linting your queries. Is this still something you can reproduce? Otherwise, I think you can close this one as it's probably no longer a bug.
@williamdes using the current
master, I can't reproduced, and I experience 0 PHP error by linting your queries. Is this still something you can reproduce? Otherwise, I think you can close this one as it's probably no longer a bug.
Thank you for trying this, please be sure to try on QA_5_2 branch as it's the maintenance branch That said I did a fix years ago to the line that did trigger this so it would shut up. but it's only a workaround I put this back to un-read and will try to find you the commit ASAP
Well, I can not find it anymore. Searched everywhere, it's lost or gone for ever.
We should probably add a test case for the code I sent because parameters are wrongly detected
The only one I found was way back before this issue 🤔 https://github.com/phpmyadmin/phpmyadmin/pull/14750
So maybe re-creating the bug would help finding my workaround. But that's not worth the research time
Well, I guess your workaround evolved to something better then 😄 Maybe this issue should be closed if it doesn't happen anymore.
Well, I guess your workaround evolved to something better then smile Maybe this issue should be closed if it doesn't happen anymore.
Yeah probably 😄
But I can not close it because as I said parameters in https://github.com/phpmyadmin/sql-parser/issues/293#issuecomment-592764284 are wrong ;p
Sorry, I didn't noticed that parameters were wrong 😅
I guess for
CREATE DEFINER=`root`@`%` PROCEDURE `foo`( $foo int )
you expect something like:
"parameters":[
{
"name": "$foo",
"inOut": null,
"type": "int"
}
]
right?
Exactly, and I am not sure if it should also do one token for
{
"token": "$",
"value": "$",
"keyword": null,
"type": 0,
"flags": 0,
"position": 61
},
{
"token": "foo",
"value": "foo",
"keyword": null,
"type": 0,
"flags": 0,
"position": 62
},
Instead of two
FTR I think this was https://github.com/phpmyadmin/phpmyadmin/issues/15991
Thanks a lot! I'll try to take a look, probably next week.
Parameter name seems to be correct now, isn't it?

Yes, let's close this one. I am not sure where it was anyway. Should have posted a reference back in the day. Thanks for having a look too