mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TitleBlacklist
synced 2024-11-23 21:53:40 +00:00
Remove use of internal $messageMemc variable
The $messageMemc legacy global, is a BagOStuff intended for MessageCache service, configured by wgMessageCacheType. Use that directly as a short-term measure so that we can remove $messageMemc initialization from Setup.php. Bug: T189966 Bug: T243175 Change-Id: I04a0e578d76269fa02ee85cffee070dc3e1f4512
This commit is contained in:
parent
fe38082a53
commit
9bf6f9480c
|
@ -8,11 +8,6 @@
|
|||
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
|
||||
<exclude-pattern>Scribunto_LuaTitleBlacklistLibrary\.php</exclude-pattern>
|
||||
</rule>
|
||||
<rule ref="MediaWiki.NamingConventions.ValidGlobalName">
|
||||
<properties>
|
||||
<property name="ignoreList" type="array" value="$messageMemc" />
|
||||
</properties>
|
||||
</rule>
|
||||
<file>.</file>
|
||||
<arg name="extensions" value="php,php5,inc"/>
|
||||
<arg name="encoding" value="UTF-8"/>
|
||||
|
|
|
@ -287,19 +287,26 @@ class TitleBlacklist {
|
|||
* @return string The content of the blacklist source as a string
|
||||
*/
|
||||
private static function getHttp( $url ) {
|
||||
global $messageMemc, $wgTitleBlacklistCaching;
|
||||
global $wgTitleBlacklistCaching, $wgMessageCacheType;
|
||||
// FIXME: This is a hack to use Memcached where possible (incl. WMF),
|
||||
// but have CACHE_DB as fallback (instead of no cache).
|
||||
// This might be a good candidate for T248005.
|
||||
$cache = ObjectCache::getInstance( $wgMessageCacheType );
|
||||
|
||||
$key = 'title_blacklist_source:' . md5( $url ); // Global shared
|
||||
$warnkey = $messageMemc->makeKey( 'titleblacklistwarning', md5( $url ) );
|
||||
$result = $messageMemc->get( $key );
|
||||
$warn = $messageMemc->get( $warnkey );
|
||||
// Globally shared
|
||||
$key = $cache->makeGlobalKey( 'title_blacklist_source', md5( $url ) );
|
||||
// Per-wiki
|
||||
$warnkey = $cache->makeKey( 'titleblacklistwarning', md5( $url ) );
|
||||
|
||||
$result = $cache->get( $key );
|
||||
$warn = $cache->get( $warnkey );
|
||||
|
||||
if ( !is_string( $result )
|
||||
|| ( !$warn && !mt_rand( 0, $wgTitleBlacklistCaching['warningchance'] ) )
|
||||
) {
|
||||
$result = Http::get( $url );
|
||||
$messageMemc->set( $warnkey, 1, $wgTitleBlacklistCaching['warningexpiry'] );
|
||||
$messageMemc->set( $key, $result, $wgTitleBlacklistCaching['expiry'] );
|
||||
$cache->set( $warnkey, 1, $wgTitleBlacklistCaching['warningexpiry'] );
|
||||
$cache->set( $key, $result, $wgTitleBlacklistCaching['expiry'] );
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
Loading…
Reference in a new issue