From: jenkins-bot Date: Mon, 8 Jul 2019 23:44:40 +0000 (+0000) Subject: Merge "build: Remove redundant 'vendor/bin' prefix from composer commands" X-Git-Tag: 1.34.0-rc.0~1126 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=6428a5cb53e646ff4a15da19fb01052f92c1bc7a;hp=c7411469d25ac1e25690a6c47ac61d76c235f104;p=lhc%2Fweb%2Fwiklou.git Merge "build: Remove redundant 'vendor/bin' prefix from composer commands" --- diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index 3223948413..5e49fc7773 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -263,6 +263,8 @@ because of Phabricator reports. * ResourceLoader no longer creates the 'mw.legacy' placeholder object. It has been unused since 1.16 and was deprecated in 1.22. To deprecate a property in JavaScript, use mw.log.deprecate() instead. +* The 'user.groups' module, deprecated in 1.28, was removed. + Use the 'user' module instead. * … === Deprecations in 1.34 === diff --git a/api.php b/api.php index db9de75156..0fb674b9eb 100644 --- a/api.php +++ b/api.php @@ -61,10 +61,9 @@ $wgTitle = Title::makeTitle( NS_SPECIAL, 'Badtitle/dummy title for API calls set RequestContext::getMain()->setTitle( $wgTitle ); try { - /* Construct an ApiMain with the arguments passed via the URL. What we get back - * is some form of an ApiMain, possibly even one that produces an error message, - * but we don't care here, as that is handled by the constructor. - */ + // Construct an ApiMain with the arguments passed via the URL. What we get back + // is some form of an ApiMain, possibly even one that produces an error message, + // but we don't care here, as that is handled by the constructor. $processor = new ApiMain( RequestContext::getMain(), true ); // Last chance hook before executing the API diff --git a/autoload.php b/autoload.php index 5eadf79b80..218c244a53 100644 --- a/autoload.php +++ b/autoload.php @@ -659,6 +659,7 @@ $wgAutoloadLocalClasses = [ 'IP' => __DIR__ . '/includes/libs/IP.php', 'IPTC' => __DIR__ . '/includes/media/IPTC.php', 'IRCColourfulRCFeedFormatter' => __DIR__ . '/includes/rcfeed/IRCColourfulRCFeedFormatter.php', + 'IStoreKeyEncoder' => __DIR__ . '/includes/libs/objectcache/IStoreKeyEncoder.php', 'IcuCollation' => __DIR__ . '/includes/collation/IcuCollation.php', 'IdentityCollation' => __DIR__ . '/includes/collation/IdentityCollation.php', 'ImageBuilder' => __DIR__ . '/maintenance/rebuildImages.php', diff --git a/includes/actions/DeleteAction.php b/includes/actions/DeleteAction.php index 6bed59a2f3..6fcb1c863c 100644 --- a/includes/actions/DeleteAction.php +++ b/includes/actions/DeleteAction.php @@ -1,9 +1,5 @@ getLockPath( $path ), 'a+' ); - if ( !$handle ) { // lock dir missing? - mkdir( $this->lockDir, 0777, true ); - $handle = fopen( $this->getLockPath( $path ), 'a+' ); // try again + if ( !$handle && !is_dir( $this->lockDir ) ) { + // Create the lock directory in case it is missing + if ( mkdir( $this->lockDir, 0777, true ) ) { + $handle = fopen( $this->getLockPath( $path ), 'a+' ); // try again + } else { + $this->logger->error( "Cannot create directory '{$this->lockDir}'." ); + } } Wikimedia\restoreWarnings(); } diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php index 7759947ee0..00bf57d66d 100644 --- a/includes/libs/objectcache/BagOStuff.php +++ b/includes/libs/objectcache/BagOStuff.php @@ -61,7 +61,7 @@ use Wikimedia\WaitConditionLoop; * * @ingroup Cache */ -abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { +abstract class BagOStuff implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInterface { /** @var array[] Lock tracking */ protected $locks = []; /** @var int ERR_* class constant */ @@ -655,11 +655,12 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { * @param string $date The reference date in MW format * @param callable|bool $progressCallback Optional, a function which will be called * regularly during long-running operations with the percentage progress - * as the first parameter. + * as the first parameter. [optional] + * @param int $limit Maximum number of keys to delete [default: INF] * * @return bool Success, false if unimplemented */ - public function deleteObjectsExpiringBefore( $date, $progressCallback = false ) { + public function deleteObjectsExpiringBefore( $date, $progressCallback = false, $limit = INF ) { // stub return false; } diff --git a/includes/libs/objectcache/CachedBagOStuff.php b/includes/libs/objectcache/CachedBagOStuff.php index 8892f73899..0bdd34914c 100644 --- a/includes/libs/objectcache/CachedBagOStuff.php +++ b/includes/libs/objectcache/CachedBagOStuff.php @@ -82,9 +82,9 @@ class CachedBagOStuff extends HashBagOStuff { $this->backend->setDebug( $bool ); } - public function deleteObjectsExpiringBefore( $date, $progressCallback = false ) { - parent::deleteObjectsExpiringBefore( $date, $progressCallback ); - return $this->backend->deleteObjectsExpiringBefore( $date, $progressCallback ); + public function deleteObjectsExpiringBefore( $date, $progressCallback = false, $limit = INF ) { + parent::deleteObjectsExpiringBefore( $date, $progressCallback, $limit ); + return $this->backend->deleteObjectsExpiringBefore( $date, $progressCallback, $limit ); } public function makeKeyInternal( $keyspace, $args ) { diff --git a/includes/libs/objectcache/IExpiringStore.php b/includes/libs/objectcache/IExpiringStore.php index 61a4c618cf..1566c07925 100644 --- a/includes/libs/objectcache/IExpiringStore.php +++ b/includes/libs/objectcache/IExpiringStore.php @@ -17,7 +17,6 @@ * * @file * @ingroup Cache - * @author 2015 Timo Tijhof */ /** diff --git a/includes/libs/objectcache/IStoreKeyEncoder.php b/includes/libs/objectcache/IStoreKeyEncoder.php new file mode 100644 index 0000000000..da0686ea0c --- /dev/null +++ b/includes/libs/objectcache/IStoreKeyEncoder.php @@ -0,0 +1,27 @@ +caches[0]->unlock( $key ); } - /** - * Delete objects expiring before a certain date. - * - * Succeed if any of the child caches succeed. - * @param string $date - * @param bool|callable $progressCallback - * @return bool - */ - public function deleteObjectsExpiringBefore( $date, $progressCallback = false ) { + public function deleteObjectsExpiringBefore( $date, $progressCallback = false, $limit = INF ) { $ret = false; foreach ( $this->caches as $cache ) { - if ( $cache->deleteObjectsExpiringBefore( $date, $progressCallback ) ) { + if ( $cache->deleteObjectsExpiringBefore( $date, $progressCallback, $limit ) ) { $ret = true; } } diff --git a/includes/libs/objectcache/ReplicatedBagOStuff.php b/includes/libs/objectcache/ReplicatedBagOStuff.php index f79c1ff65f..6fac0ade3b 100644 --- a/includes/libs/objectcache/ReplicatedBagOStuff.php +++ b/includes/libs/objectcache/ReplicatedBagOStuff.php @@ -108,7 +108,7 @@ class ReplicatedBagOStuff extends BagOStuff { return $this->writeStore->unlock( $key ); } - public function deleteObjectsExpiringBefore( $date, $progressCallback = false ) { + public function deleteObjectsExpiringBefore( $date, $progressCallback = false, $limit = INF ) { return $this->writeStore->deleteObjectsExpiringBefore( $date, $progressCallback ); } diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index 1d8662a3c8..2487920ca6 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -113,7 +113,7 @@ use Psr\Log\NullLogger; * @ingroup Cache * @since 1.26 */ -class WANObjectCache implements IExpiringStore, LoggerAwareInterface { +class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInterface { /** @var BagOStuff The local datacenter cache */ protected $cache; /** @var MapCacheLRU[] Map of group PHP instance caches */ diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php index 39d0353d45..2ef94c4297 100644 --- a/includes/objectcache/SqlBagOStuff.php +++ b/includes/objectcache/SqlBagOStuff.php @@ -46,7 +46,9 @@ class SqlBagOStuff extends BagOStuff { /** @var int */ protected $lastExpireAll = 0; /** @var int */ - protected $purgePeriod = 100; + protected $purgePeriod = 10; + /** @var int */ + protected $purgeLimit = 100; /** @var int */ protected $shards = 1; /** @var string */ @@ -77,12 +79,13 @@ class SqlBagOStuff extends BagOStuff { * when a cluster is replicated to another site (with different host names) * but each server has a corresponding replica in the other cluster. * - * - purgePeriod: The average number of object cache requests in between + * - purgePeriod: The average number of object cache writes in between * garbage collection operations, where expired entries * are removed from the database. Or in other words, the * reciprocal of the probability of purging on any given - * request. If this is set to zero, purging will never be - * done. + * write. If this is set to zero, purging will never be done. + * + * - purgeLimit: Maximum number of rows to purge at once. * * - tableName: The table name to use, default is "objectcache". * @@ -135,6 +138,9 @@ class SqlBagOStuff extends BagOStuff { if ( isset( $params['purgePeriod'] ) ) { $this->purgePeriod = intval( $params['purgePeriod'] ); } + if ( isset( $params['purgeLimit'] ) ) { + $this->purgeLimit = intval( $params['purgeLimit'] ); + } if ( isset( $params['tableName'] ) ) { $this->tableName = $params['tableName']; } @@ -270,8 +276,6 @@ class SqlBagOStuff extends BagOStuff { $keysByTable[$serverIndex][$tableName][] = $key; } - $this->garbageCollect(); // expire old entries if any - $dataRows = []; foreach ( $keysByTable as $serverIndex => $serverKeys ) { try { @@ -617,7 +621,7 @@ class SqlBagOStuff extends BagOStuff { // Disabled return; } - // Only purge on one in every $this->purgePeriod requests. + // Only purge on one in every $this->purgePeriod writes if ( $this->purgePeriod !== 1 && mt_rand( 0, $this->purgePeriod - 1 ) ) { return; } @@ -625,7 +629,11 @@ class SqlBagOStuff extends BagOStuff { // Avoid repeating the delete within a few seconds if ( $now > ( $this->lastExpireAll + 1 ) ) { $this->lastExpireAll = $now; - $this->expireAll(); + $this->deleteObjectsExpiringBefore( + wfTimestamp( TS_MW, $now ), + false, + $this->purgeLimit + ); } } @@ -633,15 +641,15 @@ class SqlBagOStuff extends BagOStuff { $this->deleteObjectsExpiringBefore( wfTimestampNow() ); } - /** - * Delete objects from the database which expire before a certain date. - * @param string $timestamp - * @param bool|callable $progressCallback - * @return bool - */ - public function deleteObjectsExpiringBefore( $timestamp, $progressCallback = false ) { + public function deleteObjectsExpiringBefore( + $timestamp, + $progressCallback = false, + $limit = INF + ) { /** @noinspection PhpUnusedLocalVariableInspection */ $silenceScope = $this->silenceTransactionProfiler(); + + $count = 0; for ( $serverIndex = 0; $serverIndex < $this->numServers; $serverIndex++ ) { $db = null; try { @@ -661,7 +669,8 @@ class SqlBagOStuff extends BagOStuff { [ 'keyname', 'exptime' ], $conds, __METHOD__, - [ 'LIMIT' => 100, 'ORDER BY' => 'exptime' ] ); + [ 'LIMIT' => 100, 'ORDER BY' => 'exptime' ] + ); if ( $rows === false || !$rows->numRows() ) { break; } @@ -684,9 +693,14 @@ class SqlBagOStuff extends BagOStuff { 'exptime < ' . $db->addQuotes( $dbTimestamp ), 'keyname' => $keys ], - __METHOD__ ); + __METHOD__ + ); + $count += $db->affectedRows(); + if ( $count >= $limit ) { + return true; + } - if ( $progressCallback ) { + if ( is_callable( $progressCallback ) ) { if ( intval( $totalSeconds ) === 0 ) { $percent = 0; } else { @@ -710,6 +724,7 @@ class SqlBagOStuff extends BagOStuff { return false; } } + return true; } diff --git a/includes/resourceloader/MessageBlobStore.php b/includes/resourceloader/MessageBlobStore.php index 74d0616d1d..457648a0d6 100644 --- a/includes/resourceloader/MessageBlobStore.php +++ b/includes/resourceloader/MessageBlobStore.php @@ -1,7 +1,5 @@ https://virtualtee.blogspot.com/ - * Copyright (C) 2015 Timo Tijhof * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the "Software"), diff --git a/maintenance/purgeModuleDeps.php b/maintenance/purgeModuleDeps.php index 3b25629318..683c319049 100644 --- a/maintenance/purgeModuleDeps.php +++ b/maintenance/purgeModuleDeps.php @@ -1,7 +1,5 @@ 'http://a9.com/-/spec/opensearch/1.1/', 'xmlns:moz' => 'http://www.mozilla.org/2006/browser/search/' ] ); -/* The spec says the ShortName must be no longer than 16 characters, - * but 16 is *realllly* short. In practice, browsers don't appear to care - * when we give them a longer string, so we're no longer attempting to trim. - * - * Note: ShortName and the need to match; they are used as - * a key for identifying if the search engine has been added already, *and* - * as the display name presented to the end-user. - * - * Behavior seems about the same between Firefox and IE 7/8 here. - * 'Description' doesn't appear to be used by either. - */ +// The spec says the ShortName must be no longer than 16 characters, +// but 16 is *realllly* short. In practice, browsers don't appear to care +// when we give them a longer string, so we're no longer attempting to trim. +// +// Note: ShortName and the need to match; they are used as +// a key for identifying if the search engine has been added already, *and* +// as the display name presented to the end-user. +// +// Behavior seems about the same between Firefox and IE 7/8 here. +// 'Description' doesn't appear to be used by either. $fullName = wfMessage( 'opensearch-desc' )->inContentLanguage()->text(); print Xml::element( 'ShortName', null, $fullName ); print Xml::element( 'Description', null, $fullName ); diff --git a/resources/Resources.php b/resources/Resources.php index c24e3eb29c..6298086a21 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -39,11 +39,6 @@ return [ 'class' => ResourceLoaderWikiModule::class, 'styles' => [ 'MediaWiki:Filepage.css' ], ], - 'user.groups' => [ - // Merged into 'user' since MediaWiki 1.28 - kept for back-compat - 'dependencies' => 'user', - 'targets' => [ 'desktop', 'mobile' ], - ], // Scripts managed by the current user (stored in their user space) 'user' => [ 'class' => ResourceLoaderUserModule::class ], diff --git a/resources/src/mediawiki.util.js b/resources/src/mediawiki.util.js index 66c1fe74d1..36a0195d84 100644 --- a/resources/src/mediawiki.util.js +++ b/resources/src/mediawiki.util.js @@ -2,8 +2,7 @@ 'use strict'; var util, - config = require( './config.json' ), - origConfig = config; + config = require( './config.json' ); /** * Encode the string like PHP's rawurlencode @@ -50,22 +49,6 @@ */ util = { - /* Main body */ - - setOptionsForTest: function ( opts ) { - if ( !window.QUnit ) { - throw new Error( 'Modifying options not allowed outside unit tests' ); - } - config = $.extend( {}, config, opts ); - }, - - resetOptionsForTest: function () { - if ( !window.QUnit ) { - throw new Error( 'Resetting options not allowed outside unit tests' ); - } - config = origConfig; - }, - /** * Encode the string like PHP's rawurlencode * @@ -533,6 +516,15 @@ } }; + // Not allowed outside unit tests + if ( window.QUnit ) { + util.setOptionsForTest = function ( opts ) { + var oldConfig = config; + config = $.extend( {}, config, opts ); + return oldConfig; + }; + } + /** * Initialisation of mw.util.$content */ diff --git a/resources/src/startup/profiler.js b/resources/src/startup/profiler.js index 5e9b6ab2a6..0f044f8834 100644 --- a/resources/src/startup/profiler.js +++ b/resources/src/startup/profiler.js @@ -1,7 +1,6 @@ /*! * Augment mw.loader to facilitate module-level profiling. * - * @author Timo Tijhof * @since 1.32 */ /* global mw */ diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js index 3679ed76f9..17672db80e 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js @@ -77,10 +77,14 @@ QUnit.module( 'mediawiki.util', QUnit.newMwEnvironment( { setup: function () { $.fn.updateTooltipAccessKeys.setTestMode( true ); + this.origConfig = mw.util.setOptionsForTest( { + FragmentMode: [ 'legacy', 'html5' ], + LoadScript: '/w/load.php' + } ); }, teardown: function () { $.fn.updateTooltipAccessKeys.setTestMode( false ); - mw.util.resetOptionsForTest(); + mw.util.setOptionsForTest( this.origConfig ); }, messages: { // Used by accessKeyLabel in test for addPortletLink