<exclude-pattern>*/includes/RevisionList\.php</exclude-pattern>
<exclude-pattern>*/includes/installer/PhpBugTests\.php</exclude-pattern>
<exclude-pattern>*/includes/specials/SpecialMostinterwikis\.php</exclude-pattern>
- <exclude-pattern>*/includes/cache/CacheDependency\.php</exclude-pattern>
<exclude-pattern>*/includes/compat/XMPReader\.php</exclude-pattern>
<exclude-pattern>*/includes/diff/DairikiDiff\.php</exclude-pattern>
<exclude-pattern>*/includes/specials/SpecialAncientpages\.php</exclude-pattern>
<exclude-pattern>*/includes/api/ApiMessage\.php</exclude-pattern>
<exclude-pattern>*/includes/api/ApiOpenSearch\.php</exclude-pattern>
<exclude-pattern>*/includes/api/ApiRsd\.php</exclude-pattern>
- <exclude-pattern>*/includes/cache/CacheDependency\.php</exclude-pattern>
<exclude-pattern>*/includes/compat/XMPReader\.php</exclude-pattern>
<exclude-pattern>*/includes/diff/DairikiDiff\.php</exclude-pattern>
<exclude-pattern>*/includes/diff/DiffEngine\.php</exclude-pattern>
* (T217772) The 'wgAvailableSkins' mw.config key in JavaScript, was removed.
* Language::markNoConversion, deprecated in 1.32, has been removed. Use
LanguageConverter::markNoConversion instead.
+* BagOStuff::modifySimpleRelayEvent() method has been removed.
=== Deprecations in 1.33 ===
* The configuration option $wgUseESI has been deprecated, and is expected
'BufferingStatsdDataFactory' => __DIR__ . '/includes/libs/stats/BufferingStatsdDataFactory.php',
'CLIParser' => __DIR__ . '/maintenance/parse.php',
'CSSMin' => __DIR__ . '/includes/libs/CSSMin.php',
- 'CacheDependency' => __DIR__ . '/includes/cache/CacheDependency.php',
+ 'CacheDependency' => __DIR__ . '/includes/cache/dependency/CacheDependency.php',
'CacheHelper' => __DIR__ . '/includes/cache/CacheHelper.php',
'CacheTime' => __DIR__ . '/includes/parser/CacheTime.php',
'CachedAction' => __DIR__ . '/includes/actions/CachedAction.php',
'ConfigException' => __DIR__ . '/includes/config/ConfigException.php',
'ConfigFactory' => __DIR__ . '/includes/config/ConfigFactory.php',
'ConfiguredReadOnlyMode' => __DIR__ . '/includes/ConfiguredReadOnlyMode.php',
- 'ConstantDependency' => __DIR__ . '/includes/cache/CacheDependency.php',
+ 'ConstantDependency' => __DIR__ . '/includes/cache/dependency/ConstantDependency.php',
'Content' => __DIR__ . '/includes/content/Content.php',
'ContentHandler' => __DIR__ . '/includes/content/ContentHandler.php',
'ContentModelLogFormatter' => __DIR__ . '/includes/logging/ContentModelLogFormatter.php',
'DeleteSelfExternals' => __DIR__ . '/maintenance/deleteSelfExternals.php',
'DeletedContribsPager' => __DIR__ . '/includes/specials/pagers/DeletedContribsPager.php',
'DeletedContributionsPage' => __DIR__ . '/includes/specials/SpecialDeletedContributions.php',
- 'DependencyWrapper' => __DIR__ . '/includes/cache/CacheDependency.php',
+ 'DependencyWrapper' => __DIR__ . '/includes/cache/dependency/DependencyWrapper.php',
'DeprecatedGlobal' => __DIR__ . '/includes/DeprecatedGlobal.php',
'DeprecatedInterfaceFinder' => __DIR__ . '/maintenance/findDeprecated.php',
'DeprecationHelper' => __DIR__ . '/includes/debug/DeprecationHelper.php',
'FileContentHandler' => __DIR__ . '/includes/content/FileContentHandler.php',
'FileContentsHasher' => __DIR__ . '/includes/utils/FileContentsHasher.php',
'FileDeleteForm' => __DIR__ . '/includes/FileDeleteForm.php',
- 'FileDependency' => __DIR__ . '/includes/cache/CacheDependency.php',
+ 'FileDependency' => __DIR__ . '/includes/cache/dependency/FileDependency.php',
'FileDuplicateSearchPage' => __DIR__ . '/includes/specials/SpecialFileDuplicateSearch.php',
'FileJournal' => __DIR__ . '/includes/libs/filebackend/filejournal/FileJournal.php',
'FileOp' => __DIR__ . '/includes/libs/filebackend/fileop/FileOp.php',
'GetReplicaServer' => __DIR__ . '/maintenance/getReplicaServer.php',
'GetTextMaint' => __DIR__ . '/maintenance/getText.php',
'GitInfo' => __DIR__ . '/includes/GitInfo.php',
- 'GlobalDependency' => __DIR__ . '/includes/cache/CacheDependency.php',
+ 'GlobalDependency' => __DIR__ . '/includes/cache/dependency/GlobalDependency.php',
'GlobalVarConfig' => __DIR__ . '/includes/config/GlobalVarConfig.php',
'GuzzleHttpRequest' => __DIR__ . '/includes/http/GuzzleHttpRequest.php',
'HHVMMakeRepo' => __DIR__ . '/maintenance/hhvm/makeRepo.php',
'MagicWordArray' => __DIR__ . '/includes/MagicWordArray.php',
'MagicWordFactory' => __DIR__ . '/includes/MagicWordFactory.php',
'MailAddress' => __DIR__ . '/includes/mail/MailAddress.php',
- 'MainConfigDependency' => __DIR__ . '/includes/cache/CacheDependency.php',
+ 'MainConfigDependency' => __DIR__ . '/includes/cache/dependency/MainConfigDependency.php',
'MaintainableDBConnRef' => __DIR__ . '/includes/libs/rdbms/database/MaintainableDBConnRef.php',
'Maintenance' => __DIR__ . '/maintenance/Maintenance.php',
'MakeTestEdits' => __DIR__ . '/maintenance/makeTestEdits.php',
$db, 'log_user', User::newFromName( $params['user'], false )
);
$this->addWhere( $q['conds'] );
+
+ // T71222: MariaDB's optimizer, at least 10.1.37 and .38, likes to choose a wildly bad plan for
+ // some reason for this code path. Tell it not to use the wrong index it wants to pick.
+ $this->addOption( 'IGNORE INDEX', [ 'logging' => [ 'times' ] ] );
}
$title = $params['title'];
+++ /dev/null
-<?php
-/**
- * Data caching with dependencies.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Cache
- */
-use MediaWiki\MediaWikiServices;
-
-/**
- * This class stores an arbitrary value along with its dependencies.
- * Users should typically only use DependencyWrapper::getValueFromCache(),
- * rather than instantiating one of these objects directly.
- * @ingroup Cache
- */
-class DependencyWrapper {
- private $value;
- /** @var CacheDependency[] */
- private $deps;
-
- /**
- * @param mixed $value The user-supplied value
- * @param CacheDependency|CacheDependency[] $deps A dependency or dependency
- * array. All dependencies must be objects implementing CacheDependency.
- */
- function __construct( $value = false, $deps = [] ) {
- $this->value = $value;
-
- if ( !is_array( $deps ) ) {
- $deps = [ $deps ];
- }
-
- $this->deps = $deps;
- }
-
- /**
- * Returns true if any of the dependencies have expired
- *
- * @return bool
- */
- function isExpired() {
- foreach ( $this->deps as $dep ) {
- if ( $dep->isExpired() ) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Initialise dependency values in preparation for storing. This must be
- * called before serialization.
- */
- function initialiseDeps() {
- foreach ( $this->deps as $dep ) {
- $dep->loadDependencyValues();
- }
- }
-
- /**
- * Get the user-defined value
- * @return bool|mixed
- */
- function getValue() {
- return $this->value;
- }
-
- /**
- * Store the wrapper to a cache
- *
- * @param BagOStuff $cache
- * @param string $key
- * @param int $expiry
- */
- function storeToCache( $cache, $key, $expiry = 0 ) {
- $this->initialiseDeps();
- $cache->set( $key, $this, $expiry );
- }
-
- /**
- * Attempt to get a value from the cache. If the value is expired or missing,
- * it will be generated with the callback function (if present), and the newly
- * calculated value will be stored to the cache in a wrapper.
- *
- * @param BagOStuff $cache
- * @param string $key The cache key
- * @param int $expiry The expiry timestamp or interval in seconds
- * @param bool|callable $callback The callback for generating the value, or false
- * @param array $callbackParams The function parameters for the callback
- * @param array $deps The dependencies to store on a cache miss. Note: these
- * are not the dependencies used on a cache hit! Cache hits use the stored
- * dependency array.
- *
- * @return mixed The value, or null if it was not present in the cache and no
- * callback was defined.
- */
- static function getValueFromCache( $cache, $key, $expiry = 0, $callback = false,
- $callbackParams = [], $deps = []
- ) {
- $obj = $cache->get( $key );
-
- if ( is_object( $obj ) && $obj instanceof DependencyWrapper && !$obj->isExpired() ) {
- $value = $obj->value;
- } elseif ( $callback ) {
- $value = $callback( ...$callbackParams );
- # Cache the newly-generated value
- $wrapper = new DependencyWrapper( $value, $deps );
- $wrapper->storeToCache( $cache, $key, $expiry );
- } else {
- $value = null;
- }
-
- return $value;
- }
-}
-
-/**
- * @ingroup Cache
- */
-abstract class CacheDependency {
- /**
- * Returns true if the dependency is expired, false otherwise
- */
- abstract function isExpired();
-
- /**
- * Hook to perform any expensive pre-serialize loading of dependency values.
- */
- function loadDependencyValues() {
- }
-}
-
-/**
- * @ingroup Cache
- */
-class FileDependency extends CacheDependency {
- private $filename;
- private $timestamp;
-
- /**
- * Create a file dependency
- *
- * @param string $filename The name of the file, preferably fully qualified
- * @param null|bool|int $timestamp The unix last modified timestamp, or false if the
- * file does not exist. If omitted, the timestamp will be loaded from
- * the file.
- *
- * A dependency on a nonexistent file will be triggered when the file is
- * created. A dependency on an existing file will be triggered when the
- * file is changed.
- */
- function __construct( $filename, $timestamp = null ) {
- $this->filename = $filename;
- $this->timestamp = $timestamp;
- }
-
- /**
- * @return array
- */
- function __sleep() {
- $this->loadDependencyValues();
-
- return [ 'filename', 'timestamp' ];
- }
-
- function loadDependencyValues() {
- if ( is_null( $this->timestamp ) ) {
- Wikimedia\suppressWarnings();
- # Dependency on a non-existent file stores "false"
- # This is a valid concept!
- $this->timestamp = filemtime( $this->filename );
- Wikimedia\restoreWarnings();
- }
- }
-
- /**
- * @return bool
- */
- function isExpired() {
- Wikimedia\suppressWarnings();
- $lastmod = filemtime( $this->filename );
- Wikimedia\restoreWarnings();
- if ( $lastmod === false ) {
- if ( $this->timestamp === false ) {
- # Still nonexistent
- return false;
- } else {
- # Deleted
- wfDebug( "Dependency triggered: {$this->filename} deleted.\n" );
-
- return true;
- }
- } else {
- if ( $lastmod > $this->timestamp ) {
- # Modified or created
- wfDebug( "Dependency triggered: {$this->filename} changed.\n" );
-
- return true;
- } else {
- # Not modified
- return false;
- }
- }
- }
-}
-
-/**
- * @ingroup Cache
- */
-class GlobalDependency extends CacheDependency {
- private $name;
- private $value;
-
- function __construct( $name ) {
- $this->name = $name;
- $this->value = $GLOBALS[$name];
- }
-
- /**
- * @return bool
- */
- function isExpired() {
- if ( !isset( $GLOBALS[$this->name] ) ) {
- return true;
- }
-
- return $GLOBALS[$this->name] != $this->value;
- }
-}
-
-/**
- * @ingroup Cache
- */
-class MainConfigDependency extends CacheDependency {
- private $name;
- private $value;
-
- function __construct( $name ) {
- $this->name = $name;
- $this->value = $this->getConfig()->get( $this->name );
- }
-
- private function getConfig() {
- return MediaWikiServices::getInstance()->getMainConfig();
- }
-
- /**
- * @return bool
- */
- function isExpired() {
- if ( !$this->getConfig()->has( $this->name ) ) {
- return true;
- }
-
- return $this->getConfig()->get( $this->name ) != $this->value;
- }
-}
-
-/**
- * @ingroup Cache
- */
-class ConstantDependency extends CacheDependency {
- private $name;
- private $value;
-
- function __construct( $name ) {
- $this->name = $name;
- $this->value = constant( $name );
- }
-
- /**
- * @return bool
- */
- function isExpired() {
- return constant( $this->name ) != $this->value;
- }
-}
--- /dev/null
+<?php
+/**
+ * Data caching with dependencies.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Cache
+ */
+
+/**
+ * @ingroup Cache
+ */
+abstract class CacheDependency {
+ /**
+ * Returns true if the dependency is expired, false otherwise
+ */
+ abstract function isExpired();
+
+ /**
+ * Hook to perform any expensive pre-serialize loading of dependency values.
+ */
+ function loadDependencyValues() {
+ }
+}
--- /dev/null
+<?php
+/**
+ * Data caching with dependencies.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Cache
+ */
+
+/**
+ * @ingroup Cache
+ */
+class ConstantDependency extends CacheDependency {
+ private $name;
+ private $value;
+
+ function __construct( $name ) {
+ $this->name = $name;
+ $this->value = constant( $name );
+ }
+
+ /**
+ * @return bool
+ */
+ function isExpired() {
+ return constant( $this->name ) != $this->value;
+ }
+}
--- /dev/null
+<?php
+/**
+ * Data caching with dependencies.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Cache
+ */
+
+/**
+ * This class stores an arbitrary value along with its dependencies.
+ * Users should typically only use DependencyWrapper::getValueFromCache(),
+ * rather than instantiating one of these objects directly.
+ * @ingroup Cache
+ */
+class DependencyWrapper {
+ private $value;
+ /** @var CacheDependency[] */
+ private $deps;
+
+ /**
+ * @param mixed $value The user-supplied value
+ * @param CacheDependency|CacheDependency[] $deps A dependency or dependency
+ * array. All dependencies must be objects implementing CacheDependency.
+ */
+ function __construct( $value = false, $deps = [] ) {
+ $this->value = $value;
+
+ if ( !is_array( $deps ) ) {
+ $deps = [ $deps ];
+ }
+
+ $this->deps = $deps;
+ }
+
+ /**
+ * Returns true if any of the dependencies have expired
+ *
+ * @return bool
+ */
+ function isExpired() {
+ foreach ( $this->deps as $dep ) {
+ if ( $dep->isExpired() ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Initialise dependency values in preparation for storing. This must be
+ * called before serialization.
+ */
+ function initialiseDeps() {
+ foreach ( $this->deps as $dep ) {
+ $dep->loadDependencyValues();
+ }
+ }
+
+ /**
+ * Get the user-defined value
+ * @return bool|mixed
+ */
+ function getValue() {
+ return $this->value;
+ }
+
+ /**
+ * Store the wrapper to a cache
+ *
+ * @param BagOStuff $cache
+ * @param string $key
+ * @param int $expiry
+ */
+ function storeToCache( $cache, $key, $expiry = 0 ) {
+ $this->initialiseDeps();
+ $cache->set( $key, $this, $expiry );
+ }
+
+ /**
+ * Attempt to get a value from the cache. If the value is expired or missing,
+ * it will be generated with the callback function (if present), and the newly
+ * calculated value will be stored to the cache in a wrapper.
+ *
+ * @param BagOStuff $cache
+ * @param string $key The cache key
+ * @param int $expiry The expiry timestamp or interval in seconds
+ * @param bool|callable $callback The callback for generating the value, or false
+ * @param array $callbackParams The function parameters for the callback
+ * @param array $deps The dependencies to store on a cache miss. Note: these
+ * are not the dependencies used on a cache hit! Cache hits use the stored
+ * dependency array.
+ *
+ * @return mixed The value, or null if it was not present in the cache and no
+ * callback was defined.
+ */
+ static function getValueFromCache( $cache, $key, $expiry = 0, $callback = false,
+ $callbackParams = [], $deps = []
+ ) {
+ $obj = $cache->get( $key );
+
+ if ( is_object( $obj ) && $obj instanceof DependencyWrapper && !$obj->isExpired() ) {
+ $value = $obj->value;
+ } elseif ( $callback ) {
+ $value = $callback( ...$callbackParams );
+ # Cache the newly-generated value
+ $wrapper = new DependencyWrapper( $value, $deps );
+ $wrapper->storeToCache( $cache, $key, $expiry );
+ } else {
+ $value = null;
+ }
+
+ return $value;
+ }
+}
--- /dev/null
+<?php
+/**
+ * Data caching with dependencies.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Cache
+ */
+
+/**
+ * @ingroup Cache
+ */
+class FileDependency extends CacheDependency {
+ private $filename;
+ private $timestamp;
+
+ /**
+ * Create a file dependency
+ *
+ * @param string $filename The name of the file, preferably fully qualified
+ * @param null|bool|int $timestamp The unix last modified timestamp, or false if the
+ * file does not exist. If omitted, the timestamp will be loaded from
+ * the file.
+ *
+ * A dependency on a nonexistent file will be triggered when the file is
+ * created. A dependency on an existing file will be triggered when the
+ * file is changed.
+ */
+ function __construct( $filename, $timestamp = null ) {
+ $this->filename = $filename;
+ $this->timestamp = $timestamp;
+ }
+
+ /**
+ * @return array
+ */
+ function __sleep() {
+ $this->loadDependencyValues();
+
+ return [ 'filename', 'timestamp' ];
+ }
+
+ function loadDependencyValues() {
+ if ( is_null( $this->timestamp ) ) {
+ Wikimedia\suppressWarnings();
+ # Dependency on a non-existent file stores "false"
+ # This is a valid concept!
+ $this->timestamp = filemtime( $this->filename );
+ Wikimedia\restoreWarnings();
+ }
+ }
+
+ /**
+ * @return bool
+ */
+ function isExpired() {
+ Wikimedia\suppressWarnings();
+ $lastmod = filemtime( $this->filename );
+ Wikimedia\restoreWarnings();
+ if ( $lastmod === false ) {
+ if ( $this->timestamp === false ) {
+ # Still nonexistent
+ return false;
+ } else {
+ # Deleted
+ wfDebug( "Dependency triggered: {$this->filename} deleted.\n" );
+
+ return true;
+ }
+ } else {
+ if ( $lastmod > $this->timestamp ) {
+ # Modified or created
+ wfDebug( "Dependency triggered: {$this->filename} changed.\n" );
+
+ return true;
+ } else {
+ # Not modified
+ return false;
+ }
+ }
+ }
+}
--- /dev/null
+<?php
+/**
+ * Data caching with dependencies.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Cache
+ */
+
+/**
+ * @ingroup Cache
+ */
+class GlobalDependency extends CacheDependency {
+ private $name;
+ private $value;
+
+ function __construct( $name ) {
+ $this->name = $name;
+ $this->value = $GLOBALS[$name];
+ }
+
+ /**
+ * @return bool
+ */
+ function isExpired() {
+ if ( !isset( $GLOBALS[$this->name] ) ) {
+ return true;
+ }
+
+ return $GLOBALS[$this->name] != $this->value;
+ }
+}
--- /dev/null
+<?php
+/**
+ * Data caching with dependencies.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Cache
+ */
+use MediaWiki\MediaWikiServices;
+
+/**
+ * @ingroup Cache
+ */
+class MainConfigDependency extends CacheDependency {
+ private $name;
+ private $value;
+
+ function __construct( $name ) {
+ $this->name = $name;
+ $this->value = $this->getConfig()->get( $this->name );
+ }
+
+ private function getConfig() {
+ return MediaWikiServices::getInstance()->getMainConfig();
+ }
+
+ /**
+ * @return bool
+ */
+ function isExpired() {
+ if ( !$this->getConfig()->has( $this->name ) ) {
+ return true;
+ }
+
+ return $this->getConfig()->get( $this->name ) != $this->value;
+ }
+}
/** @var int[] Map of (ATTR_* class constant => QOS_* class constant) */
protected $attrMap = [];
- /** Possible values for getLastError() */
- const ERR_NONE = 0; // no error
- const ERR_NO_RESPONSE = 1; // no response
- const ERR_UNREACHABLE = 2; // can't connect
- const ERR_UNEXPECTED = 3; // response gave some error
-
/** Bitfield constants for get()/getMulti() */
const READ_LATEST = 1; // use latest data for replicated stores
const READ_VERIFIED = 2; // promise that caller can tell when keys are stale
$this->busyCallbacks[] = $workCallback;
}
- /**
- * Modify a cache update operation array for EventRelayer::notify()
- *
- * This is used for relayed writes, e.g. for broadcasting a change
- * to multiple data-centers. If the array contains a 'val' field
- * then the command involves setting a key to that value. Note that
- * for simplicity, 'val' is always a simple scalar value. This method
- * is used to possibly serialize the value and add any cache-specific
- * key/values needed for the relayer daemon (e.g. memcached flags).
- *
- * @param array $event
- * @return array
- * @since 1.26
- */
- public function modifySimpleRelayEvent( array $event ) {
- return $event;
- }
-
/**
* @param string $text
*/
return $this->backend->clearLastError();
}
- public function modifySimpleRelayEvent( array $event ) {
- return $this->backend->modifySimpleRelayEvent( $event );
- }
-
// @codeCoverageIgnoreEnd
}
const QOS_SYNCWRITES_SS = 4; // strict-serializable, nodes refuse reads if possible stale
// Generic "unknown" value that is useful for comparisons (e.g. always good enough)
const QOS_UNKNOWN = INF;
+
+ const ERR_NONE = 0; // no error
+ const ERR_NO_RESPONSE = 1; // no response
+ const ERR_UNREACHABLE = 2; // can't connect
+ const ERR_UNEXPECTED = 3; // response gave some error
}
protected function debugLog( $text ) {
$this->logger->debug( $text );
}
-
- public function modifySimpleRelayEvent( array $event ) {
- if ( array_key_exists( 'val', $event ) ) {
- $event['flg'] = 0; // data is not serialized nor gzipped (for memcached driver)
- }
-
- return $event;
- }
}
return $result;
}
- public function modifySimpleRelayEvent( array $event ) {
- if ( array_key_exists( 'val', $event ) ) {
- $event['val'] = serialize( $event['val'] ); // this class uses PHP serialization
- }
-
- return $event;
- }
-
/**
* @param mixed $data
* @return string
const FLD_FLAGS = 4; // key to the flags bitfield (reserved number)
const FLD_HOLDOFF = 5; // key to any hold-off TTL
- const ERR_NONE = 0; // no error
- const ERR_NO_RESPONSE = 1; // no response
- const ERR_UNREACHABLE = 2; // can't connect
- const ERR_UNEXPECTED = 3; // response gave some error
- const ERR_RELAY = 4; // relay broadcast failed
-
const VALUE_KEY_PREFIX = 'WANCache:v:';
const INTERIM_KEY_PREFIX = 'WANCache:i:';
const TIME_KEY_PREFIX = 'WANCache:t:';
* @param array $params
* - cache : BagOStuff object for a persistent cache
* - logger : LoggerInterface object
- * - stats : LoggerInterface object
+ * - stats : StatsdDataFactoryInterface object
* - asyncHandler : A function that takes a callback and runs it later. If supplied,
* whenever a preemptive refresh would be triggered in getWithSetCallback(), the
* current cache value is still used instead. However, the async-handler function
* @return bool True if the item was purged or not found, false on failure
*/
final public function delete( $key, $ttl = self::HOLDOFF_TTL ) {
- $key = self::VALUE_KEY_PREFIX . $key;
-
if ( $ttl <= 0 ) {
// Publish the purge to all datacenters
- $ok = $this->relayDelete( $key );
+ $ok = $this->relayDelete( self::VALUE_KEY_PREFIX . $key );
} else {
// Publish the purge to all datacenters
- $ok = $this->relayPurge( $key, $ttl, self::HOLDOFF_NONE );
+ $ok = $this->relayPurge( self::VALUE_KEY_PREFIX . $key, $ttl, self::HOLDOFF_NONE );
}
+ $kClass = $this->determineKeyClassForStats( $key );
+ $this->stats->increment( "wanobjectcache.$kClass.delete." . ( $ok ? 'ok' : 'error' ) );
+
return $ok;
}
*/
final public function touchCheckKey( $key, $holdoff = self::HOLDOFF_TTL ) {
// Publish the purge to all datacenters
- return $this->relayPurge( self::TIME_KEY_PREFIX . $key, self::CHECK_KEY_TTL, $holdoff );
+ $ok = $this->relayPurge( self::TIME_KEY_PREFIX . $key, self::CHECK_KEY_TTL, $holdoff );
+
+ $kClass = $this->determineKeyClassForStats( $key );
+ $this->stats->increment( "wanobjectcache.$kClass.ck_touch." . ( $ok ? 'ok' : 'error' ) );
+
+ return $ok;
}
/**
*/
final public function resetCheckKey( $key ) {
// Publish the purge to all datacenters
- return $this->relayDelete( self::TIME_KEY_PREFIX . $key );
+ $ok = $this->relayDelete( self::TIME_KEY_PREFIX . $key );
+
+ $kClass = $this->determineKeyClassForStats( $key );
+ $this->stats->increment( "wanobjectcache.$kClass.ck_reset." . ( $ok ? 'ok' : 'error' ) );
+
+ return $ok;
}
/**
$touchedCb = $opts['touchedCallback'] ?? null;
$initialTime = $this->getCurrentTime();
- // Get a collection name to describe this class of key
- $kClass = $this->determineKeyClass( $key );
+ $kClass = $this->determineKeyClassForStats( $key );
// Get the current key value
$curTTL = self::PASS_BY_REF;
/**
* @param string $key String of the format <scope>:<class>[:<class or variable>]...
- * @return string
+ * @return string A collection name to describe this class of key
*/
- protected function determineKeyClass( $key ) {
+ protected function determineKeyClassForStats( $key ) {
$parts = explode( ':', $key );
return $parts[1] ?? $parts[0]; // sanity
// mw.loader.implement will use globalEval if scripts is a string.
// Minify manually here, because general response minification is
// not effective due it being a string literal, not a function.
- if ( !self::inDebugMode() ) {
+ if ( !$context->getDebug() ) {
$scripts = self::filter( 'minify-js', $scripts ); // T107377
}
} else {
'modules' => self::makePackedModulesString( $modules ),
'lang' => $lang,
'skin' => $skin,
- 'debug' => $debug ? 'true' : 'false',
];
+ if ( $debug === true ) {
+ $query['debug'] = 'true';
+ }
if ( $user !== null ) {
$query['user'] = $user;
}
// Various parameters
$this->user = $request->getRawVal( 'user' );
- $this->debug = $request->getFuzzyBool(
- 'debug',
- $this->getConfig()->get( 'ResourceLoaderDebug' )
- );
+ $this->debug = $request->getRawVal( 'debug' ) === 'true';
$this->only = $request->getRawVal( 'only', null );
$this->version = $request->getRawVal( 'version', null );
$this->raw = $request->getFuzzyBool( 'raw' );
* @return {string}
*/
function getElementSortKey( node ) {
- var $node = $( node ),
- // Use data-sort-value attribute.
- // Use data() instead of attr() so that live value changes
- // are processed as well (T40152).
- data = $node.data( 'sortValue' );
+ // Get data-sort-value attribute. Uses jQuery to allow live value
+ // changes from other code paths via data(), which reside only in jQuery.
+ // Must use $().data() instead of $.data(), as the latter *only*
+ // accesses the live values, without reading HTML5 attribs first (T40152).
+ var data = $( node ).data( 'sortValue' );
if ( data !== null && data !== undefined ) {
// Cast any numbers or other stuff to a string, methods
return String( data );
}
if ( node.tagName.toLowerCase() === 'img' ) {
- return $node.attr( 'alt' ) || ''; // handle undefined alt
+ return node.alt;
}
- return $.makeArray( node.childNodes ).map( function ( elem ) {
+ // Iterate the NodeList (not an array).
+ // Also uses null-return as filter in the same pass.
+ // eslint-disable-next-line no-jquery/no-map-util
+ return $.map( node.childNodes, function ( elem ) {
if ( elem.nodeType === Node.ELEMENT_NODE ) {
if ( $( elem ).hasClass( 'reference' ) ) {
return null;
- } else {
- return getElementSortKey( elem );
}
+ return getElementSortKey( elem );
+ }
+ if ( elem.nodeType === Node.TEXT_NODE ) {
+ return elem.textContent;
}
- return $.text( elem );
+ // Ignore other node types, such as HTML comments.
+ return null;
} ).join( '' );
}
}
ul {
- list-style-type: square;
margin: 0.3em 0 0 1.6em;
padding: 0;
}
$options = [ 'lang' => $options ];
}
$options += [
+ 'debug' => 'true',
'lang' => 'en',
'dir' => 'ltr',
'skin' => 'vector',
];
$resourceLoader = $rl ?: new ResourceLoader();
$request = new FauxRequest( [
+ 'debug' => $options['debug'],
'lang' => $options['lang'],
'modules' => $options['modules'],
'only' => $options['only'],
[
[ 'test.foo', ResourceLoaderModule::TYPE_SCRIPTS ],
"<script nonce=\"secret\">(window.RLQ=window.RLQ||[]).push(function(){"
- . 'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.foo\u0026only=scripts\u0026skin=fallback");'
+ . 'mw.loader.load("http://127.0.0.1:8080/w/load.php?lang=en\u0026modules=test.foo\u0026only=scripts\u0026skin=fallback");'
. "});</script>"
],
// Multiple only=styles load
[
[ [ 'test.baz', 'test.foo', 'test.bar' ], ResourceLoaderModule::TYPE_STYLES ],
- '<link rel="stylesheet" href="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.bar%2Cbaz%2Cfoo&only=styles&skin=fallback"/>'
+ '<link rel="stylesheet" href="http://127.0.0.1:8080/w/load.php?lang=en&modules=test.bar%2Cbaz%2Cfoo&only=styles&skin=fallback"/>'
],
// Private embed (only=scripts)
[
// noscript group
[
[ 'test.noscript', ResourceLoaderModule::TYPE_STYLES ],
- '<noscript><link rel="stylesheet" href="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.noscript&only=styles&skin=fallback"/></noscript>'
+ '<noscript><link rel="stylesheet" href="http://127.0.0.1:8080/w/load.php?lang=en&modules=test.noscript&only=styles&skin=fallback"/></noscript>'
],
// Load two modules in separate groups
[
[ [ 'test.group.foo', 'test.group.bar' ], ResourceLoaderModule::TYPE_COMBINED ],
"<script nonce=\"secret\">(window.RLQ=window.RLQ||[]).push(function(){"
- . 'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.group.bar\u0026skin=fallback");'
- . 'mw.loader.load("http://127.0.0.1:8080/w/load.php?debug=false\u0026lang=en\u0026modules=test.group.foo\u0026skin=fallback");'
+ . 'mw.loader.load("http://127.0.0.1:8080/w/load.php?lang=en\u0026modules=test.group.bar\u0026skin=fallback");'
+ . 'mw.loader.load("http://127.0.0.1:8080/w/load.php?lang=en\u0026modules=test.group.foo\u0026skin=fallback");'
. "});</script>"
],
];
'default logged-out' => [
'exemptStyleModules' => [ 'site' => [ 'site.styles' ] ],
'<meta name="ResourceLoaderDynamicStyles" content=""/>' . "\n" .
- '<link rel="stylesheet" href="/w/load.php?debug=false&lang=en&modules=site.styles&only=styles&skin=fallback"/>',
+ '<link rel="stylesheet" href="/w/load.php?lang=en&modules=site.styles&only=styles&skin=fallback"/>',
],
'default logged-in' => [
'exemptStyleModules' => [ 'site' => [ 'site.styles' ], 'user' => [ 'user.styles' ] ],
'<meta name="ResourceLoaderDynamicStyles" content=""/>' . "\n" .
- '<link rel="stylesheet" href="/w/load.php?debug=false&lang=en&modules=site.styles&only=styles&skin=fallback"/>' . "\n" .
- '<link rel="stylesheet" href="/w/load.php?debug=false&lang=en&modules=user.styles&only=styles&skin=fallback&version=1ai9g6t"/>',
+ '<link rel="stylesheet" href="/w/load.php?lang=en&modules=site.styles&only=styles&skin=fallback"/>' . "\n" .
+ '<link rel="stylesheet" href="/w/load.php?lang=en&modules=user.styles&only=styles&skin=fallback&version=1ai9g6t"/>',
],
'custom modules' => [
'exemptStyleModules' => [
'user' => [ 'user.styles', 'example.user' ],
],
'<meta name="ResourceLoaderDynamicStyles" content=""/>' . "\n" .
- '<link rel="stylesheet" href="/w/load.php?debug=false&lang=en&modules=example.site.a%2Cb&only=styles&skin=fallback"/>' . "\n" .
- '<link rel="stylesheet" href="/w/load.php?debug=false&lang=en&modules=site.styles&only=styles&skin=fallback"/>' . "\n" .
- '<link rel="stylesheet" href="/w/load.php?debug=false&lang=en&modules=example.user&only=styles&skin=fallback&version=0a56zyi"/>' . "\n" .
- '<link rel="stylesheet" href="/w/load.php?debug=false&lang=en&modules=user.styles&only=styles&skin=fallback&version=1ai9g6t"/>',
+ '<link rel="stylesheet" href="/w/load.php?lang=en&modules=example.site.a%2Cb&only=styles&skin=fallback"/>' . "\n" .
+ '<link rel="stylesheet" href="/w/load.php?lang=en&modules=site.styles&only=styles&skin=fallback"/>' . "\n" .
+ '<link rel="stylesheet" href="/w/load.php?lang=en&modules=example.user&only=styles&skin=fallback&version=0a56zyi"/>' . "\n" .
+ '<link rel="stylesheet" href="/w/load.php?lang=en&modules=user.styles&only=styles&skin=fallback&version=1ai9g6t"/>',
],
];
// phpcs:enable
/**
* @dataProvider statsKeyProvider
- * @covers WANObjectCache::determineKeyClass
+ * @covers WANObjectCache::determineKeyClassForStats
*/
public function testStatsKeyClass( $key, $class ) {
$wanCache = TestingAccessWrapper::newFromObject( new WANObjectCache( [
'cache' => new HashBagOStuff
] ) );
- $this->assertEquals( $class, $wanCache->determineKeyClass( $key ) );
+ $this->assertEquals( $class, $wanCache->determineKeyClassForStats( $key ) );
}
}
'ResourceModuleSkinStyles' => [],
'ResourceModules' => [],
'EnableJavaScriptTest' => false,
- 'ResourceLoaderDebug' => false,
'LoadScript' => '/w/load.php',
] );
return new ResourceLoaderContext(
. 'mw.loader.implement("test.private@{blankVer}",null,{"css":[]});'
. 'RLPAGEMODULES=["test"];mw.loader.load(RLPAGEMODULES);'
. '});</script>' . "\n"
- . '<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.styles.deprecated%2Cpure&only=styles&skin=fallback"/>' . "\n"
+ . '<link rel="stylesheet" href="/w/load.php?lang=nl&modules=test.styles.deprecated%2Cpure&only=styles&skin=fallback"/>' . "\n"
. '<style>.private{}</style>' . "\n"
- . '<script async="" src="/w/load.php?debug=false&lang=nl&modules=startup&only=scripts&skin=fallback"></script>';
+ . '<script async="" src="/w/load.php?lang=nl&modules=startup&only=scripts&skin=fallback"></script>';
// phpcs:enable
$expected = self::expandVariables( $expected );
// phpcs:disable Generic.Files.LineLength
$expected = '<script>document.documentElement.className = document.documentElement.className.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );</script>' . "\n"
- . '<script async="" src="/w/load.php?debug=false&lang=nl&modules=startup&only=scripts&skin=fallback&target=example"></script>';
+ . '<script async="" src="/w/load.php?lang=nl&modules=startup&only=scripts&skin=fallback&target=example"></script>';
// phpcs:enable
$this->assertEquals( $expected, $client->getHeadHtml() );
// phpcs:disable Generic.Files.LineLength
$expected = '<script>document.documentElement.className = document.documentElement.className.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );</script>' . "\n"
- . '<script async="" src="/w/load.php?debug=false&lang=nl&modules=startup&only=scripts&safemode=1&skin=fallback"></script>';
+ . '<script async="" src="/w/load.php?lang=nl&modules=startup&only=scripts&safemode=1&skin=fallback"></script>';
// phpcs:enable
$this->assertEquals( $expected, $client->getHeadHtml() );
// phpcs:disable Generic.Files.LineLength
$expected = '<script>document.documentElement.className = document.documentElement.className.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );</script>' . "\n"
- . '<script async="" src="/w/load.php?debug=false&lang=nl&modules=startup&only=scripts&skin=fallback"></script>';
+ . '<script async="" src="/w/load.php?lang=nl&modules=startup&only=scripts&skin=fallback"></script>';
// phpcs:enable
$this->assertEquals( $expected, $client->getHeadHtml() );
'context' => [],
'modules' => [ 'test.unknown' ],
'only' => ResourceLoaderModule::TYPE_STYLES,
+ 'extra' => [],
'output' => '',
],
[
'context' => [],
'modules' => [ 'test.styles.private' ],
'only' => ResourceLoaderModule::TYPE_STYLES,
+ 'extra' => [],
'output' => '<style>.private{}</style>',
],
[
'context' => [],
'modules' => [ 'test.private' ],
'only' => ResourceLoaderModule::TYPE_COMBINED,
+ 'extra' => [],
'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.implement("test.private@{blankVer}",null,{"css":[]});});</script>',
],
[
// Eg. startup module
'modules' => [ 'test.scripts.raw' ],
'only' => ResourceLoaderModule::TYPE_SCRIPTS,
- 'output' => '<script async="" src="/w/load.php?debug=false&lang=nl&modules=test.scripts.raw&only=scripts&skin=fallback"></script>',
+ 'extra' => [],
+ 'output' => '<script async="" src="/w/load.php?lang=nl&modules=test.scripts.raw&only=scripts&skin=fallback"></script>',
],
[
- 'context' => [ 'sync' => true ],
+ 'context' => [],
'modules' => [ 'test.scripts.raw' ],
'only' => ResourceLoaderModule::TYPE_SCRIPTS,
- 'output' => '<script src="/w/load.php?debug=false&lang=nl&modules=test.scripts.raw&only=scripts&skin=fallback&sync=1"></script>',
+ 'extra' => [ 'sync' => '1' ],
+ 'output' => '<script src="/w/load.php?lang=nl&modules=test.scripts.raw&only=scripts&skin=fallback&sync=1"></script>',
],
[
'context' => [],
'modules' => [ 'test.scripts.user' ],
'only' => ResourceLoaderModule::TYPE_SCRIPTS,
- 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test.scripts.user\u0026only=scripts\u0026skin=fallback\u0026user=Example\u0026version=0a56zyi");});</script>',
+ 'extra' => [],
+ 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.load("/w/load.php?lang=nl\u0026modules=test.scripts.user\u0026only=scripts\u0026skin=fallback\u0026user=Example\u0026version=0a56zyi");});</script>',
],
[
'context' => [],
'modules' => [ 'test.user' ],
'only' => ResourceLoaderModule::TYPE_COMBINED,
- 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test.user\u0026skin=fallback\u0026user=Example\u0026version=0a56zyi");});</script>',
+ 'extra' => [],
+ 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.load("/w/load.php?lang=nl\u0026modules=test.user\u0026skin=fallback\u0026user=Example\u0026version=0a56zyi");});</script>',
],
[
- 'context' => [ 'debug' => true ],
+ 'context' => [ 'debug' => 'true' ],
'modules' => [ 'test.styles.pure', 'test.styles.mixed' ],
'only' => ResourceLoaderModule::TYPE_STYLES,
+ 'extra' => [],
'output' => '<link rel="stylesheet" href="/w/load.php?debug=true&lang=nl&modules=test.styles.mixed&only=styles&skin=fallback"/>' . "\n"
. '<link rel="stylesheet" href="/w/load.php?debug=true&lang=nl&modules=test.styles.pure&only=styles&skin=fallback"/>',
],
[
- 'context' => [ 'debug' => false ],
+ 'context' => [ 'debug' => 'false' ],
'modules' => [ 'test.styles.pure', 'test.styles.mixed' ],
'only' => ResourceLoaderModule::TYPE_STYLES,
- 'output' => '<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.styles.mixed%2Cpure&only=styles&skin=fallback"/>',
+ 'extra' => [],
+ 'output' => '<link rel="stylesheet" href="/w/load.php?lang=nl&modules=test.styles.mixed%2Cpure&only=styles&skin=fallback"/>',
],
[
'context' => [],
'modules' => [ 'test.styles.noscript' ],
'only' => ResourceLoaderModule::TYPE_STYLES,
- 'output' => '<noscript><link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.styles.noscript&only=styles&skin=fallback"/></noscript>',
+ 'extra' => [],
+ 'output' => '<noscript><link rel="stylesheet" href="/w/load.php?lang=nl&modules=test.styles.noscript&only=styles&skin=fallback"/></noscript>',
],
[
'context' => [],
'modules' => [ 'test.shouldembed' ],
'only' => ResourceLoaderModule::TYPE_COMBINED,
+ 'extra' => [],
'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.implement("test.shouldembed@09p30q0",null,{"css":[]});});</script>',
],
[
'context' => [],
'modules' => [ 'test.styles.shouldembed' ],
'only' => ResourceLoaderModule::TYPE_STYLES,
+ 'extra' => [],
'output' => '<style>.shouldembed{}</style>',
],
[
'context' => [],
'modules' => [ 'test.scripts.shouldembed' ],
'only' => ResourceLoaderModule::TYPE_SCRIPTS,
+ 'extra' => [],
'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.state({"test.scripts.shouldembed":"ready"});});</script>',
],
[
'context' => [],
'modules' => [ 'test', 'test.shouldembed' ],
'only' => ResourceLoaderModule::TYPE_COMBINED,
- 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test\u0026skin=fallback");mw.loader.implement("test.shouldembed@09p30q0",null,{"css":[]});});</script>',
+ 'extra' => [],
+ 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.load("/w/load.php?lang=nl\u0026modules=test\u0026skin=fallback");mw.loader.implement("test.shouldembed@09p30q0",null,{"css":[]});});</script>',
],
[
'context' => [],
'modules' => [ 'test.styles.pure', 'test.styles.shouldembed' ],
'only' => ResourceLoaderModule::TYPE_STYLES,
+ 'extra' => [],
'output' =>
- '<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.styles.pure&only=styles&skin=fallback"/>' . "\n"
+ '<link rel="stylesheet" href="/w/load.php?lang=nl&modules=test.styles.pure&only=styles&skin=fallback"/>' . "\n"
. '<style>.shouldembed{}</style>'
],
[
'context' => [],
'modules' => [ 'test.ordering.a', 'test.ordering.e', 'test.ordering.b', 'test.ordering.d', 'test.ordering.c' ],
'only' => ResourceLoaderModule::TYPE_STYLES,
+ 'extra' => [],
'output' =>
- '<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.ordering.a%2Cb&only=styles&skin=fallback"/>' . "\n"
+ '<link rel="stylesheet" href="/w/load.php?lang=nl&modules=test.ordering.a%2Cb&only=styles&skin=fallback"/>' . "\n"
. '<style>.orderingC{}.orderingD{}</style>' . "\n"
- . '<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.ordering.e&only=styles&skin=fallback"/>'
+ . '<link rel="stylesheet" href="/w/load.php?lang=nl&modules=test.ordering.e&only=styles&skin=fallback"/>'
],
];
// phpcs:enable
* @covers ResourceLoader::makeLoaderQuery
* @covers ResourceLoader::makeInlineScript
*/
- public function testMakeLoad( array $extraQuery, array $modules, $type, $expected ) {
- $context = self::makeContext( $extraQuery );
+ public function testMakeLoad(
+ array $contextQuery,
+ array $modules,
+ $type,
+ array $extraQuery,
+ $expected
+ ) {
+ $context = self::makeContext( $contextQuery );
$context->getResourceLoader()->register( self::makeSampleModules() );
$actual = ResourceLoaderClientHtml::makeLoad( $context, $modules, $type, $extraQuery, false );
$expected = self::expandVariables( $expected );
}, $scripts );
$rl->register( $modules );
- $this->setMwGlobals( 'wgResourceLoaderDebug', $debug );
$context = $this->getResourceLoaderContext(
[
'modules' => implode( '|', array_keys( $modules ) ),
'only' => 'scripts',
+ 'debug' => $debug ? 'true' : 'false',
],
$rl
);