* Calling Maintenance::hasArg() as well as Maintenance::getArg() with no
parameter has been deprecated. Please pass the argument number 0.
* The MWNamespace class is deprecated. Use MediaWikiServices::getNamespaceInfo.
+* ResourceLoaderContext::expandModuleNames has been deprecated.
+ Use ResourceLoader::expandModuleNames instead.
=== Other changes in 1.33 ===
* (T201747) Html::openElement() warns if given an element name with a space
* For example, `[ 'foo.bar', 'foo.baz', 'bar.baz', 'bar.quux' ]`
* becomes `'foo.bar,baz|bar.baz,quux'`.
*
- * This process is reversed by ResourceLoaderContext::expandModuleNames().
+ * This process is reversed by ResourceLoader::expandModuleNames().
* See also mw.loader#buildModulesString() which is a port of this, used
* on the client-side.
*
return implode( '|', $arr );
}
+ /**
+ * Expand a string of the form `jquery.foo,bar|jquery.ui.baz,quux` to
+ * an array of module names like `[ 'jquery.foo', 'jquery.bar',
+ * 'jquery.ui.baz', 'jquery.ui.quux' ]`.
+ *
+ * This process is reversed by ResourceLoader::makePackedModulesString().
+ *
+ * @since 1.33
+ * @param string $modules Packed module name list
+ * @return array Array of module names
+ */
+ public static function expandModuleNames( $modules ) {
+ $retval = [];
+ $exploded = explode( '|', $modules );
+ foreach ( $exploded as $group ) {
+ if ( strpos( $group, ',' ) === false ) {
+ // This is not a set of modules in foo.bar,baz notation
+ // but a single module
+ $retval[] = $group;
+ } else {
+ // This is a set of modules in foo.bar,baz notation
+ $pos = strrpos( $group, '.' );
+ if ( $pos === false ) {
+ // Prefixless modules, i.e. without dots
+ $retval = array_merge( $retval, explode( ',', $group ) );
+ } else {
+ // We have a prefix and a bunch of suffixes
+ $prefix = substr( $group, 0, $pos ); // 'foo'
+ $suffixes = explode( ',', substr( $group, $pos + 1 ) ); // [ 'bar', 'baz' ]
+ foreach ( $suffixes as $suffix ) {
+ $retval[] = "$prefix.$suffix";
+ }
+ }
+ }
+ }
+ return $retval;
+ }
+
/**
* Determine whether debug mode was requested
* Order of priority is 1) request param, 2) cookie, 3) $wg setting
// List of modules
$modules = $request->getRawVal( 'modules' );
- $this->modules = $modules ? self::expandModuleNames( $modules ) : [];
+ $this->modules = $modules ? ResourceLoader::expandModuleNames( $modules ) : [];
// Various parameters
$this->user = $request->getRawVal( 'user' );
}
/**
- * Expand a string of the form `jquery.foo,bar|jquery.ui.baz,quux` to
- * an array of module names like `[ 'jquery.foo', 'jquery.bar',
- * 'jquery.ui.baz', 'jquery.ui.quux' ]`.
- *
- * This process is reversed by ResourceLoader::makePackedModulesString().
+ * Reverse the process done by ResourceLoader::makePackedModulesString().
*
+ * @deprecated since 1.33 Use ResourceLoader::expandModuleNames instead.
* @param string $modules Packed module name list
* @return array Array of module names
+ * @codeCoverageIgnore
*/
public static function expandModuleNames( $modules ) {
- $retval = [];
- $exploded = explode( '|', $modules );
- foreach ( $exploded as $group ) {
- if ( strpos( $group, ',' ) === false ) {
- // This is not a set of modules in foo.bar,baz notation
- // but a single module
- $retval[] = $group;
- } else {
- // This is a set of modules in foo.bar,baz notation
- $pos = strrpos( $group, '.' );
- if ( $pos === false ) {
- // Prefixless modules, i.e. without dots
- $retval = array_merge( $retval, explode( ',', $group ) );
- } else {
- // We have a prefix and a bunch of suffixes
- $prefix = substr( $group, 0, $pos ); // 'foo'
- $suffixes = explode( ',', substr( $group, $pos + 1 ) ); // [ 'bar', 'baz' ]
- foreach ( $suffixes as $suffix ) {
- $retval[] = "$prefix.$suffix";
- }
- }
- }
- }
- return $retval;
+ wfDeprecated( __METHOD__, '1.33' );
+ return ResourceLoader::expandModuleNames( $modules );
}
/**
* to a query string of the form `foo.bar,baz|bar.baz,quux`.
*
* See `ResourceLoader::makePackedModulesString()` in PHP, of which this is a port.
- * On the server, unpacking is done by `ResourceLoaderContext::expandModuleNames()`.
+ * On the server, unpacking is done by `ResourceLoader::expandModuleNames()`.
*
* Note: This is only half of the logic, the other half has to be in #batchRequest(),
* because its implementation needs to keep track of potential string size in order
/**
* See also:
- * - ResourceLoaderTest::testExpandModuleNames
* - ResourceLoaderImageModuleTest::testContext
*
- * @group Cache
+ * @group ResourceLoader
* @covers ResourceLoaderContext
*/
class ResourceLoaderContextTest extends PHPUnit\Framework\TestCase {
/**
* @dataProvider providePackedModules
- * @covers ResourceLoaderContext::expandModuleNames
+ * @covers ResourceLoader::expandModuleNames
*/
public function testExpandModuleNames( $desc, $modules, $packed, $unpacked = null ) {
$this->assertEquals(
$unpacked ?: $modules,
- ResourceLoaderContext::expandModuleNames( $packed ),
+ ResourceLoader::expandModuleNames( $packed ),
$desc
);
}
$response = '';
-// Does not support the full behaviour of ResourceLoaderContext::expandModuleNames(),
-// Only supports dotless module names joined by comma,
+// Does not support the full behaviour of the real load.php.
+// This only supports dotless module names joined by comma,
// with the exception of the hardcoded cases for testUrl*.
if ( isset( $_GET['modules'] ) ) {
if ( $_GET['modules'] === 'testUrlInc,testUrlIncDump|testUrlInc.a,b' ) {