Closed
opened this issue Oct 11, 2017 · 5 comments
Closed

opened this issue Oct 11, 2017 · 5 comments
Assignees
Labels

### Steps to reproduce

3. The Xdebug extension immediately raises 2 errors like this:

### Expected behaviour

No such errors detected by Xdebug should occur.

### Actual behaviour

The Xdebug extension immediately raises 2 errors like this:

Call Stack
1 | 0.0000 | 377304 | {main}( ) | ...\index.php:0
2 | 0.0000 | 380544 | require_once( 'S:\xtack\bin\pma\libraries\common.inc.php' ) | ...\index.php:20

## Variables in local scope (#4) $context = | S:\xtack\bin\pma\vendor\phpmyadmin\sql-parser\src\Context.php:462:string '\PhpMyAdmin\SqlParser\Contexts\ContextMySql50557' (length=48) Besides, after those 2 Xdebug errors, many other phpMyAdmin warnings like this one pop up: ## Cannot modify header information - headers already sent by (output started at S:\xtack\bin\pma\vendor\phpmyadmin\sql-parser\src\Context.php:462) ### Server configuration Operating system: Microsoft Windows 7 Enterprise Multiprocessor Free Enterprise Edition SP1 64 bits version 6.1.7601 Web server: nginx/1.13.5 Database: Server: localhost - xtack (127.0.0.1 via TCP/IP) Server type: MySQL Server version: 5.5.57 - MySQL Community Server (GPL) Protocol version: 10 User: ************** Server charset: UTF-8 Unicode (utf8) PHP version: PHP version: 7.1.10 Database client version: libmysql - mysqlnd 5.0.12-dev - 20150407 -$Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $PHP extension: mysqli curl mbstring phpMyAdmin version: 4.7.4 ### Client configuration Browser: Firefox 56.0.0.6478 (64-bit) Google Chrome 61.0.3163.100 (Official Build) (64-bit) Microsoft Internet Explorer 11.0.9600.18792 - Update Versions 11.0.46 (KB4036586) Operating system: Microsoft Windows 7 Enterprise Multiprocessor Free Enterprise Edition SP1 64 bits version 6.1.7601 ### nijel commented Oct 11, 2017  These exceptions are properly handled by the code, why is raising an exception problem? added the label Oct 11, 2017 self-assigned this Oct 11, 2017 changed the title PhpMyAdmin\SqlParser\Exceptions\LoaderException: Specified context ("\PhpMyAdmin\SqlParser\Contexts\ContextMySqlxxxxx") does not exist. in <phpmyadmin_local_installation_dir>\vendor\phpmyadmin\sql-parser\src\Context.php on line 460 (Xdebug) PhpMyAdmin\SqlParser\Exceptions\LoaderException: Specified context does not exist. Oct 11, 2017 ### caaguado commented Oct 11, 2017  Hi Michal, Because of the simple reason that since the exception is thrown like this: if (!class_exists($context)) { throw @new LoaderException( ... the fact that several consecutive exceptions need to be raised IMHO potentially points out to the fact that either the code is not optimal or that there are deeper problems causing the contexts not to be repeatedly available, which is in any case also worth a review, isn't it? On the other hand, as a basic design principle, code should run with the lowest number of exceptions, by definition... BR // Carlos Aguado. On 2017-10-11 15:42, Michal Čihař wrote: These exceptions are properly handled by the code, why is raising an exception problem? -- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub [1], or mute the thread [2].
added the label Oct 11, 2017

### nijel commented Oct 11, 2017

 Again, what is problem with throwing exception and handing it? The exception is thrown here: https://github.com/phpmyadmin/sql-parser/blob/8ab57e737d634210c0f4dd742880c690bcdde0d0/src/Context.php#L464-L469 And handled here: https://github.com/phpmyadmin/sql-parser/blob/8ab57e737d634210c0f4dd742880c690bcdde0d0/src/Context.php#L499-L513

### caaguado commented Oct 23, 2017

 Hi nijel, Again, there is no problem with an exception being thrown and properly handled per se. But the code is not running optimal, as long as one gets exceptions. Now, if this issue is to be fixed, the software should be corrected so for it to instead of looking for a context file/class that includes the first digit in the minor MySQL version number in subfolder \vendor\phpmyadmin\sql-parser\src\Contexts\ right before the ".php" filename suffix, it should just look for the MySQL major version number, appending a "00" just before such ".php" filename suffix. Example for MySQL 5.5.58 (with the aim to illustrate): phpMyAdmin 4.7.5 looks for context file \vendor\phpmyadmin\sql-parser\src\Contexts\ContextMySql50550.php, but since this file doesn't exist, an exception is thrown. Instead, phpMyAdmin should ignore the first digit of the MySQL's 5.5.58 minor version number (58, in this case) and actually load context file \vendor\phpmyadmin\sql-parser\src\Contexts\ContextMySql50500.php, which indeed does exist in that subfolder. Otherwise, a context file including the first digit of MySQL's minor version number should be ideally provided with the code. That way, no exception would be thrown either. Again, exceptions are things that are pointing out to abnormal situations that should be prevented if the long term quality of the software package is to be kept at a healthy level. Thanks, Carlos.
closed this in  phpmyadmin/sql-parser@9b56a08  Dec 6, 2017
added and removed labels Dec 6, 2017

### williamdes commented Mar 30, 2019

ID Exception Name Message Location PMA Version Status Exception Type Incident count
55626 Warning include_once(PhpMyAdmin/SqlParser/Contexts/ContextMySql50562.php): failed to open stream: No such file or directory ./../../../../../../../../plib/Loader.php 4.8.4 Forwarded php 2
36762 Warning include_once(PhpMyAdmin\SqlParser\Contexts\ContextMySql100125.php): failed to open stream: No such file or directory .......\projekty\v\xxx\yyy\zz\Class\Model\God.php 4.7.0 Forwarded php 1
56381 Warning include_once(PhpMyAdmin\SqlParser\Contexts\ContextMySql50173.php): failed to open stream: No such file or directory .................\plib\Loader.php 4.8.4 Forwarded php 8
55312 Warning include_once(PhpMyAdmin\SqlParser\Contexts\ContextMySql50636.php): failed to open stream: No such file or directory .................\plib\Loader.php 4.8.4 Forwarded php 32