<exclude-pattern>*/includes/specials/forms/PreferencesFormLegacy\.php</exclude-pattern>
<exclude-pattern>*/includes/specials/SpecialListusers\.php</exclude-pattern>
<exclude-pattern>*/includes/specials/SpecialMyRedirectPages\.php</exclude-pattern>
- <exclude-pattern>*/includes/specials/SpecialUploadStash\.php</exclude-pattern>
<exclude-pattern>*/includes/StubObject\.php</exclude-pattern>
- <exclude-pattern>*/includes/upload/UploadFromChunks\.php</exclude-pattern>
<exclude-pattern>*/includes/upload/UploadStash\.php</exclude-pattern>
<exclude-pattern>*/includes/utils/AutoloadGenerator\.php</exclude-pattern>
<exclude-pattern>*/includes/WebResponse\.php</exclude-pattern>
Content::getNativeData() for text-based content models.
* (T210814) SVGs are now by default displayed in wiki language on image
pages.
+* (T214706) LinksUpdate::getAddedExternalLinks() and
+ LinksUpdate::getRemovedExternalLinks() were introduced.
=== External library changes in 1.33 ===
'ResourceLoaderForeignApiModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderForeignApiModule.php',
'ResourceLoaderImage' => __DIR__ . '/includes/resourceloader/ResourceLoaderImage.php',
'ResourceLoaderImageModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderImageModule.php',
- 'ResourceLoaderJqueryMsgModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderJqueryMsgModule.php',
'ResourceLoaderLanguageDataModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderLanguageDataModule.php',
- 'ResourceLoaderLanguageNamesModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderLanguageNamesModule.php',
'ResourceLoaderLessVarFileModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderLessVarFileModule.php',
- 'ResourceLoaderMediaWikiUtilModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderMediaWikiUtilModule.php',
'ResourceLoaderModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderModule.php',
'ResourceLoaderOOUIFileModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderOOUIFileModule.php',
'ResourceLoaderOOUIImageModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderOOUIImageModule.php',
'ResourceLoaderSiteModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderSiteModule.php',
'ResourceLoaderSiteStylesModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderSiteStylesModule.php',
'ResourceLoaderSkinModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderSkinModule.php',
- 'ResourceLoaderSpecialCharacterDataModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderSpecialCharacterDataModule.php',
'ResourceLoaderStartUpModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderStartUpModule.php',
- 'ResourceLoaderUploadDialogModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUploadDialogModule.php',
'ResourceLoaderUserDefaultsModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserDefaultsModule.php',
'ResourceLoaderUserModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserModule.php',
'ResourceLoaderUserOptionsModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserOptionsModule.php',
'SpecialUnlockdb' => __DIR__ . '/includes/specials/SpecialUnlockdb.php',
'SpecialUpload' => __DIR__ . '/includes/specials/SpecialUpload.php',
'SpecialUploadStash' => __DIR__ . '/includes/specials/SpecialUploadStash.php',
- 'SpecialUploadStashTooLargeException' => __DIR__ . '/includes/specials/SpecialUploadStash.php',
+ 'SpecialUploadStashTooLargeException' => __DIR__ . '/includes/specials/exception/SpecialUploadStashTooLargeException.php',
'SpecialUserLogin' => __DIR__ . '/includes/specials/SpecialUserLogin.php',
'SpecialUserLogout' => __DIR__ . '/includes/specials/SpecialUserLogout.php',
'SpecialVersion' => __DIR__ . '/includes/specials/SpecialVersion.php',
'UpdateSearchIndex' => __DIR__ . '/maintenance/updateSearchIndex.php',
'UpdateSpecialPages' => __DIR__ . '/maintenance/updateSpecialPages.php',
'UploadBase' => __DIR__ . '/includes/upload/UploadBase.php',
- 'UploadChunkFileException' => __DIR__ . '/includes/upload/UploadFromChunks.php',
- 'UploadChunkVerificationException' => __DIR__ . '/includes/upload/UploadFromChunks.php',
- 'UploadChunkZeroLengthFileException' => __DIR__ . '/includes/upload/UploadFromChunks.php',
+ 'UploadChunkFileException' => __DIR__ . '/includes/upload/exception/UploadChunkFileException.php',
+ 'UploadChunkVerificationException' => __DIR__ . '/includes/upload/exception/UploadChunkVerificationException.php',
+ 'UploadChunkZeroLengthFileException' => __DIR__ . '/includes/upload/exception/UploadChunkZeroLengthFileException.php',
'UploadForm' => __DIR__ . '/includes/specials/forms/UploadForm.php',
'UploadFromChunks' => __DIR__ . '/includes/upload/UploadFromChunks.php',
'UploadFromFile' => __DIR__ . '/includes/upload/UploadFromFile.php',
'UploadSourceAdapter' => __DIR__ . '/includes/import/UploadSourceAdapter.php',
'UploadSourceField' => __DIR__ . '/includes/specials/formfields/UploadSourceField.php',
'UploadStash' => __DIR__ . '/includes/upload/UploadStash.php',
- 'UploadStashBadPathException' => __DIR__ . '/includes/upload/UploadStash.php',
- 'UploadStashException' => __DIR__ . '/includes/upload/UploadStash.php',
+ 'UploadStashBadPathException' => __DIR__ . '/includes/upload/exception/UploadStashBadPathException.php',
+ 'UploadStashException' => __DIR__ . '/includes/upload/exception/UploadStashException.php',
'UploadStashFile' => __DIR__ . '/includes/upload/UploadStash.php',
- 'UploadStashFileException' => __DIR__ . '/includes/upload/UploadStash.php',
- 'UploadStashFileNotFoundException' => __DIR__ . '/includes/upload/UploadStash.php',
- 'UploadStashNoSuchKeyException' => __DIR__ . '/includes/upload/UploadStash.php',
- 'UploadStashNotLoggedInException' => __DIR__ . '/includes/upload/UploadStash.php',
- 'UploadStashWrongOwnerException' => __DIR__ . '/includes/upload/UploadStash.php',
- 'UploadStashZeroLengthFileException' => __DIR__ . '/includes/upload/UploadStash.php',
+ 'UploadStashFileException' => __DIR__ . '/includes/upload/exception/UploadStashFileException.php',
+ 'UploadStashFileNotFoundException' => __DIR__ . '/includes/upload/exception/UploadStashFileNotFoundException.php',
+ 'UploadStashNoSuchKeyException' => __DIR__ . '/includes/upload/exception/UploadStashNoSuchKeyException.php',
+ 'UploadStashNotLoggedInException' => __DIR__ . '/includes/upload/exception/UploadStashNotLoggedInException.php',
+ 'UploadStashWrongOwnerException' => __DIR__ . '/includes/upload/exception/UploadStashWrongOwnerException.php',
+ 'UploadStashZeroLengthFileException' => __DIR__ . '/includes/upload/exception/UploadStashZeroLengthFileException.php',
'UppercaseCollation' => __DIR__ . '/includes/collation/UppercaseCollation.php',
'User' => __DIR__ . '/includes/user/User.php',
'UserArray' => __DIR__ . '/includes/user/UserArray.php',
*/
private $linkDeletions = null;
+ /**
+ * @var null|array Added external links if calculated.
+ */
+ private $externalLinkInsertions = null;
+
+ /**
+ * @var null|array Deleted external links if calculated.
+ */
+ private $externalLinkDeletions = null;
+
/**
* @var null|array Added properties if calculated.
*/
# External links
$existingEL = $this->getExistingExternals();
+ $this->externalLinkDeletions = $this->getExternalDeletions( $existingEL );
+ $this->externalLinkInsertions = $this->getExternalInsertions(
+ $existingEL );
$this->incrTableUpdate(
'externallinks',
'el',
- $this->getExternalDeletions( $existingEL ),
- $this->getExternalInsertions( $existingEL ) );
+ $this->externalLinkDeletions,
+ $this->externalLinkInsertions );
# Language links
$existingLL = $this->getExistingInterlangs();
return $result;
}
+ /**
+ * Fetch external links added by this LinksUpdate. Only available after
+ * the update is complete.
+ * @since 1.33
+ * @return null|array Array of Strings
+ */
+ public function getAddedExternalLinks() {
+ if ( $this->externalLinkInsertions === null ) {
+ return null;
+ }
+ $result = [];
+ foreach ( $this->externalLinkInsertions as $key => $value ) {
+ $result[] = $value['el_to'];
+ }
+ return $result;
+ }
+
+ /**
+ * Fetch external links removed by this LinksUpdate. Only available after
+ * the update is complete.
+ * @since 1.33
+ * @return null|array Array of Strings
+ */
+ public function getRemovedExternalLinks() {
+ if ( $this->externalLinkDeletions === null ) {
+ return null;
+ }
+ return array_keys( $this->externalLinkDeletions );
+ }
+
/**
* Fetch page properties added by this LinksUpdate.
* Only available after the update is complete.
*/
public function create( $url, array $options = [], $caller = __METHOD__ ) {
if ( !Http::$httpEngine ) {
- Http::$httpEngine = function_exists( 'curl_init' ) ? 'curl' : 'php';
+ Http::$httpEngine = 'guzzle';
} elseif ( Http::$httpEngine == 'curl' && !function_exists( 'curl_init' ) ) {
throw new DomainException( __METHOD__ . ': curl (https://secure.php.net/curl) is not ' .
'installed, but Http::$httpEngine is set to "curl"' );
$this->setOriginalRequest( $options['originalRequest'] );
}
+ $this->setHeader( 'X-Request-Id', WebRequest::getRequestId() );
+
$members = [ "postData", "proxy", "noProxy", "sslVerifyHost", "caInfo",
"method", "followRedirects", "maxRedirects", "sslVerifyCert", "callback" ];
+++ /dev/null
-<?php
-/**
- * ResourceLoader module for mediawiki.jqueryMsg that provides generated data.
- *
- * 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
- */
-
-/**
- * ResourceLoader module for mediawiki.jqueryMsg and its generated data
- */
-class ResourceLoaderJqueryMsgModule extends ResourceLoaderFileModule {
-
- /**
- * @param ResourceLoaderContext $context
- * @return string JavaScript code
- */
- public function getScript( ResourceLoaderContext $context ) {
- $fileScript = parent::getScript( $context );
-
- $tagData = Sanitizer::getRecognizedTagData();
- $allowedHtmlElements = array_merge(
- array_keys( $tagData['htmlpairs'] ),
- array_diff(
- array_keys( $tagData['htmlsingle'] ),
- array_keys( $tagData['htmlsingleonly'] )
- )
- );
-
- $magicWords = [
- 'SITENAME' => $this->getConfig()->get( 'Sitename' ),
- ];
- Hooks::run( 'ResourceLoaderJqueryMsgModuleMagicWords', [ $context, &$magicWords ] );
-
- $parserDefaults = [
- 'allowedHtmlElements' => $allowedHtmlElements,
- 'magic' => $magicWords,
- ];
-
- $setDataScript = Xml::encodeJsCall( 'mw.jqueryMsg.setParserDefaults', [
- $parserDefaults,
- // Pass deep=true because mediawiki.jqueryMsg.js contains
- // page-specific magic words that must not be overwritten.
- true,
- ] );
-
- return $fileScript . $setDataScript;
- }
-
- /**
- * @param ResourceLoaderContext $context
- * @return array
- */
- public function getScriptURLsForDebug( ResourceLoaderContext $context ) {
- // Bypass file module urls
- return ResourceLoaderModule::getScriptURLsForDebug( $context );
- }
-
- /**
- * @return bool
- */
- public function enableModuleContentVersion() {
- return true;
- }
-}
+++ /dev/null
-<?php
-/**
- * ResourceLoader module for providing language names.
- *
- * By default these names will be autonyms however other extensions may
- * provided language names in the context language (e.g. cldr extension)
- *
- * 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
- * @author Ed Sanders
- * @author Trevor Parscal
- */
-
-/**
- * ResourceLoader module for populating language specific data.
- */
-class ResourceLoaderLanguageNamesModule extends ResourceLoaderFileModule {
-
- protected $targets = [ 'desktop', 'mobile' ];
-
- /**
- * @param ResourceLoaderContext $context
- * @return array
- */
- protected function getData( ResourceLoaderContext $context ) {
- return Language::fetchLanguageNames(
- $context->getLanguage(),
- 'all'
- );
- }
-
- /**
- * @param ResourceLoaderContext $context
- * @return string JavaScript code
- */
- public function getScript( ResourceLoaderContext $context ) {
- return Xml::encodeJsCall(
- 'mw.language.setData',
- [
- $context->getLanguage(),
- 'languageNames',
- $this->getData( $context )
- ],
- ResourceLoader::inDebugMode()
- );
- }
-
- /**
- * @param ResourceLoaderContext|null $context
- * @return array
- */
- public function getDependencies( ResourceLoaderContext $context = null ) {
- return [ 'mediawiki.language' ];
- }
-
- /**
- * @return bool
- */
- public function enableModuleContentVersion() {
- return true;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * ResourceLoader mediawiki.util module
- *
- * 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
- */
-
-/**
- * ResourceLoader module for mediawiki.util
- *
- * @since 1.30
- */
-class ResourceLoaderMediaWikiUtilModule extends ResourceLoaderFileModule {
- /**
- * @inheritDoc
- */
- public function getScript( ResourceLoaderContext $context ) {
- return ResourceLoader::makeConfigSetScript(
- [ 'wgFragmentMode' => $this->getConfig()->get( 'FragmentMode' ) ]
- )
- . "\n"
- . parent::getScript( $context );
- }
-
- /**
- * @inheritDoc
- */
- public function supportsURLLoading() {
- return false;
- }
-
- /**
- * @inheritDoc
- */
- public function enableModuleContentVersion() {
- return true;
- }
-}
+++ /dev/null
-<?php
-/**
- * ResourceLoader module for populating special characters data for some
- * editing extensions to use.
- *
- * 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
- */
-
-/**
- * ResourceLoader module for populating special characters data for some
- * editing extensions to use.
- */
-class ResourceLoaderSpecialCharacterDataModule extends ResourceLoaderModule {
- private $path = "resources/src/mediawiki.language/specialcharacters.json";
- protected $targets = [ 'desktop', 'mobile' ];
-
- /**
- * Get all the dynamic data.
- *
- * @return array
- */
- protected function getData() {
- global $IP;
- return json_decode( file_get_contents( "$IP/{$this->path}" ) );
- }
-
- /**
- * @param ResourceLoaderContext $context
- * @return string JavaScript code
- */
- public function getScript( ResourceLoaderContext $context ) {
- return Xml::encodeJsCall(
- 'mw.language.setSpecialCharacters',
- [
- $this->getData()
- ],
- ResourceLoader::inDebugMode()
- );
- }
-
- /**
- * @return bool
- */
- public function enableModuleContentVersion() {
- return true;
- }
-
- /**
- * @param ResourceLoaderContext|null $context
- * @return array
- */
- public function getDependencies( ResourceLoaderContext $context = null ) {
- return [ 'mediawiki.language' ];
- }
-
- /**
- * @return array
- */
- public function getMessages() {
- return [
- 'special-characters-group-latin',
- 'special-characters-group-latinextended',
- 'special-characters-group-ipa',
- 'special-characters-group-symbols',
- 'special-characters-group-greek',
- 'special-characters-group-greekextended',
- 'special-characters-group-cyrillic',
- 'special-characters-group-arabic',
- 'special-characters-group-arabicextended',
- 'special-characters-group-persian',
- 'special-characters-group-hebrew',
- 'special-characters-group-bangla',
- 'special-characters-group-tamil',
- 'special-characters-group-telugu',
- 'special-characters-group-sinhala',
- 'special-characters-group-devanagari',
- 'special-characters-group-gujarati',
- 'special-characters-group-thai',
- 'special-characters-group-lao',
- 'special-characters-group-khmer',
- 'special-characters-group-canadianaboriginal',
- 'special-characters-title-endash',
- 'special-characters-title-emdash',
- 'special-characters-title-minus'
- ];
- }
-}
+++ /dev/null
-<?php
-/**
- * ResourceLoader module for the upload dialog configuration data.
- *
- * 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
- */
-
-/**
- * ResourceLoader module for the upload dialog configuration data.
- *
- * @since 1.27
- */
-class ResourceLoaderUploadDialogModule extends ResourceLoaderModule {
-
- protected $targets = [ 'desktop', 'mobile' ];
-
- /**
- * @param ResourceLoaderContext $context
- * @return string JavaScript code
- */
- public function getScript( ResourceLoaderContext $context ) {
- $config = $context->getResourceLoader()->getConfig();
- return ResourceLoader::makeConfigSetScript( [
- 'wgUploadDialog' => $config->get( 'UploadDialog' ),
- ] );
- }
-
- /**
- * @return bool
- */
- public function enableModuleContentVersion() {
- return true;
- }
-}
return true;
}
}
-
-/**
- * @ingroup SpecialPage
- * @ingroup Upload
- */
-class SpecialUploadStashTooLargeException extends UploadStashException {
-}
--- /dev/null
+<?php
+/**
+ * Implements SpecialUploadStashTooLargeException
+ *
+ * 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 SpecialPage
+ * @ingroup Upload
+ */
+class SpecialUploadStashTooLargeException extends UploadStashException {
+}
<meta charset="UTF-8" />
<title>MediaWiki {{wgVersion}}</title>
<style media="screen">
- html, body {
+ body {
color: #000;
background-color: #fff;
font-family: sans-serif;
}
}
}
-
-class UploadChunkZeroLengthFileException extends MWException {
-}
-
-class UploadChunkFileException extends MWException {
-}
-
-class UploadChunkVerificationException extends MWException {
- public $msg;
- public function __construct( array $res ) {
- $this->msg = wfMessage( ...$res );
- parent::__construct( wfMessage( ...$res )
- ->inLanguage( 'en' )->useDatabase( false )->text() );
- }
-}
return $this->repo->fileExists( $this->path );
}
}
-
-/**
- * @ingroup Upload
- */
-class UploadStashException extends MWException implements ILocalizedException {
- /** @var string|array|MessageSpecifier */
- protected $messageSpec;
-
- /**
- * @param string|array|MessageSpecifier $messageSpec See Message::newFromSpecifier
- * @param int $code Exception code
- * @param Exception|Throwable|null $previous The previous exception used for the exception
- * chaining.
- */
- public function __construct( $messageSpec, $code = 0, $previous = null ) {
- $this->messageSpec = $messageSpec;
-
- $msg = $this->getMessageObject()->text();
- $msg = preg_replace( '!</?(var|kbd|samp|code)>!', '"', $msg );
- $msg = Sanitizer::stripAllTags( $msg );
- parent::__construct( $msg, $code, $previous );
- }
-
- public function getMessageObject() {
- return Message::newFromSpecifier( $this->messageSpec );
- }
-}
-
-/**
- * @ingroup Upload
- */
-class UploadStashFileNotFoundException extends UploadStashException {
-}
-
-/**
- * @ingroup Upload
- */
-class UploadStashBadPathException extends UploadStashException {
-}
-
-/**
- * @ingroup Upload
- */
-class UploadStashFileException extends UploadStashException {
-}
-
-/**
- * @ingroup Upload
- */
-class UploadStashZeroLengthFileException extends UploadStashException {
-}
-
-/**
- * @ingroup Upload
- */
-class UploadStashNotLoggedInException extends UploadStashException {
-}
-
-/**
- * @ingroup Upload
- */
-class UploadStashWrongOwnerException extends UploadStashException {
-}
-
-/**
- * @ingroup Upload
- */
-class UploadStashNoSuchKeyException extends UploadStashException {
-}
--- /dev/null
+<?php
+/**
+ * Implements UploadChunkFileException
+ *
+ * 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 Upload
+ */
+
+class UploadChunkFileException extends MWException {
+}
--- /dev/null
+<?php
+/**
+ * Implements UploadChunkVerificationException
+ *
+ * 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 Upload
+ */
+
+class UploadChunkVerificationException extends MWException {
+ public $msg;
+ public function __construct( array $res ) {
+ $this->msg = wfMessage( ...$res );
+ parent::__construct( wfMessage( ...$res )
+ ->inLanguage( 'en' )->useDatabase( false )->text() );
+ }
+}
--- /dev/null
+<?php
+/**
+ * Implements UploadChunkZeroLengthFileException
+ *
+ * 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 Upload
+ */
+
+class UploadChunkZeroLengthFileException extends MWException {
+}
--- /dev/null
+<?php
+/**
+ * Implements UploadStashBadPathException
+ *
+ * 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 Upload
+ */
+class UploadStashBadPathException extends UploadStashException {
+}
--- /dev/null
+<?php
+/**
+ * Implements UploadStashException
+ *
+ * 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 Upload
+ */
+class UploadStashException extends MWException implements ILocalizedException {
+ /** @var string|array|MessageSpecifier */
+ protected $messageSpec;
+
+ /**
+ * @param string|array|MessageSpecifier $messageSpec See Message::newFromSpecifier
+ * @param int $code Exception code
+ * @param Exception|Throwable|null $previous The previous exception used for the exception
+ * chaining.
+ */
+ public function __construct( $messageSpec, $code = 0, $previous = null ) {
+ $this->messageSpec = $messageSpec;
+
+ $msg = $this->getMessageObject()->text();
+ $msg = preg_replace( '!</?(var|kbd|samp|code)>!', '"', $msg );
+ $msg = Sanitizer::stripAllTags( $msg );
+ parent::__construct( $msg, $code, $previous );
+ }
+
+ public function getMessageObject() {
+ return Message::newFromSpecifier( $this->messageSpec );
+ }
+}
--- /dev/null
+<?php
+/**
+ * Implements UploadStashFileException
+ *
+ * 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 Upload
+ */
+class UploadStashFileException extends UploadStashException {
+}
--- /dev/null
+<?php
+/**
+ * Implements UploadStashFileNotFoundException
+ *
+ * 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 Upload
+ */
+class UploadStashFileNotFoundException extends UploadStashException {
+}
--- /dev/null
+<?php
+/**
+ * Implements UploadStashNoSuchKeyException
+ *
+ * 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 Upload
+ */
+class UploadStashNoSuchKeyException extends UploadStashException {
+}
--- /dev/null
+<?php
+/**
+ * Implements UploadStashNotLoggedInException
+ *
+ * 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 Upload
+ */
+class UploadStashNotLoggedInException extends UploadStashException {
+}
--- /dev/null
+<?php
+/**
+ * Implements UploadStashWrongOwnerException
+ *
+ * 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 Upload
+ */
+class UploadStashWrongOwnerException extends UploadStashException {
+}
--- /dev/null
+<?php
+/**
+ * Implements UploadStashZeroLengthFileException
+ *
+ * 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 Upload
+ */
+class UploadStashZeroLengthFileException extends UploadStashException {
+}
$name = self::getCanonicalName( $name, $validate );
if ( $name === false ) {
return false;
- } else {
- // Create unloaded user object
- $u = new User;
- $u->mName = $name;
- $u->mFrom = 'name';
- $u->setItemLoaded( 'name' );
- return $u;
}
+
+ // Create unloaded user object
+ $u = new User;
+ $u->mName = $name;
+ $u->mFrom = 'name';
+ $u->setItemLoaded( 'name' );
+
+ return $u;
}
/**
}
// Preg yells if you try to give it an empty string
- if ( $wgInvalidUsernameCharacters !== '' ) {
- if ( preg_match( '/[' . preg_quote( $wgInvalidUsernameCharacters, '/' ) . ']/', $name ) ) {
- wfDebugLog( 'username', __METHOD__ .
- ": '$name' invalid due to wgInvalidUsernameCharacters" );
- return false;
- }
+ if ( $wgInvalidUsernameCharacters !== '' &&
+ preg_match( '/[' . preg_quote( $wgInvalidUsernameCharacters, '/' ) . ']/', $name )
+ ) {
+ wfDebugLog( 'username', __METHOD__ .
+ ": '$name' invalid due to wgInvalidUsernameCharacters" );
+ return false;
}
return self::isUsableName( $name );
$result = $this->checkPasswordValidity( $password );
if ( $result->isGood() ) {
return true;
- } else {
- $messages = [];
- foreach ( $result->getErrorsByType( 'error' ) as $error ) {
- $messages[] = $error['message'];
- }
- foreach ( $result->getErrorsByType( 'warning' ) as $warning ) {
- $messages[] = $warning['message'];
- }
- if ( count( $messages ) === 1 ) {
- return $messages[0];
- }
- return $messages;
}
+
+ $messages = [];
+ foreach ( $result->getErrorsByType( 'error' ) as $error ) {
+ $messages[] = $error['message'];
+ }
+ foreach ( $result->getErrorsByType( 'warning' ) as $warning ) {
+ $messages[] = $warning['message'];
+ }
+ if ( count( $messages ) === 1 ) {
+ return $messages[0];
+ }
+
+ return $messages;
}
/**
if ( $result === false ) {
$status->merge( $upp->checkUserPassword( $this, $password ), true );
return $status;
- } elseif ( $result === true ) {
+ }
+
+ if ( $result === true ) {
return $status;
- } else {
- $status->error( $result );
- return $status; // the isValidPassword hook set a string $result and returned true
}
+
+ $status->error( $result );
+ return $status; // the isValidPassword hook set a string $result and returned true
}
/**
$this->mGroupMemberships = null; // deferred
$this->getEditCount(); // revalidation for nulls
return true;
- } else {
- // Invalid user_id
- $this->mId = 0;
- $this->loadDefaults();
- return false;
}
+
+ // Invalid user_id
+ $this->mId = 0;
+ $this->loadDefaults();
+
+ return false;
}
/**
if ( $blockIsValid && $useBlockCookie ) {
// Use the block.
return $tmpBlock;
- } else {
- // If the block is not valid, remove the cookie.
- Block::clearCookie( $this->getRequest()->response() );
}
+
+ // If the block is not valid, remove the cookie.
+ Block::clearCookie( $this->getRequest()->response() );
} else {
// If the block doesn't exist, remove the cookie.
Block::clearCookie( $this->getRequest()->response() );
public function isDnsBlacklisted( $ip, $checkWhitelist = false ) {
global $wgEnableDnsBlacklist, $wgDnsBlacklistUrls, $wgProxyWhitelist;
- if ( !$wgEnableDnsBlacklist ) {
- return false;
- }
-
- if ( $checkWhitelist && in_array( $ip, $wgProxyWhitelist ) ) {
+ if ( !$wgEnableDnsBlacklist ||
+ ( $checkWhitelist && in_array( $ip, $wgProxyWhitelist ) )
+ ) {
return false;
}
wfDebugLog( 'dnsblacklist', "Hostname $host is {$ipList[0]}, it's a proxy says $basename!" );
$found = true;
break;
- } else {
- wfDebugLog( 'dnsblacklist', "Requested $host, not found in $basename." );
}
+
+ wfDebugLog( 'dnsblacklist', "Requested $host, not found in $basename." );
}
}
if ( isset( $limits['anon'] ) ) {
$keys[$cache->makeKey( 'limiter', $action, 'anon' )] = $limits['anon'];
}
- } else {
+ } elseif ( isset( $limits['user'] ) ) {
// limits for logged-in users
- if ( isset( $limits['user'] ) ) {
- $userLimit = $limits['user'];
- }
+ $userLimit = $limits['user'];
}
// limits for anons and for newbie logged-in users
if ( $this->mId === null && $this->mName !== null && self::isIP( $this->mName ) ) {
// Special case, we know the user is anonymous
return 0;
- } elseif ( !$this->isItemLoaded( 'id' ) ) {
+ }
+
+ if ( !$this->isItemLoaded( 'id' ) ) {
// Don't load if this was initialized from an ID
$this->load();
}
if ( $this->isItemLoaded( 'name', 'only' ) ) {
// Special case optimisation
return $this->mName;
- } else {
- $this->load();
- if ( $this->mName === false ) {
- // Clean up IPs
- $this->mName = IP::sanitizeIP( $this->getRequest()->getIP() );
- }
- return $this->mName;
}
+
+ $this->load();
+ if ( $this->mName === false ) {
+ // Clean up IPs
+ $this->mName = IP::sanitizeIP( $this->getRequest()->getIP() );
+ }
+
+ return $this->mName;
}
/**
$talks = [];
if ( !Hooks::run( 'UserRetrieveNewTalks', [ &$user, &$talks ] ) ) {
return $talks;
- } elseif ( !$this->getNewtalk() ) {
+ }
+
+ if ( !$this->getNewtalk() ) {
return [];
}
$utp = $this->getTalkPage();
public function getNewMessageRevisionId() {
$newMessageRevisionId = null;
$newMessageLinks = $this->getNewMessageLinks();
- if ( $newMessageLinks ) {
- // Note: getNewMessageLinks() never returns more than a single link
- // and it is always for the same wiki, but we double-check here in
- // case that changes some time in the future.
- if ( count( $newMessageLinks ) === 1
- && WikiMap::isCurrentWikiId( $newMessageLinks[0]['wiki'] )
- && $newMessageLinks[0]['rev']
- ) {
- /** @var Revision $newMessageRevision */
- $newMessageRevision = $newMessageLinks[0]['rev'];
- $newMessageRevisionId = $newMessageRevision->getId();
- }
+
+ // Note: getNewMessageLinks() never returns more than a single link
+ // and it is always for the same wiki, but we double-check here in
+ // case that changes some time in the future.
+ if ( $newMessageLinks && count( $newMessageLinks ) === 1
+ && WikiMap::isCurrentWikiId( $newMessageLinks[0]['wiki'] )
+ && $newMessageLinks[0]['rev']
+ ) {
+ /** @var Revision $newMessageRevision */
+ $newMessageRevision = $newMessageLinks[0]['rev'];
+ $newMessageRevisionId = $newMessageRevision->getId();
}
+
return $newMessageRevisionId;
}
if ( $dbw->affectedRows() ) {
wfDebug( __METHOD__ . ": set on ($field, $id)\n" );
return true;
- } else {
- wfDebug( __METHOD__ . " already set ($field, $id)\n" );
- return false;
}
+
+ wfDebug( __METHOD__ . " already set ($field, $id)\n" );
+ return false;
}
/**
if ( $dbw->affectedRows() ) {
wfDebug( __METHOD__ . ": killed on ($field, $id)\n" );
return true;
- } else {
- wfDebug( __METHOD__ . ": already gone ($field, $id)\n" );
- return false;
}
+
+ wfDebug( __METHOD__ . ": already gone ($field, $id)\n" );
+ return false;
}
/**
if ( !$this->mToken ) {
// The user doesn't have a token, return null to indicate that.
return null;
- } elseif ( $this->mToken === self::INVALID_TOKEN ) {
+ }
+
+ if ( $this->mToken === self::INVALID_TOKEN ) {
// We return a random value here so existing token checks are very
// likely to fail.
return MWCryptRand::generateHex( self::TOKEN_LENGTH );
- } elseif ( $wgAuthenticationTokenVersion === null ) {
+ }
+
+ if ( $wgAuthenticationTokenVersion === null ) {
// $wgAuthenticationTokenVersion not in use, so return the raw secret
return $this->mToken;
- } else {
- // $wgAuthenticationTokenVersion in use, so hmac it.
- $ret = MWCryptHash::hmac( $wgAuthenticationTokenVersion, $this->mToken, false );
-
- // The raw hash can be overly long. Shorten it up.
- $len = max( 32, self::TOKEN_LENGTH );
- if ( strlen( $ret ) < $len ) {
- // Should never happen, even md5 is 128 bits
- throw new \UnexpectedValueException( 'Hmac returned less than 128 bits' );
- }
- return substr( $ret, -$len );
}
+
+ // $wgAuthenticationTokenVersion in use, so hmac it.
+ $ret = MWCryptHash::hmac( $wgAuthenticationTokenVersion, $this->mToken, false );
+
+ // The raw hash can be overly long. Shorten it up.
+ $len = max( 32, self::TOKEN_LENGTH );
+ if ( strlen( $ret ) < $len ) {
+ // Should never happen, even md5 is 128 bits
+ throw new \UnexpectedValueException( 'Hmac returned less than 128 bits' );
+ }
+
+ return substr( $ret, -$len );
}
/**
$type = $oldaddr != '' ? 'changed' : 'set';
$notificationResult = null;
- if ( $wgEmailAuthentication ) {
+ if ( $wgEmailAuthentication && $type === 'changed' ) {
// Send the user an email notifying the user of the change in registered
// email address on their previous email address
- if ( $type == 'changed' ) {
- $change = $str != '' ? 'changed' : 'removed';
- $notificationResult = $this->sendMail(
- wfMessage( 'notificationemail_subject_' . $change )->text(),
- wfMessage( 'notificationemail_body_' . $change,
- $this->getRequest()->getIP(),
- $this->getName(),
- $str )->text()
- );
- }
+ $change = $str != '' ? 'changed' : 'removed';
+ $notificationResult = $this->sendMail(
+ wfMessage( 'notificationemail_subject_' . $change )->text(),
+ wfMessage( 'notificationemail_body_' . $change,
+ $this->getRequest()->getIP(),
+ $this->getName(),
+ $str )->text()
+ );
}
$this->setEmail( $str );
if ( array_key_exists( $oname, $this->mOptions ) ) {
return $this->mOptions[$oname];
- } else {
- return $defaultOverride;
}
+
+ return $defaultOverride;
}
/**
global $wgSecureLogin;
if ( !$wgSecureLogin ) {
return false;
- } else {
- $https = $this->getBoolOption( 'prefershttps' );
- Hooks::run( 'UserRequiresHTTPS', [ $this, &$https ] );
- if ( $https ) {
- $https = wfCanIPUseHTTPS( $this->getRequest()->getIP() );
- }
- return $https;
}
+
+ $https = $this->getBoolOption( 'prefershttps' );
+ Hooks::run( 'UserRequiresHTTPS', [ $this, &$https ] );
+ if ( $https ) {
+ $https = wfCanIPUseHTTPS( $this->getRequest()->getIP() );
+ }
+
+ return $https;
}
/**
public function getRequest() {
if ( $this->mRequest ) {
return $this->mRequest;
- } else {
- global $wgRequest;
- return $wgRequest;
}
+
+ global $wgRequest;
+ return $wgRequest;
}
/**
$learnerRegistration = wfTimestamp( TS_MW, $now - $wgLearnerMemberSince * 86400 );
$experiencedRegistration = wfTimestamp( TS_MW, $now - $wgExperiencedUserMemberSince * 86400 );
- if (
- $editCount < $wgLearnerEdits ||
- $registration > $learnerRegistration
- ) {
+ if ( $editCount < $wgLearnerEdits ||
+ $registration > $learnerRegistration ) {
return 'newcomer';
- } elseif (
- $editCount > $wgExperiencedUserEdits &&
+ }
+
+ if ( $editCount > $wgExperiencedUserEdits &&
$registration <= $experiencedRegistration
) {
return 'experienced';
- } else {
- return 'learner';
}
+
+ return 'learner';
}
/**
return false;
}
return true;
- } else {
- return $confirmed;
}
+
+ return $confirmed;
}
/**
if ( $title ) {
return MediaWikiServices::getInstance()
->getLinkRenderer()->makeLink( $title, $text );
- } else {
- return htmlspecialchars( $text );
}
+
+ return htmlspecialchars( $text );
}
/**
if ( $title ) {
$page = $title->getFullText();
return "[[$page|$text]]";
- } else {
- return $text;
}
+
+ return $text;
}
/**
if ( $groups ) {
return Status::newFatal( 'badaccess-groups', $wgLang->commaList( $groups ), count( $groups ) );
- } else {
- return Status::newFatal( 'badaccess-group0' );
}
+
+ return Status::newFatal( 'badaccess-group0' );
}
/**
die( 'Not an entry point.' );
}
+global $wgResourceBasePath;
+
return [
/**
'upload-foreign-cant-upload',
]
],
- 'mediawiki.ForeignStructuredUpload.config' => [
- 'class' => ResourceLoaderUploadDialogModule::class,
- ],
'mediawiki.ForeignStructuredUpload' => [
- 'scripts' => 'resources/src/mediawiki.ForeignStructuredUpload.js',
+ 'localBasePath' => "$IP/resources/src",
+ 'remoteBasePath' => "$wgResourceBasePath/resources/src",
+ 'packageFiles' => [
+ 'mediawiki.ForeignStructuredUpload.js',
+ 'config.json' => [ 'config' => [ 'UploadDialog' ] ],
+ ],
'dependencies' => [
'mediawiki.ForeignUpload',
- 'mediawiki.ForeignStructuredUpload.config',
],
'messages' => [
'upload-foreign-cant-load-config',
]
],
'mediawiki.util' => [
- 'class' => ResourceLoaderMediaWikiUtilModule::class,
- 'scripts' => 'resources/src/mediawiki.util.js',
+ 'localBasePath' => "$IP/resources/src",
+ 'remoteBasePath' => "$wgResourceBasePath/resources/src",
+ 'packageFiles' => [
+ 'mediawiki.util.js',
+ 'config.json' => [ 'config' => [ 'FragmentMode' ] ],
+ ],
'dependencies' => [
'jquery.accessKeyLabel',
'mediawiki.RegExp',
],
'mediawiki.jqueryMsg' => [
- // Add data for mediawiki.jqueryMsg, such as allowed tags
- 'class' => ResourceLoaderJqueryMsgModule::class,
- 'scripts' => 'resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js',
+ 'localBasePath' => "$IP/resources/src/mediawiki.jqueryMsg",
+ 'remoteBasePath' => "$wgResourceBasePath/resources/src/mediawiki.jqueryMsg",
+ 'packageFiles' => [
+ 'mediawiki.jqueryMsg.js',
+ 'parserDefaults.json' => [ 'callback' => function ( ResourceLoaderContext $context ) {
+ $tagData = Sanitizer::getRecognizedTagData();
+ $allowedHtmlElements = array_merge(
+ array_keys( $tagData['htmlpairs'] ),
+ array_diff(
+ array_keys( $tagData['htmlsingle'] ),
+ array_keys( $tagData['htmlsingleonly'] )
+ )
+ );
+
+ $magicWords = [
+ 'SITENAME' => $context->getConfig()->get( 'Sitename' ),
+ ];
+ Hooks::run( 'ResourceLoaderJqueryMsgModuleMagicWords', [ $context, &$magicWords ] );
+
+ return [
+ 'allowedHtmlElements' => $allowedHtmlElements,
+ 'magic' => $magicWords,
+ ];
+ } ],
+ ],
'dependencies' => [
'mediawiki.util',
'mediawiki.language',
)
],
- 'mediawiki.language.names' => [ 'class' => ResourceLoaderLanguageNamesModule::class ],
+ 'mediawiki.language.names' => [
+ 'localBasePath' => "$IP/resources/src/mediawiki.language",
+ 'remoteBasePath' => "$wgResourceBasePath/resources/src/mediawiki.language",
+ 'packageFiles' => [
+ 'mediawiki.language.names.js',
+ 'names.json' => [ 'callback' => function ( ResourceLoaderContext $context ) {
+ return Language::fetchLanguageNames( $context->getLanguage(), 'all' );
+ } ],
+ ],
+ 'dependencies' => 'mediawiki.language',
+ 'targets' => [ 'desktop', 'mobile' ],
+ ],
'mediawiki.language.specialCharacters' => [
- 'class' => ResourceLoaderSpecialCharacterDataModule::class
+ 'localBasePath' => "$IP/resources/src/mediawiki.language",
+ 'remoteBasePath' => "$wgResourceBasePath/resources/src/mediawiki.language",
+ 'packageFiles' => [
+ 'mediawiki.language.specialCharacters.js',
+ 'specialcharacters.json'
+ ],
+ 'dependencies' => 'mediawiki.language',
+ 'targets' => [ 'desktop', 'mobile' ],
+ 'messages' => [
+ 'special-characters-group-latin',
+ 'special-characters-group-latinextended',
+ 'special-characters-group-ipa',
+ 'special-characters-group-symbols',
+ 'special-characters-group-greek',
+ 'special-characters-group-greekextended',
+ 'special-characters-group-cyrillic',
+ 'special-characters-group-arabic',
+ 'special-characters-group-arabicextended',
+ 'special-characters-group-persian',
+ 'special-characters-group-hebrew',
+ 'special-characters-group-bangla',
+ 'special-characters-group-tamil',
+ 'special-characters-group-telugu',
+ 'special-characters-group-sinhala',
+ 'special-characters-group-devanagari',
+ 'special-characters-group-gujarati',
+ 'special-characters-group-thai',
+ 'special-characters-group-lao',
+ 'special-characters-group-khmer',
+ 'special-characters-group-canadianaboriginal',
+ 'special-characters-title-endash',
+ 'special-characters-title-emdash',
+ 'special-characters-title-minus'
+ ]
],
/* MediaWiki Libs */
// Config for uploads to local wiki.
// Can be overridden with foreign wiki config when #loadConfig is called.
- this.config = mw.config.get( 'wgUploadDialog' );
+ this.config = require( './config.json' ).UploadDialog;
mw.ForeignUpload.call( this, target, apiconfig );
}
var oldParser,
slice = Array.prototype.slice,
parserDefaults = {
+ // Magic words and their expansions. Server-side data is added to this below.
magic: {
PAGENAME: mw.config.get( 'wgPageName' ),
PAGENAMEE: mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) )
},
// Whitelist for allowed HTML elements in wikitext.
// Self-closing tags are not currently supported.
- // Can be populated via setParserDefaults().
+ // Filled in with server-side data below
allowedHtmlElements: [],
// Key tag name, value allowed attributes for that tag.
// See Sanitizer::setupAttributeWhitelist
format: 'parse'
};
+ // Add in server-side data (allowedHtmlElements and magic words)
+ $.extend( true, parserDefaults, require( './parserDefaults.json' ) );
+
/**
* Wrapper around jQuery append that converts all non-objects to TextNode so append will not
* convert what it detects as an htmlString to an element.
--- /dev/null
+( function () {
+ var names = require( './names.json' );
+ mw.language.setData( mw.config.get( 'wgUserLanguage' ), 'languageData', names );
+}() );
--- /dev/null
+( function () {
+ var specialCharacters = require( './specialcharacters.json' );
+ mw.language.setSpecialCharacters( specialCharacters );
+ module.exports = specialCharacters;
+}() );
@colorButtonText: @colorGray2;
@colorButtonTextHighlight: @colorGray4;
@colorButtonTextActive: @colorGray1;
-@colorDisabledText: @colorGray12;
+@colorDisabledText: @colorGray7;
@colorErrorText: #d33;
@colorWarningText: #705000;
box-shadow: none;
}
- &:disabled,
- &.mw-ui-quiet.mw-ui-progressive,
- &.mw-ui-quiet.mw-ui-destructive {
+ &:disabled {
background-color: @colorGray12;
color: @colorBaseInverted;
border-color: @colorGray12;
// </div>
//
// Styleguide 2.1.1.
- &.mw-ui-quiet {
+ &.mw-ui-quiet,
+ &.mw-ui-quiet.mw-ui-progressive,
+ &.mw-ui-quiet.mw-ui-destructive {
background-color: transparent;
// Quiet buttons all start gray, and reveal
// progressive/destructive color on hover and active.
box-shadow: none;
}
- &:disabled {
+ &:disabled,
+ &:disabled:hover,
+ &:disabled:active {
background-color: transparent;
color: @colorDisabledText;
border-color: transparent;
( function () {
'use strict';
- var util;
+ var util,
+ config = require( './config.json' ),
+ origConfig = config;
/**
* Encode the string like PHP's rawurlencode
/* 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
*
* @return {string} Encoded string
*/
escapeIdForAttribute: function ( str ) {
- var mode = mw.config.get( 'wgFragmentMode' )[ 0 ];
+ var mode = config.FragmentMode[ 0 ];
return escapeIdInternal( str, mode );
},
* @return {string} Encoded string
*/
escapeIdForLink: function ( str ) {
- var mode = mw.config.get( 'wgFragmentMode' )[ 0 ];
+ var mode = config.FragmentMode[ 0 ];
return escapeIdInternal( str, mode );
},
/**
* @covers ParserOutput::addExternalLink
+ * @covers LinksUpdate::getAddedExternalLinks
+ * @covers LinksUpdate::getRemovedExternalLinks
*/
public function testUpdate_externallinks() {
/** @var ParserOutput $po */
$po->addExternalLink( "http://testing.com/wiki/Foo" );
- $this->assertLinksUpdate(
+ $update = $this->assertLinksUpdate(
$t,
$po,
'externallinks',
[ 'http://testing.com/wiki/Foo', 'http://com.testing./wiki/Foo' ],
]
);
+
+ $this->assertArrayEquals( [
+ "http://testing.com/wiki/Foo"
+ ], $update->getAddedExternalLinks() );
+
+ $po = new ParserOutput();
+ $po->setTitleText( $t->getPrefixedText() );
+ $po->addExternalLink( 'http://testing.com/wiki/Bar' );
+ $update = $this->assertLinksUpdate(
+ $t,
+ $po,
+ 'externallinks',
+ 'el_to, el_index',
+ 'el_from = ' . self::$testingPageId,
+ [
+ [ 'http://testing.com/wiki/Bar', 'http://com.testing./wiki/Bar' ],
+ ]
+ );
+
+ $this->assertArrayEquals( [
+ "http://testing.com/wiki/Bar"
+ ], $update->getAddedExternalLinks() );
+ $this->assertArrayEquals( [
+ "http://testing.com/wiki/Foo"
+ ], $update->getRemovedExternalLinks() );
}
/**
'SkinModule (FileModule subclass)' => [ true,
[ 'class' => ResourceLoaderSkinModule::class, 'scripts' => 'example.js' ]
],
- 'JqueryMsgModule (FileModule subclass)' => [ true, [
- 'class' => ResourceLoaderJqueryMsgModule::class,
- 'scripts' => 'example.js',
- ] ],
'WikiModule' => [ false, [
'class' => ResourceLoaderWikiModule::class,
'scripts' => [ 'MediaWiki:Example.js' ],
},
teardown: function () {
$.fn.updateTooltipAccessKeys.setTestMode( false );
+ mw.util.resetOptionsForTest();
},
messages: {
// Used by accessKeyLabel in test for addPortletLink
// Distant future: no legacy fallbacks
[ allNew, text, html5Encoded ]
].forEach( function ( testCase ) {
- mw.config.set( 'wgFragmentMode', testCase[ 0 ] );
+ mw.util.setOptionsForTest( { FragmentMode: testCase[ 0 ] } );
assert.strictEqual( util.escapeIdForAttribute( testCase[ 1 ] ), testCase[ 2 ] );
} );
// Distant future: no legacy fallbacks
[ allNew, text, html5Encoded ]
].forEach( function ( testCase ) {
- mw.config.set( 'wgFragmentMode', testCase[ 0 ] );
+ mw.util.setOptionsForTest( { FragmentMode: testCase[ 0 ] } );
assert.strictEqual( util.escapeIdForLink( testCase[ 1 ] ), testCase[ 2 ] );
} );
href = util.getUrl( '#Fragment', { action: 'edit' } );
assert.strictEqual( href, '/w/index.php?action=edit#Fragment', 'empty title with query string and fragment' );
- mw.config.set( 'wgFragmentMode', [ 'legacy' ] );
+ mw.util.setOptionsForTest( { FragmentMode: [ 'legacy' ] } );
href = util.getUrl( 'Foo:Sandbox \xC4#Fragment \xC4', { action: 'edit' } );
assert.strictEqual( href, '/w/index.php?title=Foo:Sandbox_%C3%84&action=edit#Fragment_.C3.84', 'title with query string, fragment, and special characters' );
- mw.config.set( 'wgFragmentMode', [ 'html5' ] );
+ mw.util.setOptionsForTest( { FragmentMode: [ 'html5' ] } );
href = util.getUrl( 'Foo:Sandbox \xC4#Fragment \xC4', { action: 'edit' } );
assert.strictEqual( href, '/w/index.php?title=Foo:Sandbox_%C3%84&action=edit#Fragment_Ä', 'title with query string, fragment, and special characters' );
href = util.getUrl( 'Foo:%23#Fragment', { action: 'edit' } );
assert.strictEqual( href, '/w/index.php?title=Foo:%2523&action=edit#Fragment', 'title containing %23 (#), fragment, and a query string' );
- mw.config.set( 'wgFragmentMode', [ 'legacy' ] );
+ mw.util.setOptionsForTest( { FragmentMode: [ 'legacy' ] } );
href = util.getUrl( '#+&=:;@$-_.!*/[]<>\'§', { action: 'edit' } );
assert.strictEqual( href, '/w/index.php?action=edit#.2B.26.3D:.3B.40.24-_..21.2A.2F.5B.5D.3C.3E.27.C2.A7', 'fragment with various characters' );
- mw.config.set( 'wgFragmentMode', [ 'html5' ] );
+ mw.util.setOptionsForTest( { FragmentMode: [ 'html5' ] } );
href = util.getUrl( '#+&=:;@$-_.!*/[]<>\'§', { action: 'edit' } );
assert.strictEqual( href, '/w/index.php?action=edit#+&=:;@$-_.!*/[]<>\'§', 'fragment with various characters' );
} );