Page MenuHomePhabricator

GlobalBlocking uses deprecated Block::decodeExpiry (deprecated in 1.18)
Closed, ResolvedPublic

Description

Seen on 'beta' while auto blocking a user (I believe with sorbs).

Use of Block::decodeExpiry was deprecated in MediaWiki 1.18. [Called from GlobalBlocking::getUserBlockErrors in /usr/local/apache/common-local/php-master/extensions/GlobalBlocking/GlobalBlocking.class.php at line 76]


Version: master
Severity: minor

Details

Reference
bz38619

Event Timeline

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

Messy B/C until $wgLang->formatExpiry() is well embedded

$blockExpiry = Block::decodeExpiry( $block->gb_expiry );

The comment was added in r84258, but I'm not sure what it means. Maybe this has since been fixed?

formatExpiry is relatively new

https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blobdiff;f=languages/Language.php;h=504f8826e39744b6368cf1eab1666f910f486dc5;hp=6d971b5d06b1b423f9928a05fee8d04fb65b717f;hb=91e7b5a93c6bcc9ba30101107cf75c488db9b769;hpb=757e8c7bff29da462ecca37752555336011afd26

Fri, 18 Mar 2011 19:15:56

I'm guessing it's some back compat related comment. It was not long after 1.17, but not there till 1.18. That's enough to not really worry about breaking back-compat. Expecting trunk versions of extensions to run with arbitary versions of MediaWiki is just daft

I note it is missing a @since annotation (which I'll add in a few)

public static function decodeExpiry( $expiry, $timestampType = TS_MW ) {

		wfDeprecated( __METHOD__, '1.18' );
		global $wgContLang;
		return $wgContLang->formatExpiry( $expiry, $timestampType );

}

Just replace the call in Global Blocking

$blockExpiry = Block::decodeExpiry( $block->gb_expiry );

with

global $wgContLang;
$blockExpiry = $wgContLang->formatExpiry( $block->gb_expiry, TS_MW );

and call it a fixed bug.

Though, $wgContLang seems slightly out of place, when surrounding code in getUserBlockErrors() using $wgLang. But that's an aside

While my changeset was still awaiting review, Siebrand did this partly in Gerrit change 22432. Both are merged now.