Page MenuHomePhabricator

includes/memcached-client.php constants have incorrect scope
Closed, InvalidPublic

Description

Author: widdis

Description:
I encountered a problem exhibited in the latest version of the TableEdit extension on the latest svn version of MW 1.17. The root cause of the problem is that the constants defined in the memcached-client.php include file are not properly interpreted.

Problematic file is:
http://svn.wikimedia.org/viewvc/mediawiki/branches/REL1_17/phase3/includes/memcached-client.php?view=markup

Error message is:
Fatal error: Undefined class constant 'COMPRESSED' in /<path>/includes/memcached-client.php on line 973

(Similar error for COMPRESSION_SAVINGS. I didn't encounter the SERIALIZED error but might have if I had gone down a different branch of code.)

In the problematic lines, the constants are referred to using self::, i.e., self::COMPRESSED, self::COMPRESSION_SAVINGS, and self::SERIALIZED

self:: refers to the scope at the point of definition not at the point of execution. This is problematic in an include file.

For PHP 5.3+, the correct syntax is to use static:: to refer to the constants.


Version: 1.17.x
Severity: normal

Details

Reference
bz35274

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 12:12 AM
bzimport set Reference to bz35274.
bzimport added a subscriber: Unknown Object (MLST).

(In reply to comment #0)

For PHP 5.3+, the correct syntax is to use static:: to refer to the constants.

Our minimum supported version of PHP is still 5.2.3, so we cannot use LSB stuff in core.

Also, self is still valid syntax: http://php.net/manual/en/language.oop5.constants.php

MediaWiki 1.17 isn't a currently supported release, and as this extension isn't kept and maintained in our SVN repository,