MediaWiki  master
MovePage.php
Go to the documentation of this file.
1 <?php
2 
23 
30 class MovePage {
31 
35  protected $oldTitle;
36 
40  protected $newTitle;
41 
42  public function __construct( Title $oldTitle, Title $newTitle ) {
43  $this->oldTitle = $oldTitle;
44  $this->newTitle = $newTitle;
45  }
46 
47  public function checkPermissions( User $user, $reason ) {
48  $status = new Status();
49 
50  $errors = wfMergeErrorArrays(
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 )
55  );
56 
57  // Convert into a Status object
58  if ( $errors ) {
59  foreach ( $errors as $error ) {
60  call_user_func_array( [ $status, 'fatal' ], $error );
61  }
62  }
63 
64  if ( EditPage::matchSummarySpamRegex( $reason ) !== false ) {
65  // This is kind of lame, won't display nice
66  $status->fatal( 'spamprotectiontext' );
67  }
68 
69  $tp = $this->newTitle->getTitleProtection();
70  if ( $tp !== false && !$user->isAllowed( $tp['permission'] ) ) {
71  $status->fatal( 'cantmove-titleprotected' );
72  }
73 
74  Hooks::run( 'MovePageCheckPermissions',
75  [ $this->oldTitle, $this->newTitle, $user, $reason, $status ]
76  );
77 
78  return $status;
79  }
80 
88  public function isValidMove() {
90  $status = new Status();
91 
92  if ( $this->oldTitle->equals( $this->newTitle ) ) {
93  $status->fatal( 'selfmove' );
94  }
95  if ( !$this->oldTitle->isMovable() ) {
96  $status->fatal( 'immobile-source-namespace', $this->oldTitle->getNsText() );
97  }
98  if ( $this->newTitle->isExternal() ) {
99  $status->fatal( 'immobile-target-namespace-iw' );
100  }
101  if ( !$this->newTitle->isMovable() ) {
102  $status->fatal( 'immobile-target-namespace', $this->newTitle->getNsText() );
103  }
104 
105  $oldid = $this->oldTitle->getArticleID();
106 
107  if ( strlen( $this->newTitle->getDBkey() ) < 1 ) {
108  $status->fatal( 'articleexists' );
109  }
110  if (
111  ( $this->oldTitle->getDBkey() == '' ) ||
112  ( !$oldid ) ||
113  ( $this->newTitle->getDBkey() == '' )
114  ) {
115  $status->fatal( 'badarticleerror' );
116  }
117 
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).
121  if ( $this->newTitle->getArticleID() && !$this->isValidMoveTarget() ) {
122  $status->fatal( 'articleexists' );
123  }
124 
125  // Content model checks
126  if ( !$wgContentHandlerUseDB &&
127  $this->oldTitle->getContentModel() !== $this->newTitle->getContentModel() ) {
128  // can't move a page if that would change the page's content model
129  $status->fatal(
130  'bad-target-model',
131  ContentHandler::getLocalizedName( $this->oldTitle->getContentModel() ),
132  ContentHandler::getLocalizedName( $this->newTitle->getContentModel() )
133  );
134  }
135 
136  // Image-specific checks
137  if ( $this->oldTitle->inNamespace( NS_FILE ) ) {
138  $status->merge( $this->isValidFileMove() );
139  }
140 
141  if ( $this->newTitle->inNamespace( NS_FILE ) && !$this->oldTitle->inNamespace( NS_FILE ) ) {
142  $status->fatal( 'nonfile-cannot-move-to-file' );
143  }
144 
145  // Hook for extensions to say a title can't be moved for technical reasons
146  Hooks::run( 'MovePageIsValidMove', [ $this->oldTitle, $this->newTitle, $status ] );
147 
148  return $status;
149  }
150 
156  protected function isValidFileMove() {
157  $status = new Status();
158  $file = wfLocalFile( $this->oldTitle );
159  $file->load( File::READ_LATEST );
160  if ( $file->exists() ) {
161  if ( $this->newTitle->getText() != wfStripIllegalFilenameChars( $this->newTitle->getText() ) ) {
162  $status->fatal( 'imageinvalidfilename' );
163  }
164  if ( !File::checkExtensionCompatibility( $file, $this->newTitle->getDBkey() ) ) {
165  $status->fatal( 'imagetypemismatch' );
166  }
167  }
168 
169  if ( !$this->newTitle->inNamespace( NS_FILE ) ) {
170  $status->fatal( 'imagenocrossnamespace' );
171  }
172 
173  return $status;
174  }
175 
183  protected function isValidMoveTarget() {
184  # Is it an existing file?
185  if ( $this->newTitle->inNamespace( NS_FILE ) ) {
186  $file = wfLocalFile( $this->newTitle );
187  $file->load( File::READ_LATEST );
188  if ( $file->exists() ) {
189  wfDebug( __METHOD__ . ": file exists\n" );
190  return false;
191  }
192  }
193  # Is it a redirect with no history?
194  if ( !$this->newTitle->isSingleRevRedirect() ) {
195  wfDebug( __METHOD__ . ": not a one-rev redirect\n" );
196  return false;
197  }
198  # Get the article text
199  $rev = Revision::newFromTitle( $this->newTitle, false, Revision::READ_LATEST );
200  if ( !is_object( $rev ) ) {
201  return false;
202  }
203  $content = $rev->getContent();
204  # Does the redirect point to the source?
205  # Or is it a broken self-redirect, usually caused by namespace collisions?
206  $redirTitle = $content ? $content->getRedirectTarget() : null;
207 
208  if ( $redirTitle ) {
209  if ( $redirTitle->getPrefixedDBkey() !== $this->oldTitle->getPrefixedDBkey() &&
210  $redirTitle->getPrefixedDBkey() !== $this->newTitle->getPrefixedDBkey() ) {
211  wfDebug( __METHOD__ . ": redirect points to other page\n" );
212  return false;
213  } else {
214  return true;
215  }
216  } else {
217  # Fail safe (not a redirect after all. strange.)
218  wfDebug( __METHOD__ . ": failsafe: database says " . $this->newTitle->getPrefixedDBkey() .
219  " is a redirect, but it doesn't contain a valid redirect.\n" );
220  return false;
221  }
222  }
223 
230  public function move( User $user, $reason, $createRedirect ) {
232 
233  Hooks::run( 'TitleMove', [ $this->oldTitle, $this->newTitle, $user ] );
234 
235  // If it is a file, move it first.
236  // It is done before all other moving stuff is done because it's hard to revert.
237  $dbw = wfGetDB( DB_MASTER );
238  if ( $this->oldTitle->getNamespace() == NS_FILE ) {
239  $file = wfLocalFile( $this->oldTitle );
240  $file->load( File::READ_LATEST );
241  if ( $file->exists() ) {
242  $status = $file->move( $this->newTitle );
243  if ( !$status->isOK() ) {
244  return $status;
245  }
246  }
247  // Clear RepoGroup process cache
248  RepoGroup::singleton()->clearCache( $this->oldTitle );
249  RepoGroup::singleton()->clearCache( $this->newTitle ); # clear false negative cache
250  }
251 
252  $dbw->startAtomic( __METHOD__ );
253 
254  Hooks::run( 'TitleMoveStarting', [ $this->oldTitle, $this->newTitle, $user ] );
255 
256  $pageid = $this->oldTitle->getArticleID( Title::GAID_FOR_UPDATE );
257  $protected = $this->oldTitle->isProtected();
258 
259  // Do the actual move
260  $nullRevision = $this->moveToInternal( $user, $this->newTitle, $reason, $createRedirect );
261 
262  // Refresh the sortkey for this row. Be careful to avoid resetting
263  // cl_timestamp, which may disturb time-based lists on some sites.
264  // @todo This block should be killed, it's duplicating code
265  // from LinksUpdate::getCategoryInsertions() and friends.
266  $prefixes = $dbw->select(
267  'categorylinks',
268  [ 'cl_sortkey_prefix', 'cl_to' ],
269  [ 'cl_from' => $pageid ],
270  __METHOD__
271  );
272  if ( $this->newTitle->getNamespace() == NS_CATEGORY ) {
273  $type = 'subcat';
274  } elseif ( $this->newTitle->getNamespace() == NS_FILE ) {
275  $type = 'file';
276  } else {
277  $type = 'page';
278  }
279  foreach ( $prefixes as $prefixRow ) {
280  $prefix = $prefixRow->cl_sortkey_prefix;
281  $catTo = $prefixRow->cl_to;
282  $dbw->update( 'categorylinks',
283  [
284  'cl_sortkey' => Collation::singleton()->getSortKey(
285  $this->newTitle->getCategorySortkey( $prefix ) ),
286  'cl_collation' => $wgCategoryCollation,
287  'cl_type' => $type,
288  'cl_timestamp=cl_timestamp' ],
289  [
290  'cl_from' => $pageid,
291  'cl_to' => $catTo ],
292  __METHOD__
293  );
294  }
295 
296  $redirid = $this->oldTitle->getArticleID();
297 
298  if ( $protected ) {
299  # Protect the redirect title as the title used to be...
300  $dbw->insertSelect( 'page_restrictions', 'page_restrictions',
301  [
302  'pr_page' => $redirid,
303  'pr_type' => 'pr_type',
304  'pr_level' => 'pr_level',
305  'pr_cascade' => 'pr_cascade',
306  'pr_user' => 'pr_user',
307  'pr_expiry' => 'pr_expiry'
308  ],
309  [ 'pr_page' => $pageid ],
310  __METHOD__,
311  [ 'IGNORE' ]
312  );
313 
314  // Build comment for log
316  'prot_1movedto2',
317  $this->oldTitle->getPrefixedText(),
318  $this->newTitle->getPrefixedText()
319  )->inContentLanguage()->text();
320  if ( $reason ) {
321  $comment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $reason;
322  }
323 
324  // reread inserted pr_ids for log relation
325  $insertedPrIds = $dbw->select(
326  'page_restrictions',
327  'pr_id',
328  [ 'pr_page' => $redirid ],
329  __METHOD__
330  );
331  $logRelationsValues = [];
332  foreach ( $insertedPrIds as $prid ) {
333  $logRelationsValues[] = $prid->pr_id;
334  }
335 
336  // Update the protection log
337  $logEntry = new ManualLogEntry( 'protect', 'move_prot' );
338  $logEntry->setTarget( $this->newTitle );
339  $logEntry->setComment( $comment );
340  $logEntry->setPerformer( $user );
341  $logEntry->setParameters( [
342  '4::oldtitle' => $this->oldTitle->getPrefixedText(),
343  ] );
344  $logEntry->setRelations( [ 'pr_id' => $logRelationsValues ] );
345  $logId = $logEntry->insert();
346  $logEntry->publish( $logId );
347  }
348 
349  // Update *_from_namespace fields as needed
350  if ( $this->oldTitle->getNamespace() != $this->newTitle->getNamespace() ) {
351  $dbw->update( 'pagelinks',
352  [ 'pl_from_namespace' => $this->newTitle->getNamespace() ],
353  [ 'pl_from' => $pageid ],
354  __METHOD__
355  );
356  $dbw->update( 'templatelinks',
357  [ 'tl_from_namespace' => $this->newTitle->getNamespace() ],
358  [ 'tl_from' => $pageid ],
359  __METHOD__
360  );
361  $dbw->update( 'imagelinks',
362  [ 'il_from_namespace' => $this->newTitle->getNamespace() ],
363  [ 'il_from' => $pageid ],
364  __METHOD__
365  );
366  }
367 
368  # Update watchlists
369  $oldtitle = $this->oldTitle->getDBkey();
370  $newtitle = $this->newTitle->getDBkey();
371  $oldsnamespace = MWNamespace::getSubject( $this->oldTitle->getNamespace() );
372  $newsnamespace = MWNamespace::getSubject( $this->newTitle->getNamespace() );
373  if ( $oldsnamespace != $newsnamespace || $oldtitle != $newtitle ) {
374  $store = MediaWikiServices::getInstance()->getWatchedItemStore();
375  $store->duplicateAllAssociatedEntries( $this->oldTitle, $this->newTitle );
376  }
377 
378  Hooks::run(
379  'TitleMoveCompleting',
380  [ $this->oldTitle, $this->newTitle,
381  $user, $pageid, $redirid, $reason, $nullRevision ]
382  );
383 
384  $dbw->endAtomic( __METHOD__ );
385 
386  $params = [
389  &$user,
390  $pageid,
391  $redirid,
392  $reason,
393  $nullRevision
394  ];
395  // Keep each single hook handler atomic
398  $dbw,
399  __METHOD__,
400  function () use ( $params ) {
401  Hooks::run( 'TitleMoveComplete', $params );
402  }
403  )
404  );
405 
406  return Status::newGood();
407  }
408 
422  private function moveToInternal( User $user, &$nt, $reason = '', $createRedirect = true ) {
424 
425  if ( $nt->exists() ) {
426  $moveOverRedirect = true;
427  $logType = 'move_redir';
428  } else {
429  $moveOverRedirect = false;
430  $logType = 'move';
431  }
432 
433  if ( $createRedirect ) {
434  if ( $this->oldTitle->getNamespace() == NS_CATEGORY
435  && !wfMessage( 'category-move-redirect-override' )->inContentLanguage()->isDisabled()
436  ) {
437  $redirectContent = new WikitextContent(
438  wfMessage( 'category-move-redirect-override' )
439  ->params( $nt->getPrefixedText() )->inContentLanguage()->plain() );
440  } else {
441  $contentHandler = ContentHandler::getForTitle( $this->oldTitle );
442  $redirectContent = $contentHandler->makeRedirectContent( $nt,
443  wfMessage( 'move-redirect-text' )->inContentLanguage()->plain() );
444  }
445 
446  // NOTE: If this page's content model does not support redirects, $redirectContent will be null.
447  } else {
448  $redirectContent = null;
449  }
450 
451  // Figure out whether the content model is no longer the default
452  $oldDefault = ContentHandler::getDefaultModelFor( $this->oldTitle );
453  $contentModel = $this->oldTitle->getContentModel();
454  $newDefault = ContentHandler::getDefaultModelFor( $nt );
455  $defaultContentModelChanging = ( $oldDefault !== $newDefault
456  && $oldDefault === $contentModel );
457 
458  // bug 57084: log_page should be the ID of the *moved* page
459  $oldid = $this->oldTitle->getArticleID();
460  $logTitle = clone $this->oldTitle;
461 
462  $logEntry = new ManualLogEntry( 'move', $logType );
463  $logEntry->setPerformer( $user );
464  $logEntry->setTarget( $logTitle );
465  $logEntry->setComment( $reason );
466  $logEntry->setParameters( [
467  '4::target' => $nt->getPrefixedText(),
468  '5::noredir' => $redirectContent ? '0': '1',
469  ] );
470 
471  $formatter = LogFormatter::newFromEntry( $logEntry );
472  $formatter->setContext( RequestContext::newExtraneousContext( $this->oldTitle ) );
473  $comment = $formatter->getPlainActionText();
474  if ( $reason ) {
475  $comment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $reason;
476  }
477  # Truncate for whole multibyte characters.
478  $comment = $wgContLang->truncate( $comment, 255 );
479 
480  $dbw = wfGetDB( DB_MASTER );
481 
482  $oldpage = WikiPage::factory( $this->oldTitle );
483  $oldcountable = $oldpage->isCountable();
484 
485  $newpage = WikiPage::factory( $nt );
486 
487  if ( $moveOverRedirect ) {
488  $newid = $nt->getArticleID();
489  $newcontent = $newpage->getContent();
490 
491  # Delete the old redirect. We don't save it to history since
492  # by definition if we've got here it's rather uninteresting.
493  # We have to remove it so that the next step doesn't trigger
494  # a conflict on the unique namespace+title index...
495  $dbw->delete( 'page', [ 'page_id' => $newid ], __METHOD__ );
496 
497  $newpage->doDeleteUpdates( $newid, $newcontent );
498  }
499 
500  # Save a null revision in the page's history notifying of the move
501  $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true, $user );
502  if ( !is_object( $nullRevision ) ) {
503  throw new MWException( 'No valid null revision produced in ' . __METHOD__ );
504  }
505 
506  $nullRevision->insertOn( $dbw );
507 
508  # Change the name of the target page:
509  $dbw->update( 'page',
510  /* SET */ [
511  'page_namespace' => $nt->getNamespace(),
512  'page_title' => $nt->getDBkey(),
513  ],
514  /* WHERE */ [ 'page_id' => $oldid ],
515  __METHOD__
516  );
517 
518  // clean up the old title before reset article id - bug 45348
519  if ( !$redirectContent ) {
520  WikiPage::onArticleDelete( $this->oldTitle );
521  }
522 
523  $this->oldTitle->resetArticleID( 0 ); // 0 == non existing
524  $nt->resetArticleID( $oldid );
525  $newpage->loadPageData( WikiPage::READ_LOCKING ); // bug 46397
526 
527  $newpage->updateRevisionOn( $dbw, $nullRevision );
528 
529  Hooks::run( 'NewRevisionFromEditComplete',
530  [ $newpage, $nullRevision, $nullRevision->getParentId(), $user ] );
531 
532  $newpage->doEditUpdates( $nullRevision, $user,
533  [ 'changed' => false, 'moved' => true, 'oldcountable' => $oldcountable ] );
534 
535  // If the default content model changes, we need to populate rev_content_model
536  if ( $defaultContentModelChanging ) {
537  $dbw->update(
538  'revision',
539  [ 'rev_content_model' => $contentModel ],
540  [ 'rev_page' => $nt->getArticleID(), 'rev_content_model IS NULL' ],
541  __METHOD__
542  );
543  }
544 
545  if ( !$moveOverRedirect ) {
547  }
548 
549  # Recreate the redirect, this time in the other direction.
550  if ( $redirectContent ) {
551  $redirectArticle = WikiPage::factory( $this->oldTitle );
552  $redirectArticle->loadFromRow( false, WikiPage::READ_LOCKING ); // bug 46397
553  $newid = $redirectArticle->insertOn( $dbw );
554  if ( $newid ) { // sanity
555  $this->oldTitle->resetArticleID( $newid );
556  $redirectRevision = new Revision( [
557  'title' => $this->oldTitle, // for determining the default content model
558  'page' => $newid,
559  'user_text' => $user->getName(),
560  'user' => $user->getId(),
561  'comment' => $comment,
562  'content' => $redirectContent ] );
563  $redirectRevision->insertOn( $dbw );
564  $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 );
565 
566  Hooks::run( 'NewRevisionFromEditComplete',
567  [ $redirectArticle, $redirectRevision, false, $user ] );
568 
569  $redirectArticle->doEditUpdates( $redirectRevision, $user, [ 'created' => true ] );
570  }
571  }
572 
573  # Log the move
574  $logid = $logEntry->insert();
575  $logEntry->publish( $logid );
576 
577  return $nullRevision;
578  }
579 }
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:101
static onArticleCreate(Title $title)
The onArticle*() functions are supposed to be a kind of hooks which should be called whenever any of ...
Definition: WikiPage.php:3270
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
Handles the backend logic of moving a page from one title to another.
Definition: MovePage.php:30
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static singleton()
Definition: Collation.php:34
Generic operation result class Has warning/error list, boolean status and arbitrary value...
Definition: Status.php:40
$comment
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
Definition: injection.txt:23
Represents a title within MediaWiki.
Definition: Title.php:36
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
static newFromTitle(LinkTarget $linkTarget, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given link target...
Definition: Revision.php:117
wfLocalFile($title)
Get an object referring to a locally registered file.
$wgCategoryCollation
Specify how category names should be sorted, when listed on a category page.
wfStripIllegalFilenameChars($name)
Replace all invalid characters with '-'.
getName()
Get the user name, or the IP of an anonymous user.
Definition: User.php:2139
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...
Definition: EditPage.php:2247
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
Definition: User.php:47
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility...
you have access to all of the normal MediaWiki so you can get a DB use the cache
Definition: maintenance.txt:52
move(User $user, $reason, $createRedirect)
Definition: MovePage.php:230
wfMergeErrorArrays()
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g.
checkPermissions(User $user, $reason)
Definition: MovePage.php:47
isAllowed($action= '')
Internal mechanics of testing a permission.
Definition: User.php:3576
moveToInternal(User $user, &$nt, $reason= '', $createRedirect=true)
Move page to a title which is either a redirect to the source page or nonexistent.
Definition: MovePage.php:422
static singleton()
Get a RepoGroup instance.
Definition: RepoGroup.php:59
static newNullRevision($dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
Definition: Revision.php:1640
MediaWiki exception.
Definition: MWException.php:26
const GAID_FOR_UPDATE
Used to be GAID_FOR_UPDATE define.
Definition: Title.php:51
Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
$params
const NS_CATEGORY
Definition: Defines.php:83
static newExtraneousContext(Title $title, $request=[])
Create a new extraneous context.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned after processing 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"&lt
static addUpdate(DeferrableUpdate $update, $type=self::POSTSEND)
Add an update to the deferred list.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
const NS_FILE
Definition: Defines.php:75
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
Definition: hooks.txt:1601
Content object for wiki text pages.
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
Definition: distributors.txt:9
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
Definition: hooks.txt:242
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
Definition: injection.txt:35
isValidFileMove()
Sanity checks for when a file is being moved.
Definition: MovePage.php:156
static checkExtensionCompatibility(File $old, $new)
Checks if file extensions are compatible.
Definition: File.php:248
Class for creating log entries manually, to inject them into the database.
Definition: LogEntry.php:394
__construct(Title $oldTitle, Title $newTitle)
Definition: MovePage.php:42
isValidMoveTarget()
Checks if $this can be moved to a given Title.
Definition: MovePage.php:183
getId()
Get the user's ID.
Definition: User.php:2114
insertOn($dbw)
Insert a new revision into the database, returning the new revision ID number on success and dies hor...
Definition: Revision.php:1371
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
Definition: hooks.txt:1020
static onArticleDelete(Title $title)
Clears caches when article is deleted.
Definition: WikiPage.php:3294
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
Definition: design.txt:56
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
Definition: hooks.txt:1020
const DB_MASTER
Definition: Defines.php:47
Title $oldTitle
Definition: MovePage.php:35
isValidMove()
Does various sanity checks that the move is valid.
Definition: MovePage.php:88
static getSubject($index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA, NS_SPECIAL) are always the subject.
Title $newTitle
Definition: MovePage.php:40
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
Definition: hooks.txt:2376
static newGood($value=null)
Factory function for good results.
Definition: Status.php:101