51 $this->oldTitle->getUserPermissionsErrors(
'move', $user ),
52 $this->oldTitle->getUserPermissionsErrors(
'edit', $user ),
53 $this->newTitle->getUserPermissionsErrors(
'move-target', $user ),
54 $this->newTitle->getUserPermissionsErrors(
'edit', $user )
59 foreach ( $errors
as $error ) {
60 call_user_func_array( [
$status,
'fatal' ], $error );
66 $status->fatal(
'spamprotectiontext' );
69 $tp = $this->newTitle->getTitleProtection();
70 if ( $tp !==
false && !$user->
isAllowed( $tp[
'permission'] ) ) {
71 $status->fatal(
'cantmove-titleprotected' );
75 [ $this->oldTitle, $this->newTitle, $user, $reason,
$status ]
89 global $wgContentHandlerUseDB;
92 if ( $this->oldTitle->equals( $this->newTitle ) ) {
95 if ( !$this->oldTitle->isMovable() ) {
96 $status->fatal(
'immobile-source-namespace', $this->oldTitle->getNsText() );
98 if ( $this->newTitle->isExternal() ) {
99 $status->fatal(
'immobile-target-namespace-iw' );
101 if ( !$this->newTitle->isMovable() ) {
102 $status->fatal(
'immobile-target-namespace', $this->newTitle->getNsText() );
105 $oldid = $this->oldTitle->getArticleID();
107 if ( strlen( $this->newTitle->getDBkey() ) < 1 ) {
108 $status->fatal(
'articleexists' );
111 ( $this->oldTitle->getDBkey() ==
'' ) ||
113 ( $this->newTitle->getDBkey() ==
'' )
115 $status->fatal(
'badarticleerror' );
118 # The move is allowed only if (1) the target doesn't exist, or
119 # (2) the target is a redirect to the source, and has no history
120 # (so we can undo bad moves right after they're done).
122 $status->fatal(
'articleexists' );
126 if ( !$wgContentHandlerUseDB &&
127 $this->oldTitle->getContentModel() !== $this->newTitle->getContentModel() ) {
138 'content-not-allowed-here',
140 $this->newTitle->getPrefixedText()
145 if ( $this->oldTitle->inNamespace(
NS_FILE ) ) {
149 if ( $this->newTitle->inNamespace(
NS_FILE ) && !$this->oldTitle->inNamespace(
NS_FILE ) ) {
150 $status->fatal(
'nonfile-cannot-move-to-file' );
154 Hooks::run(
'MovePageIsValidMove', [ $this->oldTitle, $this->newTitle,
$status ] );
167 $file->load( File::READ_LATEST );
168 if ( $file->exists() ) {
170 $status->fatal(
'imageinvalidfilename' );
173 $status->fatal(
'imagetypemismatch' );
177 if ( !$this->newTitle->inNamespace(
NS_FILE ) ) {
178 $status->fatal(
'imagenocrossnamespace' );
192 # Is it an existing file?
193 if ( $this->newTitle->inNamespace(
NS_FILE ) ) {
195 $file->load( File::READ_LATEST );
196 if ( $file->exists() ) {
197 wfDebug( __METHOD__ .
": file exists\n" );
201 # Is it a redirect with no history?
202 if ( !$this->newTitle->isSingleRevRedirect() ) {
203 wfDebug( __METHOD__ .
": not a one-rev redirect\n" );
206 # Get the article text
208 if ( !is_object(
$rev ) ) {
212 # Does the redirect point to the source?
213 # Or is it a broken self-redirect, usually caused by namespace collisions?
217 if ( $redirTitle->getPrefixedDBkey() !== $this->oldTitle->getPrefixedDBkey() &&
218 $redirTitle->getPrefixedDBkey() !== $this->newTitle->getPrefixedDBkey() ) {
219 wfDebug( __METHOD__ .
": redirect points to other page\n" );
225 # Fail safe (not a redirect after all. strange.)
226 wfDebug( __METHOD__ .
": failsafe: database says " . $this->newTitle->getPrefixedDBkey() .
227 " is a redirect, but it doesn't contain a valid redirect.\n" );
239 global $wgCategoryCollation;
241 Hooks::run(
'TitleMove', [ $this->oldTitle, $this->newTitle, $user ] );
246 if ( $this->oldTitle->getNamespace() ==
NS_FILE ) {
248 $file->load( File::READ_LATEST );
249 if ( $file->exists() ) {
250 $status = $file->move( $this->newTitle );
260 $dbw->startAtomic( __METHOD__ );
262 Hooks::run(
'TitleMoveStarting', [ $this->oldTitle, $this->newTitle, $user ] );
265 $protected = $this->oldTitle->isProtected();
268 $nullRevision = $this->
moveToInternal( $user, $this->newTitle, $reason, $createRedirect );
274 $prefixes = $dbw->select(
276 [
'cl_sortkey_prefix',
'cl_to' ],
277 [
'cl_from' => $pageid ],
280 if ( $this->newTitle->getNamespace() ==
NS_CATEGORY ) {
282 } elseif ( $this->newTitle->getNamespace() ==
NS_FILE ) {
287 foreach ( $prefixes
as $prefixRow ) {
288 $prefix = $prefixRow->cl_sortkey_prefix;
289 $catTo = $prefixRow->cl_to;
290 $dbw->update(
'categorylinks',
293 $this->newTitle->getCategorySortkey( $prefix ) ),
294 'cl_collation' => $wgCategoryCollation,
296 'cl_timestamp=cl_timestamp' ],
298 'cl_from' => $pageid,
304 $redirid = $this->oldTitle->getArticleID();
307 # Protect the redirect title as the title used to be...
311 [
'pr_page' => $pageid ],
316 foreach (
$res as $row ) {
318 'pr_page' => $redirid,
319 'pr_type' => $row->pr_type,
320 'pr_level' => $row->pr_level,
321 'pr_cascade' => $row->pr_cascade,
322 'pr_user' => $row->pr_user,
323 'pr_expiry' => $row->pr_expiry
326 $dbw->insert(
'page_restrictions', $rowsInsert, __METHOD__, [
'IGNORE' ] );
331 $this->oldTitle->getPrefixedText(),
332 $this->newTitle->getPrefixedText()
333 )->inContentLanguage()->text();
335 $comment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() . $reason;
339 $insertedPrIds = $dbw->select(
342 [
'pr_page' => $redirid ],
345 $logRelationsValues = [];
346 foreach ( $insertedPrIds
as $prid ) {
347 $logRelationsValues[] = $prid->pr_id;
352 $logEntry->setTarget( $this->newTitle );
354 $logEntry->setPerformer( $user );
355 $logEntry->setParameters( [
356 '4::oldtitle' => $this->oldTitle->getPrefixedText(),
358 $logEntry->setRelations( [
'pr_id' => $logRelationsValues ] );
359 $logId = $logEntry->insert();
360 $logEntry->publish( $logId );
364 if ( $this->oldTitle->getNamespace() != $this->newTitle->getNamespace() ) {
365 $dbw->update(
'pagelinks',
366 [
'pl_from_namespace' => $this->newTitle->getNamespace() ],
367 [
'pl_from' => $pageid ],
370 $dbw->update(
'templatelinks',
371 [
'tl_from_namespace' => $this->newTitle->getNamespace() ],
372 [
'tl_from' => $pageid ],
375 $dbw->update(
'imagelinks',
376 [
'il_from_namespace' => $this->newTitle->getNamespace() ],
377 [
'il_from' => $pageid ],
383 $oldtitle = $this->oldTitle->getDBkey();
384 $newtitle = $this->newTitle->getDBkey();
387 if ( $oldsnamespace != $newsnamespace || $oldtitle != $newtitle ) {
388 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
389 $store->duplicateAllAssociatedEntries( $this->oldTitle, $this->newTitle );
393 'TitleMoveCompleting',
394 [ $this->oldTitle, $this->newTitle,
395 $user, $pageid, $redirid, $reason, $nullRevision ]
398 $dbw->endAtomic( __METHOD__ );
439 if ( $nt->exists() ) {
440 $moveOverRedirect =
true;
441 $logType =
'move_redir';
443 $moveOverRedirect =
false;
447 if ( $moveOverRedirect ) {
449 'delete_and_move_reason',
450 $this->oldTitle->getPrefixedText()
454 $status = $newpage->doDeleteArticleReal(
469 $nt->resetArticleID(
false );
472 if ( $createRedirect ) {
473 if ( $this->oldTitle->getNamespace() ==
NS_CATEGORY
474 && !
wfMessage(
'category-move-redirect-override' )->inContentLanguage()->isDisabled()
477 wfMessage(
'category-move-redirect-override' )
478 ->params( $nt->getPrefixedText() )->inContentLanguage()->plain() );
481 $redirectContent = $contentHandler->makeRedirectContent( $nt,
482 wfMessage(
'move-redirect-text' )->inContentLanguage()->
plain() );
487 $redirectContent = null;
492 $contentModel = $this->oldTitle->getContentModel();
494 $defaultContentModelChanging = ( $oldDefault !== $newDefault
495 && $oldDefault === $contentModel );
498 $oldid = $this->oldTitle->getArticleID();
502 $logEntry->setPerformer( $user );
503 $logEntry->setTarget( $logTitle );
504 $logEntry->setComment( $reason );
505 $logEntry->setParameters( [
506 '4::target' => $nt->getPrefixedText(),
507 '5::noredir' => $redirectContent ?
'0':
'1',
512 $comment = $formatter->getPlainActionText();
514 $comment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() . $reason;
516 # Truncate for whole multibyte characters.
522 $oldcountable = $oldpage->isCountable();
526 # Save a null revision in the page's history notifying of the move
528 if ( !is_object( $nullRevision ) ) {
529 throw new MWException(
'No valid null revision produced in ' . __METHOD__ );
532 $nullRevision->insertOn( $dbw );
534 # Change the name of the target page:
535 $dbw->update(
'page',
537 'page_namespace' => $nt->getNamespace(),
538 'page_title' => $nt->getDBkey(),
540 [
'page_id' => $oldid ],
544 if ( !$redirectContent ) {
549 $this->oldTitle->resetArticleID( 0 );
550 $nt->resetArticleID( $oldid );
553 $newpage->updateRevisionOn( $dbw, $nullRevision );
556 [ $newpage, $nullRevision, $nullRevision->getParentId(),
$user ] );
558 $newpage->doEditUpdates( $nullRevision, $user,
559 [
'changed' =>
false,
'moved' =>
true,
'oldcountable' => $oldcountable ] );
562 if ( $defaultContentModelChanging ) {
565 [
'rev_content_model' => $contentModel ],
566 [
'rev_page' => $nt->getArticleID(),
'rev_content_model IS NULL' ],
573 # Recreate the redirect, this time in the other direction.
574 if ( $redirectContent ) {
577 $newid = $redirectArticle->insertOn( $dbw );
579 $this->oldTitle->resetArticleID( $newid );
581 'title' => $this->oldTitle,
583 'user_text' => $user->
getName(),
584 'user' => $user->
getId(),
586 'content' => $redirectContent ] );
587 $redirectRevision->
insertOn( $dbw );
588 $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 );
591 [ $redirectArticle, $redirectRevision,
false, $user ] );
593 $redirectArticle->doEditUpdates( $redirectRevision, $user, [
'created' =>
true ] );
598 $logid = $logEntry->insert();
599 $logEntry->publish( $logid );
601 return $nullRevision;
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
static onArticleCreate(Title $title)
The onArticle*() functions are supposed to be a kind of hooks which should be called whenever any of ...
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
Handles the backend logic of moving a page from one title to another.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
const READ_LOCKING
Constants for object loading bitfield flags (higher => higher QoS)
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title...
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
when a variable name is used in a it is silently declared as a new local masking the global
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target...
wfLocalFile($title)
Get an object referring to a locally registered file.
wfStripIllegalFilenameChars($name)
Replace all invalid characters with '-'.
getName()
Get the user name, or the IP of an anonymous user.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static matchSummarySpamRegex($text)
Check given input text against $wgSummarySpamRegex, and return the text of the first match...
you have access to all of the normal MediaWiki so you can get a DB use the cache
static getLocalizedName($name, Language $lang=null)
Returns the localized name for a given content model.
move(User $user, $reason, $createRedirect)
wfMergeErrorArrays()
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g.
checkPermissions(User $user, $reason)
isAllowed($action= '')
Internal mechanics of testing a permission.
moveToInternal(User $user, &$nt, $reason= '', $createRedirect=true)
Move page to a title which is either a redirect to the source page or nonexistent.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock()-offset Set to overwrite offset parameter in $wgRequest set to ''to unsetoffset-wrap String Wrap the message in html(usually something like"<
static singleton()
Get a RepoGroup instance.
static newNullRevision($dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
const GAID_FOR_UPDATE
Used to be GAID_FOR_UPDATE define.
Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
static newExtraneousContext(Title $title, $request=[])
Create a new extraneous context.
static newGood($value=null)
Factory function for good results.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Content object for wiki text pages.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
isValidFileMove()
Sanity checks for when a file is being moved.
static checkExtensionCompatibility(File $old, $new)
Checks if file extensions are compatible.
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
Class for creating log entries manually, to inject them into the database.
__construct(Title $oldTitle, Title $newTitle)
isValidMoveTarget()
Checks if $this can be moved to a given Title.
getId()
Get the user's ID.
insertOn($dbw)
Insert a new revision into the database, returning the new revision ID number on success and dies hor...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
static onArticleDelete(Title $title)
Clears caches when article is deleted.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
isValidMove()
Does various sanity checks that the move is valid.
static getSubject($index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA, NS_SPECIAL) are always the subject.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type