Page MenuHomePhabricator

Treat PHPDBG like CLI
Closed, ResolvedPublic

Description

When I use PHPDBG 7.0 for unit tests, it is issuing some PHP notices (see below).

Then I searched when CLI received a special treatment and found another cases (see list). I’m not sure if there are security implications in treating PHPDBG exactly like CLI, but if PHPDBG is used for code coverage as suggested in T147778 and PHPDBG is not equivalent to CLI, it could create differences in unit tests results depending on the SAPI, which is probably undesirable.


When I execute unit tests with PHPDBG 7.0.16 with phpdbg -qrr tests/phpunit/phpunit.php, I obtain (in addition of T72357#3167810) PHP notices during the first tests:

PHP Notice:  JobQueueGroup::__destruct: 3 buffered job(s) of type(s) RecentChangesUpdateJob, HTMLCacheUpdateJob never inserted. in /mediawiki/includes/jobqueue/JobQueueGroup.php on line 449

This is because JobQueueGroup::lazyPush() has a special condition for PHP_SAPI 'cli' but not for 'phpdbg'. It is solved when PHPDBG is added.


List of current occurrences:

As of 4b7be83 (1.29-alpha).

includes/libs/lockmanager/LockManager.php:87:            } elseif ( PHP_SAPI === 'cli' ) {
includes/libs/filebackend/FileBackend.php:931:           if ( PHP_SAPI != 'cli' ) { // https://bugs.php.net/bug.php?id=47540
includes/libs/rdbms/loadbalancer/LoadBalancer.php:224:   $this->cliMode = isset( $params['cliMode'] ) ? $params['cliMode'] : PHP_SAPI === 'cli';
includes/libs/rdbms/loadbalancer/LoadBalancer.php:1628:  if ( PHP_SAPI != 'cli' ) { // https://bugs.php.net/bug.php?id=47540
includes/libs/rdbms/lbfactory/LBFactory.php:123:         $this->cliMode = isset( $conf['cliMode'] ) ? $conf['cliMode'] : PHP_SAPI === 'cli';
includes/libs/rdbms/lbfactory/LBFactory.php:568:         if ( PHP_SAPI != 'cli' ) { // https://bugs.php.net/bug.php?id=47540
includes/libs/rdbms/database/Database.php:381:           $p['cliMode'] = isset( $p['cliMode'] ) ? $p['cliMode'] : ( PHP_SAPI === 'cli' );
includes/ForkController.php:57:                          if ( PHP_SAPI != 'cli' ) {
includes/jobqueue/JobQueueGroup.php:173:                 if ( PHP_SAPI === 'cli' ) {
includes/utils/UIDGenerator.php:371:                     if ( ( $flags & self::QUICK_VOLATILE ) && PHP_SAPI !== 'cli' ) {
includes/profiler/output/ProfilerOutputText.php:62:      if ( PHP_SAPI === 'cli' ) {
includes/profiler/Profiler.php:77:                       if ( PHP_SAPI === 'cli' || !$inSample ) {
includes/api/ApiQuerySiteinfo.php:150:                   $data['phpsapi'] = PHP_SAPI;
includes/GlobalFunctions.php:3235:                       $timeout = ( PHP_SAPI === 'cli' ) ? 86400 : 10;
includes/PHPVersionCheck.php:267:                        case 'cli':
maintenance/updateCredits.php:25:                        if ( PHP_SAPI != 'cli' ) {
maintenance/mwdoc-filter.php:41:                         if ( PHP_SAPI != 'cli' ) {
maintenance/dev/includes/router.php:24:                  if ( PHP_SAPI != 'cli-server' ) {
maintenance/generateLocalAutoload.php:3:                 if ( PHP_SAPI != 'cli' ) {
maintenance/Maintenance.php:26:                          wfEntryPointCheck( 'cli' );
maintenance/Maintenance.php:392:                         if ( PHP_SAPI == 'cli' ) {

Other occurrences related to PHP_SAPI, for information:

includes/specials/SpecialVersion.php:227:                $software['[http://hhvm.com/ HHVM]'] = HHVM_VERSION . " (" . PHP_SAPI . ")";
includes/specials/SpecialVersion.php:229:                $software['[https://php.net/ PHP]'] = PHP_VERSION . " (" . PHP_SAPI . ")";
includes/DefaultSettings.php:160:                        $wgUsePathInfo = ( strpos( PHP_SAPI, 'cgi' ) === false ) &&
includes/DefaultSettings.php:161:                        ( strpos( PHP_SAPI, 'apache2filter' ) === false ) &&
includes/DefaultSettings.php:162:                        ( strpos( PHP_SAPI, 'isapi' ) === false );

Event Timeline

Seb35 created this task.Apr 10 2017, 11:30 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 10 2017, 11:30 AM

Change 347355 had a related patch set uploaded (by Seb35):
[mediawiki/core@master] Prevent PHPDBG from issuing notices in unit tests

https://gerrit.wikimedia.org/r/347355

Change 347355 merged by jenkins-bot:
[mediawiki/core@master] Prevent PHPDBG from issuing notices in unit tests

https://gerrit.wikimedia.org/r/347355

Krinkle closed this task as Resolved.May 25 2017, 12:57 PM
Krinkle assigned this task to Seb35.
Krinkle triaged this task as Normal priority.