Odd warning from VTQL_Parser...
I am seeing this Warning being triggered by a call to vtws_query on a fresh install of a pull from the master branch this morning.
The query looks like this:
"SELECT * FROM LSModule WHERE lsmod_status != 'Inactive' AND tgt_module = '".$moduleName."';";
The warning being reported from PHP is this:
[12-May-2020 10:38:32 UTC] PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /var/www/html/vt721-2/include/Webservices/VTQL_Parser.php on line 1237
[12-May-2020 10:38:32 UTC] PHP Stack trace:
[12-May-2020 10:38:32 UTC] PHP 1. {main}() /var/www/html/vt721-2/index.php:0
[12-May-2020 10:38:32 UTC] PHP 2. Vtiger_WebUI->process() /var/www/html/vt721-2/index.php:20
[12-May-2020 10:38:32 UTC] PHP 3. LSModule_BasicAjax_Action->process() /var/www/html/vt721-2/includes/main/WebUI.php:215
[12-May-2020 10:38:32 UTC] PHP 4. LSModule_BasicAjax_Action->invokeExposedMethod() /var/www/html/vt721-2/modules/LSModule/actions/BasicAjax.php:36
[12-May-2020 10:38:32 UTC] PHP 5. LSModule_BasicAjax_Action->getModuleData() /var/www/html/vt721-2/includes/runtime/Controller.php:64
[12-May-2020 10:38:32 UTC] PHP 6. LSModule_Module_Model->getDataForModule() /var/www/html/vt721-2/modules/LSModule/actions/BasicAjax.php:52
[12-May-2020 10:38:32 UTC] PHP 7. vtws_query() /var/www/html/vt721-2/modules/LSModule/models/Module.php:26
[12-May-2020 10:38:32 UTC] PHP 8. VtigerModuleOperation->query() /var/www/html/vt721-2/include/Webservices/Query.php:64
[12-May-2020 10:38:32 UTC] PHP 9. Parser->parse() /var/www/html/vt721-2/include/Webservices/VtigerModuleOperation.php:174
[12-May-2020 10:38:32 UTC] PHP 10. VTQL_Parser->doParse() /var/www/html/vt721-2/include/Webservices/QueryParser.php:42
[12-May-2020 10:38:32 UTC] PHP 11. VTQL_Parser->yy_reduce() /var/www/html/vt721-2/include/Webservices/VTQL_Parser.php:1577
[12-May-2020 10:38:32 UTC] PHP 12. VTQL_Parser->yy_r17() /var/www/html/vt721-2/include/Webservices/VTQL_Parser.php:1429
[12-May-2020 10:38:32 UTC] PHP 13. sizeof() /var/www/html/vt721-2/include/Webservices/VTQL_Parser.php:1237
[12-May-2020 10:38:32 UTC] PHP Warning: Use of undefined constant SEMI - assumed 'SEMI' (this will throw an Error in a future version of PHP) in /var/www/html/vt721-2/include/Webservices/VTQL_Parser.php on line 1163
I see a few problems in the above.
-
See line 1163 and 1164. The constant "SEMI" is indeed not defined. On line 392 there is a constant called SEMICOLON which is what I guess is being tested for...
-
In php sizeof() is an just an alias of count() so why not use count()? In most other languages sizeof() means something very different to what is being done here (sizeof() generally returns a memory value in bytes)
-
Why is sizeof() being passed something like a bool or null which is what triggered the original Warning? I can't see anything wrong with the query structure itself?