was deprecated in 1.25.
* The jquery.byteLength module, deprecated in 1.31, was removed.
Use the mediawiki.String module instead.
+* mw.language.specialCharacters, deprecated in 1.33, has been removed.
+ Use require( 'mediawiki.language.specialCharacters' ) instead.
+* EditPage::submit(), deprecated in 1.29, has been removed. Used $this->edit()
+ directly.
* …
=== Deprecations in 1.34 ===
MovePage::moveSubpagesIfAllowed.
* The MWNamespace class is deprecated. Use MediaWikiServices::getNamespaceInfo.
* (T62260) Hard deprecate Language::getExtraUserToggles() method.
-* …
=== Other changes in 1.34 ===
* …
$this->enableApiEditOverride = $enableOverride;
}
- /**
- * @deprecated since 1.29, call edit directly
- */
- public function submit() {
- wfDeprecated( __METHOD__, '1.29' );
- $this->edit();
- }
-
/**
* This is the function that gets called for "action=edit". It
* sets up various member variables, then passes execution to
$this->newTitle = $newTitle;
}
+ /**
+ * Check if the user is allowed to perform the move.
+ *
+ * @param User $user
+ * @param string|null $reason To check against summary spam regex. Set to null to skip the check,
+ * for instance to display errors preemptively before the user has filled in a summary.
+ * @return Status
+ */
public function checkPermissions( User $user, $reason ) {
$status = new Status();
}
}
- if ( EditPage::matchSummarySpamRegex( $reason ) !== false ) {
+ if ( $reason !== null && EditPage::matchSummarySpamRegex( $reason ) !== false ) {
// This is kind of lame, won't display nice
$status->fatal( 'spamprotectiontext' );
}
* @return array|bool True on success, getUserPermissionsErrors()-like array on failure
*/
public function isValidMoveOperation( &$nt, $auth = true, $reason = '' ) {
+ wfDeprecated( __METHOD__, '1.25' );
+
global $wgUser;
if ( !( $nt instanceof Title ) ) {
public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true,
array $changeTags = []
) {
+ wfDeprecated( __METHOD__, '1.25' );
+
global $wgUser;
$mp = new MovePage( $this, $nt );
public function moveSubpages( $nt, $auth = true, $reason = '', $createRedirect = true,
array $changeTags = []
) {
- // Check permissions
- if ( !$this->userCan( 'move-subpages' ) ) {
- return [
- [ 'cant-move-subpages' ],
- ];
- }
- // Do the source and target namespaces support subpages?
- $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
- if ( !$nsInfo->hasSubpages( $this->mNamespace ) ) {
- return [
- [ 'namespace-nosubpages', $nsInfo->getCanonicalName( $this->mNamespace ) ],
- ];
- }
- if ( !$nsInfo->hasSubpages( $nt->getNamespace() ) ) {
- return [
- [ 'namespace-nosubpages', $nsInfo->getCanonicalName( $nt->getNamespace() ) ],
- ];
- }
+ wfDeprecated( __METHOD__, '1.34' );
global $wgUser;
+
$mp = new MovePage( $this, $nt );
$method = $auth ? 'moveSubpagesIfAllowed' : 'moveSubpages';
$result = $mp->$method( $wgUser, $reason, $createRedirect, $changeTags );
* @return bool
*/
public function isValidMoveTarget( $nt ) {
+ wfDeprecated( __METHOD__, '1.25' );
+
# Is it an existing file?
if ( $nt->getNamespace() == NS_FILE ) {
$file = wfLocalFile( $nt );
/**
* Same as addPageSubItems(), but one element of $data at a time
* @param int $pageId Page ID
- * @param array $item Data array à la ApiResult
+ * @param mixed $item Data à la ApiResult
* @param string|null $elemname XML element name. If null, getModuleName()
* is used
* @return bool Whether the element fit in the result
/**
* Try to load the cache from APC.
*
- * @param string $code Optional language code, see documenation of load().
+ * @param string $code Optional language code, see documentation of load().
* @return array|bool The cache array, or false if not in cache.
*/
protected function getLocalCache( $code ) {
} elseif ( $hashVolatile ) {
# DB results are replica DB lag prone until the holdoff TTL passes.
# By then, updates should be reflected in loadFromDBWithLock().
- # One thread renerates the cache while others use old values.
+ # One thread regenerates the cache while others use old values.
$where[] = 'global cache is expired/volatile';
$staleCache = $cache;
} else {
break;
} elseif ( $loadStatus === 'cantacquire' ) {
# Wait for the other thread to finish, then retry. Normally,
- # the memcached get() will then yeild the other thread's result.
+ # the memcached get() will then yield the other thread's result.
$where[] = 'waited for other thread to complete';
$this->getReentrantScopedLock( $cacheKey );
} else {
/**
* Render files as PNG
*
- * @param string $text
+ * @param string $ext
* @param string $mime
* @param array|null $params
* @return array
*/
- public function getThumbType( $text, $mime, $params = null ) {
+ public function getThumbType( $ext, $mime, $params = null ) {
return [ 'png', 'image/png' ];
}
}
/**
- * Splits a newline separated list of user ids into a
+ * Splits a newline separated list of user ids into an array.
*
* @param string $str
* @return int[]
$deleteAndMove = false;
$moveOverShared = false;
+ $user = $this->getUser();
+
$newTitle = $this->newTitle;
if ( !$newTitle ) {
# If a title was supplied, probably from the move log revert
# link, check for validity. We can then show some diagnostic
# information and save a click.
- $newerr = $this->oldTitle->isValidMoveOperation( $newTitle );
- if ( is_array( $newerr ) ) {
- $err = $newerr;
+ $mp = new MovePage( $this->oldTitle, $newTitle );
+ $status = $mp->isValidMove();
+ $status->merge( $mp->checkPermissions( $user, null ) );
+ if ( $status->getErrors() ) {
+ $err = $status->getErrorsArray();
}
}
- $user = $this->getUser();
-
if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists'
&& $newTitle->quickUserCan( 'delete', $user )
) {
continue;
}
+ $mp = new MovePage( $oldSubpage, $newSubpage );
# This was copy-pasted from Renameuser, bleh.
- if ( $newSubpage->exists() && !$oldSubpage->isValidMoveTarget( $newSubpage ) ) {
+ if ( $newSubpage->exists() && !$mp->isValidMove()->isOk() ) {
$link = $linkRenderer->makeKnownLink( $newSubpage );
$extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
} else {
- $success = $oldSubpage->moveTo( $newSubpage, true, $this->reason, $createRedirect );
+ $status = $mp->moveIfAllowed( $user, $this->reason, $createRedirect );
- if ( $success === true ) {
+ if ( $status->isOK() ) {
if ( $this->fixRedirects ) {
DoubleRedirectJob::fixRedirects( 'move', $oldSubpage, $newSubpage );
}
var $a;
// Recheck preference so extensions can do a hack to disable this code.
if ( parseInt( mw.user.options.get( 'editondblclick' ), 10 ) ) {
- e.preventDefault();
// Trigger native HTMLElement click instead of opening URL (T45052)
$a = $( '#ca-edit a' );
// Not every page has an edit link (T59713)
if ( $a.length ) {
+ e.preventDefault();
// eslint-disable-next-line no-jquery/no-event-shorthand
$a.get( 0 ).click();
}
-( function () {
- var specialCharacters = require( './specialcharacters.json' );
- // Deprecated since 1.33
- mw.log.deprecate( mw.language, 'specialCharacters', specialCharacters,
- 'Use require( \'mediawiki.language.specialCharacters\' ) instead',
- 'mw.language.specialCharacters'
- );
- module.exports = specialCharacters;
-}() );
+module.exports = require( './specialcharacters.json' );
];
}
- /**
- * Integration test to catch regressions like T74870. Taken and modified
- * from SemanticMediaWiki
- *
- * @covers Title::moveTo
- */
- public function testTitleMoveCompleteIntegrationTest() {
- $oldTitle = Title::newFromText( 'Help:Some title' );
- WikiPage::factory( $oldTitle )->doEditContent( new WikitextContent( 'foo' ), 'bar' );
- $newTitle = Title::newFromText( 'Help:Some other title' );
- $this->assertNull(
- WikiPage::factory( $newTitle )->getRevision()
- );
-
- $this->assertTrue( $oldTitle->moveTo( $newTitle, false, 'test1', true ) );
- $this->assertNotNull(
- WikiPage::factory( $oldTitle )->getRevision()
- );
- $this->assertNotNull(
- WikiPage::factory( $newTitle )->getRevision()
- );
- }
-
/**
* Test for the move operation being aborted via the TitleMove hook
* @covers MovePage::move
$this->assertSame( $expected, $title->getLinkURL( $query, $query2, $proto ) );
}
+ /**
+ * Integration test to catch regressions like T74870. Taken and modified
+ * from SemanticMediaWiki
+ *
+ * @covers Title::moveTo
+ */
+ public function testTitleMoveCompleteIntegrationTest() {
+ $this->hideDeprecated( 'Title::moveTo' );
+
+ $oldTitle = Title::newFromText( 'Help:Some title' );
+ WikiPage::factory( $oldTitle )->doEditContent( new WikitextContent( 'foo' ), 'bar' );
+ $newTitle = Title::newFromText( 'Help:Some other title' );
+ $this->assertNull(
+ WikiPage::factory( $newTitle )->getRevision()
+ );
+
+ $this->assertTrue( $oldTitle->moveTo( $newTitle, false, 'test1', true ) );
+ $this->assertNotNull(
+ WikiPage::factory( $oldTitle )->getRevision()
+ );
+ $this->assertNotNull(
+ WikiPage::factory( $newTitle )->getRevision()
+ );
+ }
+
function tearDown() {
Title::clearCaches();
parent::tearDown();
* @covers Title::isValidMoveOperation
*/
public function testIsValidMoveOperation( $source, $target, $expected ) {
+ $this->hideDeprecated( 'Title::isValidMoveOperation' );
+
$this->setMwGlobals( 'wgContentHandlerUseDB', false );
$title = Title::newFromText( $source );
$nt = Title::newFromText( $target );