* - If boolean and false, create object from the current users language
* - If boolean and true, create object from the wikis content language
* - If language object, use it as given
- * @param bool $isFullKey Specifies whether $key is a two part key "msg/lang".
*
* @throws MWException When given an invalid key
* @return string|bool False if the message doesn't exist, otherwise the
* message (which can be empty)
*/
- function get( $key, $useDB = true, $langcode = true, $isFullKey = false ) {
+ function get( $key, $useDB = true, $langcode = true ) {
if ( is_int( $key ) ) {
// Fix numerical strings that somehow become ints
// on their way here
return false;
}
- // For full keys, get the language code from the key
- $pos = strrpos( $key, '/' );
- if ( $isFullKey && $pos !== false ) {
- $langcode = substr( $key, $pos + 1 );
- $key = substr( $key, 0, $pos );
- }
-
// Normalise title-case input (with some inlining)
$lckey = self::normalizeKey( $key );
$conds = '';
}
- if ( $conds === '' ) {
+ if ( $conds === '' || $conds === '*' ) {
$sql = "SELECT $startOpts $fields $from $useIndex $ignoreIndex $preLimitTail";
} elseif ( is_string( $conds ) ) {
$sql = "SELECT $startOpts $fields $from $useIndex $ignoreIndex " .
* Escaping of untrusted input used in values of numeric keys should be done via
* IDatabase::addQuotes()
*
+ * Use an empty array, string, or '*' to update all rows.
+ *
* @param string|array $options
*
* Optional: Array of query options. Boolean options are specified by
$parserOptions,
$this->getRevIdFetched(),
$useParserCache,
- $rev
+ $rev,
+ // permission checking was done earlier via showDeletedRevisionHeader()
+ RevisionRecord::RAW
);
$ok = $poolArticleView->execute();
$error = $poolArticleView->getError();
/** @var RevisionRecord|null */
private $revision = null;
+ /** @var int */
+ private $audience;
+
/** @var RevisionStore */
private $revisionStore = null;
* operation.
* @param RevisionRecord|Content|string|null $revision Revision to render, or null to load it;
* may also be given as a wikitext string, or a Content object, for BC.
+ * @param int $audience One of the RevisionRecord audience constants
*/
public function __construct( WikiPage $page, ParserOptions $parserOptions,
- $revid, $useParserCache, $revision = null
+ $revid, $useParserCache, $revision = null, $audience = RevisionRecord::FOR_PUBLIC
) {
if ( is_string( $revision ) ) { // BC: very old style call
$modelId = $page->getRevision()->getContentModel();
$this->cacheable = $useParserCache;
$this->parserOptions = $parserOptions;
$this->revision = $revision;
+ $this->audience = $audience;
$this->cacheKey = $this->parserCache->getKey( $page, $parserOptions );
$keyPrefix = $this->cacheKey ?: wfMemcKey( 'articleview', 'missingcachekey' );
$isCurrent = $this->revid === $this->page->getLatest();
- // Bypass audience check for current revision
- $audience = $isCurrent ? RevisionRecord::RAW : RevisionRecord::FOR_PUBLIC;
+ // The current revision cannot be hidden so we can skip some checks.
+ $audience = $isCurrent ? RevisionRecord::RAW : $this->audience;
if ( $this->revision !== null ) {
$rev = $this->revision;
}
$this->namespaceAliases = $aliases + $convertedNames;
+
+ # Filter out aliases to namespaces that don't exist, e.g. from extensions
+ # that aren't loaded here but are included in the l10n cache.
+ # (array_intersect preserves keys from its first argument)
+ $this->namespaceAliases = array_intersect(
+ $this->namespaceAliases,
+ array_keys( $this->getNamespaces() )
+ );
}
return $this->namespaceAliases;
@import 'mw.rcfilters.variables';
.mw-rcfilters-ui-itemMenuOptionWidget {
- min-height: 3.5em;
padding: 0 0.5em;
.box-sizing( border-box );
.oo-ui-fieldLayout.oo-ui-fieldLayout-align-inline {
// Override margin-top and -bottom rules from FieldLayout
margin: 0 !important; /* stylelint-disable-line declaration-no-important */
+
+ .oo-ui-fieldLayout-body > .oo-ui-fieldLayout-field {
+ vertical-align: middle;
+ }
}
.oo-ui-checkboxInputWidget {
// Workaround for IE11 rendering issues. T162098
display: block;
- padding-top: 1em;
}
label {
$this->assertEquals( $oldText, $messageCache->get( $message ), 'Content restored' );
}
- /**
- * There's a fallback case where the message key is given as fully qualified -- this
- * should ignore the passed $lang and use the language from the key
- *
- * @dataProvider provideMessagesForFullKeys
- */
- public function testFullKeyBehaviour( $message, $lang, $expectedContent ) {
- $result = MessageCache::singleton()->get( $message, true, $lang, true );
- $this->assertEquals( $expectedContent, $result, "Full key message fallback failed." );
- }
-
- function provideMessagesForFullKeys() {
- return [
- [ 'MessageCacheTest-FullKeyTest/ru', 'ru', 'ru' ],
- [ 'MessageCacheTest-FullKeyTest/ru', 'ab', 'ru' ],
- [ 'MessageCacheTest-FullKeyTest/ru/foo', 'ru', false ],
- ];
- }
-
/**
* @dataProvider provideNormalizeKey
*/
"INSERT INTO insert_table " .
"(field_insert,field) " .
"SELECT field_select,field2 " .
- "FROM select_table WHERE *",
+ "FROM select_table",
"SELECT field_select AS field_insert,field2 AS field " .
- "FROM select_table WHERE * FOR UPDATE",
+ "FROM select_table FOR UPDATE",
"INSERT INTO insert_table (field_insert,field) VALUES ('0','1')"
],
[
__METHOD__
);
$this->assertLastSqlDb( implode( '; ', [
- 'SELECT field2 AS field FROM select_table WHERE * FOR UPDATE',
+ 'SELECT field2 AS field FROM select_table FOR UPDATE',
'BEGIN',
"INSERT INTO insert_table (field) VALUES ('" . implode( "'),('", range( 0, 9999 ) ) . "')",
"INSERT INTO insert_table (field) VALUES ('" . implode( "'),('", range( 10000, 19999 ) ) . "')",
$this->assertNotContains( 'Test B', $this->getHtml( $output ) );
}
+ public function testUnhiddenViewOfDeletedRevision() {
+ $revisions = [];
+ $page = $this->getPage( __METHOD__, [ 1 => 'Test A', 2 => 'Test B' ], $revisions );
+ $idA = $revisions[1]->getId();
+
+ $revDelList = new RevDelRevisionList(
+ RequestContext::getMain(), $page->getTitle(), [ $idA ]
+ );
+ $revDelList->setVisibility( [
+ 'value' => [ RevisionRecord::DELETED_TEXT => 1 ],
+ 'comment' => "Testing",
+ ] );
+
+ $article = new Article( $page->getTitle(), $idA );
+ $context = new DerivativeContext( $article->getContext() );
+ $article->setContext( $context );
+ $context->getOutput()->setTitle( $page->getTitle() );
+ $context->getRequest()->setVal( 'unhide', 1 );
+ $context->setUser( $this->getTestUser( [ 'sysop' ] )->getUser() );
+ $article->view();
+
+ $output = $article->getContext()->getOutput();
+ $this->assertContains( '(rev-deleted-text-view)', $this->getHtml( $output ) );
+
+ $this->assertContains( 'Test A', $this->getHtml( $output ) );
+ $this->assertNotContains( 'Test B', $this->getHtml( $output ) );
+ }
+
public function testViewMissingPage() {
$page = $this->getPage( __METHOD__ );
$work = new PoolWorkArticleView( $page, $options, $rev1->getId(), false, $fakeRev );
$this->assertFalse( $work->execute() );
+ $work = new PoolWorkArticleView( $page, $options, $rev1->getId(), false, $fakeRev,
+ RevisionRecord::RAW );
+ $this->assertNotFalse( $work->execute() );
+
// a deleted current revision should still be show
$fakeRev->setId( $rev2->getId() );
$work = new PoolWorkArticleView( $page, $options, $rev2->getId(), false, $fakeRev );