ApiBase::getModuleSourceInfo(): Use $wgExtensionDirectory
authorKunal Mehta <legoktm@member.fsf.org>
Sun, 13 Dec 2015 03:45:43 +0000 (19:45 -0800)
committerTim Starling <tstarling@wikimedia.org>
Wed, 17 Aug 2016 04:02:42 +0000 (04:02 +0000)
This function takes the class file path, and iterates up through its
parent directories until it hits either a registered extension, or $IP
(for core) or $IP/extensions (for an unknown extension). This change
adds $wgExtensionDirectory as another iteration stopper, so that
unregistered extensions in $wgExtensionDirectory will not cause
iteration back up to the filesystem root, or to $IP if
$wgExtensionDirectory is a child of $IP other than $IP/extensions.

Change-Id: I06553591b0b6156e945aad5176479eb71517e77d

includes/api/ApiBase.php

index b45eacb..4a1a520 100644 (file)
@@ -2458,6 +2458,7 @@ abstract class ApiBase extends ContextSource {
 
                // Build map of extension directories to extension info
                if ( self::$extensionInfo === null ) {
+                       $extDir = $this->getConfig()->get( 'ExtensionDirectory' );
                        self::$extensionInfo = [
                                realpath( __DIR__ ) ?: __DIR__ => [
                                        'path' => $IP,
@@ -2465,6 +2466,7 @@ abstract class ApiBase extends ContextSource {
                                        'license-name' => 'GPL-2.0+',
                                ],
                                realpath( "$IP/extensions" ) ?: "$IP/extensions" => null,
+                               realpath( $extDir ) ?: $extDir => null,
                        ];
                        $keep = [
                                'path' => null,