[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Skin: Don't use parser cache in getCachedNotice()
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/358225 ) Change subject: Skin: Don't use parser cache in getCachedNotice() .. Skin: Don't use parser cache in getCachedNotice() Just use wfGetCache( CACHE_ANYTHING ) which should be sufficient for most cases. Change-Id: Ic97549c9649d0cc1938773b10e26f6e8f819c7fa --- M includes/skins/Skin.php 1 file changed, 5 insertions(+), 4 deletions(-) Approvals: Tim Starling: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index ccb202e..e9d2f07 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -1485,7 +1485,7 @@ * should fall back to the next notice in its sequence */ private function getCachedNotice( $name ) { - global $wgRenderHashAppend, $parserMemc, $wgContLang; + global $wgRenderHashAppend, $wgContLang; $needParse = false; @@ -1506,9 +1506,10 @@ $notice = $msg->plain(); } + $cache = wfGetCache( CACHE_ANYTHING ); // Use the extra hash appender to let eg SSL variants separately cache. - $key = $parserMemc->makeKey( $name . $wgRenderHashAppend ); - $cachedNotice = $parserMemc->get( $key ); + $key = $cache->makeKey( $name . $wgRenderHashAppend ); + $cachedNotice = $cache->get( $key ); if ( is_array( $cachedNotice ) ) { if ( md5( $notice ) == $cachedNotice['hash'] ) { $notice = $cachedNotice['html']; @@ -1521,7 +1522,7 @@ if ( $needParse ) { $parsed = $this->getOutput()->parse( $notice ); - $parserMemc->set( $key, [ 'html' => $parsed, 'hash' => md5( $notice ) ], 600 ); + $cache->set( $key, [ 'html' => $parsed, 'hash' => md5( $notice ) ], 600 ); $notice = $parsed; } -- To view, visit https://gerrit.wikimedia.org/r/358225 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic97549c9649d0cc1938773b10e26f6e8f819c7fa Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: LegoktmGerrit-Reviewer: Jack Phoenix Gerrit-Reviewer: Tim Starling Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki/core[master]: DB: Add join conditions to selectField, selectFieldValues, a...
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/358054 ) Change subject: DB: Add join conditions to selectField, selectFieldValues, and insertSelect .. DB: Add join conditions to selectField, selectFieldValues, and insertSelect selectField() and selectFieldValues() are trivial, they just need to pass it through to select(). In fact, selectFieldValues() was already doing it, just no one ever updated IDatabase. insertSelect() is a little more work. nativeInsertSelect() was originally written as largely a copy-paste of select() and has since gotten well out of sync. Now that we have selectSQLText(), we should be able to just use that. DatabasePostgres's implementation can wrap the parent implementation instead of being another copy-paste, but DatabaseOracle seems to still need to be special. Change-Id: I0e6a9e6daa510639d3212641606047a5db96c500 --- M includes/db/DatabaseOracle.php M includes/libs/rdbms/database/DBConnRef.php M includes/libs/rdbms/database/Database.php M includes/libs/rdbms/database/DatabaseMssql.php M includes/libs/rdbms/database/DatabasePostgres.php M includes/libs/rdbms/database/IDatabase.php M tests/phpunit/includes/db/DatabaseSQLTest.php 7 files changed, 78 insertions(+), 86 deletions(-) Approvals: Tim Starling: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index b728786..556fe75 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -558,19 +558,9 @@ } function nativeInsertSelect( $destTable, $srcTable, $varMap, $conds, $fname = __METHOD__, - $insertOptions = [], $selectOptions = [] + $insertOptions = [], $selectOptions = [], $selectJoinConds = [] ) { $destTable = $this->tableName( $destTable ); - if ( !is_array( $selectOptions ) ) { - $selectOptions = [ $selectOptions ]; - } - list( $startOpts, $useIndex, $tailOpts, $ignoreIndex ) = - $this->makeSelectOptions( $selectOptions ); - if ( is_array( $srcTable ) ) { - $srcTable = implode( ',', array_map( [ $this, 'tableName' ], $srcTable ) ); - } else { - $srcTable = $this->tableName( $srcTable ); - } $sequenceData = $this->getSequenceData( $destTable ); if ( $sequenceData !== false && @@ -585,13 +575,16 @@ $val = $val . ' field' . ( $i++ ); } - $sql = "INSERT INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' . - " SELECT $startOpts " . implode( ',', $varMap ) . - " FROM $srcTable $useIndex $ignoreIndex "; - if ( $conds != '*' ) { - $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND ); - } - $sql .= " $tailOpts"; + $selectSql = $this->selectSQLText( + $srcTable, + array_values( $varMap ), + $conds, + $fname, + $selectOptions, + $selectJoinConds + ); + + $sql = "INSERT INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ') ' . $selectSql; if ( in_array( 'IGNORE', $insertOptions ) ) { $this->ignoreDupValOnIndex = true; diff --git a/includes/libs/rdbms/database/DBConnRef.php b/includes/libs/rdbms/database/DBConnRef.php index 5b59d2a..fb4122d 100644 --- a/includes/libs/rdbms/database/DBConnRef.php +++ b/includes/libs/rdbms/database/DBConnRef.php @@ -247,13 +247,13 @@ } public function selectField( - $table, $var, $cond = '', $fname = __METHOD__, $options = [] + $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = [] ) { return $this->__call( __FUNCTION__, func_get_args() ); } public function selectFieldValues( - $table, $var, $cond = '', $fname = __METHOD__, $options = [] + $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = [] ) { return $this->__call( __FUNCTION__, func_get_args() ); } @@ -411,7 +411,7 @@ public function insertSelect( $destTable, $srcTable, $varMap, $conds, - $fname = __METHOD__, $insertOptions = [], $selectOptions = [] + $fname = __METHOD__, $insertOptions = [], $selectOptions = [], $selectJoinConds = [] ) { return $this->__call( __FUNCTION__, func_get_args() ); } diff --git a/includes/libs/rdbms/database/Database.php
[MediaWiki-commits] [Gerrit] mediawiki/core[master]: ParserOptions: Fix handling of 'editsection'
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/358238 ) Change subject: ParserOptions: Fix handling of 'editsection' .. ParserOptions: Fix handling of 'editsection' The handling of the 'editsection' option prior to I7fb9ffca9 was unusual: it was included in the cache key, but the getter didn't ever flag it as "used". This was overlooked in I7fb9ffca9. This fixes the handling to restore that behavior. It's no longer considered to be a real parser option, so changing it won't make isSafeToCache() fail while reading it won't flag it as 'used'. But to keep Wikibase working (see T85252), if 'editsection' is supplied in $forOptions optionsHash() will still include it in the hash so whatever Wikibase is doing by forcing that doesn't break. The hash when it is included is the same as was used in I7fb9ffca9 to reuse keys. Once optionsHashPre30() is removed, Wikibase should be changed to use some other method to fix T85252 so we can remove that hack from optionsHash(). Change-Id: I77b5519c5a1122a1fafbfc523b77b2268c0efeb1 --- M includes/parser/ParserOptions.php M tests/phpunit/includes/parser/ParserOptionsTest.php 2 files changed, 80 insertions(+), 28 deletions(-) Approvals: Tim Starling: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index f8ed63f..5be0321 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -60,7 +60,6 @@ */ private static $inCacheKey = [ 'dateformat' => true, - 'editsection' => true, 'numberheadings' => true, 'thumbsize' => true, 'stubthreshold' => true, @@ -81,6 +80,13 @@ * @note Caching based on parse time is handled externally */ private $mTimestamp; + + /** +* The edit section flag is in ParserOptions for historical reasons, but +* doesn't actually affect the parser output since Feb 2015. +* @var bool +*/ + private $mEditSection = true; /** * Stored user object @@ -242,23 +248,6 @@ */ public function setEnableImageWhitelist( $x ) { return $this->setOptionLegacy( 'enableImageWhitelist', $x ); - } - - /** -* Create "edit section" links? -* @return bool -*/ - public function getEditSection() { - return $this->getOption( 'editsection' ); - } - - /** -* Create "edit section" links? -* @param bool|null $x New value (null is no change) -* @return bool Old value -*/ - public function setEditSection( $x ) { - return $this->setOptionLegacy( 'editsection', $x ); } /** @@ -879,6 +868,23 @@ } /** +* Create "edit section" links? +* @return bool +*/ + public function getEditSection() { + return $this->mEditSection; + } + + /** +* Create "edit section" links? +* @param bool|null $x New value (null is no change) +* @return bool Old value +*/ + public function setEditSection( $x ) { + return wfSetVar( $this->mEditSection, $x ); + } + + /** * Set the redirect target. * * Note that setting or changing this does not *make* the page a redirect @@ -1041,7 +1047,6 @@ // *UPDATE* ParserOptions::matches() if any of this changes as needed self::$defaults = [ 'dateformat' => null, - 'editsection' => true, 'tidy' => false, 'interfaceMessage' => false, 'targetLanguage' => null, @@ -1256,16 +1261,32 @@ public function optionsHash( $forOptions, $title = null ) { global $wgRenderHashAppend; + $options = $this->options; + $defaults = self::getCanonicalOverrides() + self::getDefaults(); + $inCacheKey = self::$inCacheKey; + + // Historical hack: 'editsection' hasn't been a true parser option since + // Feb 2015 (instead the parser outputs a constant placeholder and post-parse + // processing handles the option). But Wikibase forces it in $forOptions + // and expects the cache key to still vary on it for T85252. + // @todo Deprecate and remove this behavior after optionsHashPre30() is + // removed (Wikibase can use addExtraKey() or something instead). + if ( in_array( 'editsection', $forOptions, true ) ) { + $options['editsection'] = $this->mEditSection; +
[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Make Titles with an unknown namespace ID refer to Special:Ba...
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/358047 ) Change subject: Make Titles with an unknown namespace ID refer to Special:Badtitle. .. Make Titles with an unknown namespace ID refer to Special:Badtitle. Without this patch, Title::getPrefixedText() would return ":Foo" if the namespace was unknown, potentially creating a misleading link to the main namespace. With this change, getPrefixedText() will return something like "Special:Badtitle/NS12345:Foo". Note that round trip behavior is broken either way. Bug: T165149 Change-Id: I0d491a2b58ff45f207f83ee62ca6e7e6ffbf790a --- M includes/Title.php M tests/phpunit/includes/TitleTest.php 2 files changed, 68 insertions(+), 11 deletions(-) Approvals: Tim Starling: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Title.php b/includes/Title.php index a8cfad8..c9f09f7 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1419,13 +1419,22 @@ * @return string The prefixed text */ private function prefix( $name ) { + global $wgContLang; + $p = ''; if ( $this->isExternal() ) { $p = $this->mInterwiki . ':'; } if ( 0 != $this->mNamespace ) { - $p .= $this->getNsText() . ':'; + $nsText = $this->getNsText(); + + if ( $nsText === false ) { + // See T165149. Awkward, but better than erroneously linking to the main namespace. + $nsText = $wgContLang->getNsText( NS_SPECIAL ) . ":Badtitle/NS{$this->mNamespace}"; + } + + $p .= $nsText . ':'; } return $p . $name; } diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php index 238b65f..6c44999 100644 --- a/tests/phpunit/includes/TitleTest.php +++ b/tests/phpunit/includes/TitleTest.php @@ -716,28 +716,33 @@ return [ // ns = 0 [ - Title::makeTitle( NS_MAIN, 'Foobar' ), - 'Foobar' + Title::makeTitle( NS_MAIN, 'Foo bar' ), + 'Foo bar' ], // ns = 2 [ - Title::makeTitle( NS_USER, 'Foobar' ), - 'User:Foobar' + Title::makeTitle( NS_USER, 'Foo bar' ), + 'User:Foo bar' + ], + // ns = 3 + [ + Title::makeTitle( NS_USER_TALK, 'Foo bar' ), + 'User talk:Foo bar' ], // fragment not included [ - Title::makeTitle( NS_MAIN, 'Foobar', 'fragment' ), - 'Foobar' + Title::makeTitle( NS_MAIN, 'Foo bar', 'fragment' ), + 'Foo bar' ], // ns = -2 [ - Title::makeTitle( NS_MEDIA, 'Foobar' ), - 'Media:Foobar' + Title::makeTitle( NS_MEDIA, 'Foo bar' ), + 'Media:Foo bar' ], // non-existent namespace [ - Title::makeTitle( 10, 'Foobar' ), - ':Foobar' + Title::makeTitle( 100777, 'Foo bar' ), + 'Special:Badtitle/NS100777:Foo bar' ], ]; } @@ -749,4 +754,47 @@ public function testGetPrefixedText( Title $title, $expected ) { $this->assertEquals( $expected, $title->getPrefixedText() ); } + + public function provideGetPrefixedDBKey() { + return [ + // ns = 0 + [ + Title::makeTitle( NS_MAIN, 'Foo_bar' ), + 'Foo_bar' + ], + // ns = 2 + [ + Title::makeTitle( NS_USER, 'Foo_bar' ), + 'User:Foo_bar' + ], + // ns = 3 + [ + Title::makeTitle( NS_USER_TALK, 'Foo_bar' ), + 'User_talk:Foo_bar' + ], + //
[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Hide
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/358636 ) Change subject: Hide tags from Tidy .. Hide