X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=6fbc11d0d84f4759909850e48abe31eda3e346fe;hb=ddbba62d03e8d5d586d73a20cbc6544b41c574a6;hp=28525610d54fe1294284d4ab23bf5f4a31822ae4;hpb=6382ba2d5a487def06bde3fa1749de2944535954;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 28525610d5..6fbc11d0d8 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -171,6 +171,7 @@ if ( !function_exists( 'hash_equals' ) ) { * * @param string $ext Name of the extension to load * @param string|null $path Absolute path of where to find the extension.json file + * @since 1.25 */ function wfLoadExtension( $ext, $path = null ) { if ( !$path ) { @@ -191,6 +192,7 @@ function wfLoadExtension( $ext, $path = null ) { * * @see wfLoadExtension * @param string[] $exts Array of extension names to load + * @since 1.25 */ function wfLoadExtensions( array $exts ) { global $wgExtensionDirectory; @@ -206,6 +208,7 @@ function wfLoadExtensions( array $exts ) { * @see wfLoadExtension * @param string $skin Name of the extension to load * @param string|null $path Absolute path of where to find the skin.json file + * @since 1.25 */ function wfLoadSkin( $skin, $path = null ) { if ( !$path ) { @@ -220,6 +223,7 @@ function wfLoadSkin( $skin, $path = null ) { * * @see wfLoadExtensions * @param string[] $skins Array of extension names to load + * @since 1.25 */ function wfLoadSkins( array $skins ) { global $wgStyleDirectory; @@ -631,7 +635,7 @@ function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) { $bits = wfParseUrl( $url ); // ensure proper port for HTTPS arrives in URL - // https://bugzilla.wikimedia.org/show_bug.cgi?id=65184 + // https://phabricator.wikimedia.org/T67184 if ( $defaultProto === PROTO_HTTPS && $wgHttpsPort != 443 ) { $bits['port'] = $wgHttpsPort; } @@ -2538,7 +2542,7 @@ function wfMkdirParents( $dir, $mode = null, $caller = null ) { MediaWiki\restoreWarnings(); if ( !$ok ) { - //directory may have been created on another request since we last checked + // directory may have been created on another request since we last checked if ( is_dir( $dir ) ) { return true; } @@ -3212,6 +3216,7 @@ function wfUsePHP( $req_ver ) { * * @see perldoc -f use * + * @deprecated since 1.26, use the "requires' property of extension.json * @param string|int|float $req_ver The version to check, can be a string, an integer, or a float * @throws MWException */ @@ -3462,7 +3467,6 @@ function wfResetSessionID() { $_SESSION = $tmp; } $newSessionId = session_id(); - Hooks::run( 'ResetSessionID', array( $oldSessionId, $newSessionId ) ); } /** @@ -4068,13 +4072,10 @@ function wfUnpack( $format, $data, $length = false ) { * @return bool */ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) { - static $badImageCache = null; // based on bad_image_list msg - - # Handle redirects - $redirectTitle = RepoGroup::singleton()->checkRedirect( Title::makeTitle( NS_FILE, $name ) ); - if ( $redirectTitle ) { - $name = $redirectTitle->getDBkey(); - } + # Handle redirects; callers almost always hit wfFindFile() anyway, + # so just use that method because it has a fast process cache. + $file = wfFindFile( $name ); // get the final name + $name = $file ? $file->getTitle()->getDBkey() : $name; # Run the extension hook $bad = false; @@ -4082,10 +4083,11 @@ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) { return $bad; } - $cacheable = ( $blacklist === null ); - if ( $cacheable && $badImageCache !== null ) { - $badImages = $badImageCache; - } else { // cache miss + $cache = ObjectCache::newAccelerator( 'hash' ); + $key = wfMemcKey( 'bad-image-list', ( $blacklist === null ) ? 'default' : md5( $blacklist ) ); + $badImages = $cache->get( $key ); + + if ( $badImages === false ) { // cache miss if ( $blacklist === null ) { $blacklist = wfMessage( 'bad_image_list' )->inContentLanguage()->plain(); // site list } @@ -4121,13 +4123,12 @@ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) { $badImages[$imageDBkey] = $exceptions; } } - if ( $cacheable ) { - $badImageCache = $badImages; - } + $cache->set( $key, $badImages, 60 ); } $contextKey = $contextTitle ? $contextTitle->getPrefixedDBkey() : false; $bad = isset( $badImages[$name] ) && !isset( $badImages[$name][$contextKey] ); + return $bad; }