Page MenuHomePhabricator

PEAR PHP classes are loaded from system packages instead of Composer packages in WMF production
Closed, ResolvedPublic

Description

Per T215126: PHP warning on some Echo email sending attempts due to mismatching PEAR file versions, some files of the Mail_Mime PEAR package are included from the mediawiki/vendor repo (or the Composer-maintained vendor directory, presumably, when one uses Composer in production), other files are from the PEAR package installed as a Debian system package in /usr/share/php. This results in a version mismatch and bugs.

Files in the Mail_Mime PEAR package start with something like

require_once 'PEAR.php';
require_once 'Mail/mimePart.php';

Mail and Mail_Mime use Composer's include-path property:

"include-path": [
    "./"
],

so in theory the vendor/pear/mail and vendor/pear/mail-mime subdirectories should be part of the include path but that doesn't seem to be the case:

tgr@mwdebug1002:~$ PHP=php7.2 mwscript shell.php enwiki
>>> get_include_path()
=> "/srv/mediawiki/php-1.33.0-wmf.14:/usr/local/lib/php:/usr/share/php"

(Same result with PHP 5, not sure why the error only seems to be happening with PHP 7.)

Seems like a Composer bug? (Also, those PEAR packages should probably be fixed the way other packages have been.)

Details

Related Gerrit Patches:
operations/mediawiki-config : masterPreserve Composer's include paths

Event Timeline

Tgr created this task.Feb 5 2019, 12:17 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 5 2019, 12:17 AM
Tgr renamed this task from PHP classes are loaded from system packages before Composer packages in WMF production to PEAR PHP classes are loaded from system packages instead of Composer packages in WMF production.Feb 5 2019, 12:19 AM
Tgr updated the task description. (Show Details)Feb 5 2019, 12:26 AM
MaxSem added a subscriber: MaxSem.Feb 5 2019, 2:07 AM

Is there any reason why we shouldn't just nuke the PEAR packages?

Tgr added a comment.Feb 5 2019, 2:31 AM

Is there any reason why we shouldn't just nuke the PEAR packages?

In general there isn't, that's T195364: Remove pear/mail packages from WMF MW app servers. Nuking before fixing this issue would probably make the require_once calls break, though.

Anomie added a subscriber: Anomie.EditedFeb 5 2019, 2:42 PM

The composer-added include path is being overwritten in WMF production by https://gerrit.wikimedia.org/r/plugins/gitiles/operations/mediawiki-config/+/30a9c394893275b368271ac070f02cb3a00427d9/wmf-config/CommonSettings.php#83

Before that line, it was set to /srv/mediawiki/php-1.33.0-wmf.14/vendor/pear/console_getopt:/srv/mediawiki/php-1.33.0-wmf.14/vendor/pear/mail:/srv/mediawiki/php-1.33.0-wmf.14/vendor/pear/mail_mime:/srv/mediawiki/php-1.33.0-wmf.14/vendor/pear/net_smtp:/srv/mediawiki/php-1.33.0-wmf.14/vendor/pear/net_socket:/srv/mediawiki/php-1.33.0-wmf.14/vendor/pear/pear-core-minimal/src:/srv/mediawiki/php-1.33.0-wmf.14/vendor/pear/pear_exception:.:/usr/share/php:/srv/mediawiki/php (from some mwdebug1002 testing with shell.php).

Change 488070 had a related patch set uploaded (by Anomie; owner: Anomie):
[operations/mediawiki-config@master] Preserve Composer's include paths

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

Change 488070 merged by jenkins-bot:
[operations/mediawiki-config@master] Preserve Composer's include paths

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

Mentioned in SAL (#wikimedia-operations) [2019-02-06T00:16:52Z] <niharika29@deploy1001> Synchronized wmf-config/CommonSettings.php: Preserve Composer's include paths - T215126, T215224 (duration: 01m 40s)

Tgr closed this task as Resolved.Feb 6 2019, 3:30 AM
Tgr assigned this task to Anomie.
Tgr removed projects: Patch-For-Review, Upstream.

(Also, those PEAR packages should probably be fixed the way other packages have been.)

Filed as T215373: Fix the PEAR packages used by MediaWiki to use Composer properly, nothing else left here.