X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderModule.php;h=8124f3398b22797ff1ccf120f1c2eeccf1635eee;hb=ba39208f91e5caafab28d97999fdddf0dae00410;hp=43cf78bd598822f53156b6572b44f76853b03721;hpb=253d5a07ca762cd6e9030af1d297ecfbaacdb004;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index 43cf78bd59..8124f3398b 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -22,9 +22,11 @@ * @author Roan Kattouw */ +use MediaWiki\MediaWikiServices; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; +use Wikimedia\ScopedCallback; /** * Abstraction for ResourceLoader modules, with name registration and maxage functionality. @@ -186,7 +188,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { public function getConfig() { if ( $this->config === null ) { // Ugh, fall back to default - $this->config = ConfigFactory::getDefaultInstance()->makeConfig( 'main' ); + $this->config = MediaWikiServices::getInstance()->getMainConfig(); } return $this->config; @@ -329,14 +331,13 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { } /** - * Where on the HTML page should this module's JS be loaded? - * - 'top': in the "" - * - 'bottom': at the bottom of the "" + * From where in the page HTML should this module be loaded? * + * @deprecated since 1.29 Obsolete. All modules load async from ``. * @return string */ public function getPosition() { - return 'bottom'; + return 'top'; } /** @@ -486,9 +487,14 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { ] ); - $dbw->onTransactionResolution( function () use ( &$scopeLock ) { - ScopedCallback::consume( $scopeLock ); // release after commit - } ); + if ( $dbw->trxLevel() ) { + $dbw->onTransactionResolution( + function () use ( &$scopeLock ) { + ScopedCallback::consume( $scopeLock ); // release after commit + }, + __METHOD__ + ); + } } } catch ( Exception $e ) { wfDebugLog( 'resourceloader', __METHOD__ . ": failed to update DB: $e" ); @@ -787,10 +793,10 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { * * @code * $summary = parent::getDefinitionSummary( $context ); - * $summary[] = array( + * $summary[] = [ * 'foo' => 123, * 'bar' => 'quux', - * ); + * ]; * return $summary; * @endcode *