Go to the documentation of this file.
59 protected $mId =
null;
113 $ns =
$title->getNamespace();
116 throw new MWException(
"NS_MEDIA is a virtual namespace; use NS_FILE." );
117 } elseif ( $ns < 0 ) {
118 throw new MWException(
"Invalid or virtual namespace $ns given." );
153 $row = $db->selectRow(
'page', self::selectFields(),
array(
'page_id' => $id ), __METHOD__ );
174 $page->loadFromRow( $row,
$from );
210 return $content_handler->getActionOverrides();
238 public function clear() {
239 $this->mDataLoaded =
false;
251 $this->mCounter =
null;
252 $this->mRedirectTarget =
null;
253 $this->mLastRevision =
null;
254 $this->mTouched =
'19700101000000';
255 $this->mLinksUpdated =
'19700101000000';
256 $this->mTimestamp =
'';
257 $this->mIsRedirect =
false;
258 $this->mLatest =
false;
271 $this->mPreparedEdit =
false;
281 global $wgContentHandlerUseDB;
293 'page_links_updated',
298 if ( $wgContentHandlerUseDB ) {
299 $fields[] =
'page_content_model';
317 $row =
$dbr->selectRow(
'page', $fields, $conditions, __METHOD__,
$options );
335 'page_namespace' =>
$title->getNamespace(),
365 if ( is_int(
$from ) && $from <= $this->mDataLoadedFrom ) {
370 if (
$from === self::READ_LOCKING ) {
372 } elseif (
$from === self::READ_LATEST ) {
374 } elseif (
$from === self::READ_NORMAL ) {
408 $lc->clearLink( $this->mTitle );
411 $lc->addGoodLinkObjFromRow( $this->mTitle, $data );
413 $this->mTitle->loadFromRow( $data );
416 $this->mTitle->loadRestrictions( $data->page_restrictions );
418 $this->mId = intval( $data->page_id );
419 $this->mCounter = intval( $data->page_counter );
422 $this->mIsRedirect = intval( $data->page_is_redirect );
423 $this->mLatest = intval( $data->page_latest );
426 if ( $this->mLastRevision && $this->mLastRevision->getId() !=
$this->mLatest ) {
427 $this->mLastRevision =
null;
428 $this->mTimestamp =
'';
431 $lc->addBadLinkObj( $this->mTitle );
433 $this->mTitle->loadFromRow(
false );
440 $this->mDataLoaded =
true;
447 public function getId() {
448 if ( !$this->mDataLoaded ) {
457 public function exists() {
458 if ( !$this->mDataLoaded ) {
461 return $this->mId > 0;
473 return $this->
exists() || $this->mTitle->isAlwaysKnown();
480 if ( !$this->mDataLoaded ) {
498 return $content->isRedirect();
516 if (
$rev !==
null ) {
517 return $rev->getContentModel();
519 $title = $this->mTitle->getPrefixedDBkey();
520 wfWarn(
"Page $title exists but has no (visible) revisions!" );
525 return $this->mTitle->getContentModel();
533 if ( !$this->mDataLoaded ) {
544 if ( !$this->mDataLoaded ) {
555 if ( !$this->mDataLoaded ) {
566 if ( !$this->mDataLoaded ) {
585 while ( $continue ) {
586 $row = $db->selectRow(
587 array(
'page',
'revision' ),
590 'page_namespace' => $this->mTitle->getNamespace(),
591 'page_title' => $this->mTitle->getDBkey(),
596 'ORDER BY' =>
'rev_timestamp ASC'
617 if ( $this->mLastRevision !==
null ) {
643 $this->mLastRevision = $revision;
653 if ( $this->mLastRevision ) {
674 if ( $this->mLastRevision ) {
675 return $this->mLastRevision->getContent( $audience,
$user );
696 if ( $this->mLastRevision ) {
697 return $this->mLastRevision->getText( $audience,
$user );
719 if ( !$this->mTimestamp ) {
746 if ( $this->mLastRevision ) {
747 return $this->mLastRevision->getUser( $audience,
$user );
784 if ( $this->mLastRevision ) {
785 return $this->mLastRevision->getUserText( $audience,
$user );
802 if ( $this->mLastRevision ) {
803 return $this->mLastRevision->getComment( $audience,
$user );
816 if ( $this->mLastRevision ) {
817 return $this->mLastRevision->isMinor();
830 $key =
wfMemcKey(
'page-lastedit', md5( $this->mTitle->getPrefixedDBkey() ) );
842 $key =
wfMemcKey(
'page-lastedit', md5( $this->mTitle->getPrefixedDBkey() ) );
855 global $wgArticleCountMethod;
857 if ( !$this->mTitle->isContentPage() ) {
862 $content = $editInfo->pstContent;
867 if ( !$content || $content->isRedirect() ) {
873 if ( $wgArticleCountMethod ===
'link' ) {
881 $hasLinks = (bool)count( $editInfo->output->getLinks() );
884 array(
'pl_from' => $this->
getId() ), __METHOD__ );
888 return $content->isCountable( $hasLinks );
899 if ( !$this->mTitle->isRedirect() ) {
903 if ( $this->mRedirectTarget !==
null ) {
909 $row =
$dbr->selectRow(
'redirect',
910 array(
'rd_namespace',
'rd_title',
'rd_fragment',
'rd_interwiki' ),
916 if ( $row && !is_null( $row->rd_fragment ) && !is_null( $row->rd_interwiki ) ) {
918 $row->rd_namespace, $row->rd_title,
919 $row->rd_fragment, $row->rd_interwiki );
937 $retval = $content ? $content->getUltimateRedirectTarget() :
null;
952 $dbw->replace(
'redirect',
array(
'rd_from' ),
954 'rd_from' => $this->
getId(),
955 'rd_namespace' => $rt->getNamespace(),
956 'rd_title' => $rt->getDBkey(),
957 'rd_fragment' => $rt->getFragment(),
958 'rd_interwiki' => $rt->getInterwiki(),
985 if ( $rt->isExternal() ) {
986 if ( $rt->isLocal() ) {
991 $source = $this->mTitle->getFullURL(
'redirect=no' );
1000 if ( $rt->isSpecialPage() ) {
1006 if ( $rt->isValidRedirectTarget() ) {
1007 return $rt->getFullURL();
1026 if (
$dbr->implicitGroupby() ) {
1027 $realNameField =
'user_real_name';
1029 $realNameField =
'MIN(user_real_name) AS user_real_name';
1035 'user_id' =>
'rev_user',
1036 'user_name' =>
'rev_user_text',
1038 'timestamp' =>
'MAX(rev_timestamp)',
1041 $conds =
array(
'rev_page' => $this->
getId() );
1047 $conds[] =
"rev_user != $user";
1049 $conds[] =
"rev_user_text != {$dbr->addQuotes( $this->getUserText() )}";
1052 $conds[] =
"{$dbr->bitAnd( 'rev_deleted', Revision::DELETED_USER )} = 0";
1055 'user' =>
array(
'LEFT JOIN',
'rev_user = user_id' ),
1059 'GROUP BY' =>
array(
'rev_user',
'rev_user_text' ),
1060 'ORDER BY' =>
'timestamp DESC',
1081 $res = $db->select(
array(
'page',
'revision' ),
1082 array(
'rev_id',
'rev_user_text' ),
1084 'page_namespace' => $this->mTitle->getNamespace(),
1085 'page_title' => $this->mTitle->getDBkey(),
1086 'rev_page = page_id'
1089 'ORDER BY' =>
'rev_timestamp DESC',
1099 $row = $db->fetchObject(
$res );
1101 if ( $continue == 2 && $revLatest && $row->rev_id != $revLatest ) {
1107 }
while ( $continue );
1109 $authors =
array( $row->rev_user_text );
1111 foreach (
$res as $row ) {
1112 $authors[] = $row->rev_user_text;
1127 global $wgEnableParserCache;
1129 return $wgEnableParserCache
1132 && ( $oldid ===
null || $oldid === 0 || $oldid === $this->
getLatest() )
1151 wfDebug( __METHOD__ .
': using parser cache: ' . ( $useParserCache ?
'yes' :
'no' ) .
"\n" );
1156 if ( $useParserCache ) {
1158 if ( $parserOutput !==
false ) {
1160 return $parserOutput;
1164 if ( $oldid ===
null || $oldid === 0 ) {
1173 return $pool->getParserOutput();
1182 global $wgDisableCounters;
1188 if ( !$wgDisableCounters && !
$user->isAllowed(
'bot' ) && $this->
exists() ) {
1194 $user->clearNotification( $this->mTitle, $oldid );
1209 $this->mTitle->invalidateCache();
1211 if ( $wgUseSquid ) {
1214 $dbw->commit( __METHOD__ );
1218 $update->doUpdate();
1229 $text = $content ===
null ? null : $content->getWikitextForTransclusion();
1231 if ( $text ===
null ) {
1256 $page_id = $dbw->nextSequenceValue(
'page_page_id_seq' );
1257 $dbw->insert(
'page',
array(
1258 'page_id' => $page_id,
1259 'page_namespace' => $this->mTitle->getNamespace(),
1260 'page_title' => $this->mTitle->getDBkey(),
1261 'page_counter' => 0,
1262 'page_restrictions' =>
'',
1263 'page_is_redirect' => 0,
1266 'page_touched' => $dbw->timestamp(),
1269 ), __METHOD__,
'IGNORE' );
1271 $affected = $dbw->affectedRows();
1274 $newid = $dbw->insertId();
1275 $this->mId = $newid;
1276 $this->mTitle->resetArticleID( $newid );
1280 return $affected ? $newid :
false;
1298 public function updateRevisionOn( $dbw, $revision, $lastRevision =
null, $lastRevIsRedirect =
null ) {
1299 global $wgContentHandlerUseDB;
1304 $len = $content ? $content->getSize() : 0;
1305 $rt = $content ? $content->getUltimateRedirectTarget() :
null;
1307 $conditions =
array(
'page_id' => $this->
getId() );
1309 if ( !is_null( $lastRevision ) ) {
1311 $conditions[
'page_latest'] = $lastRevision;
1316 'page_latest' => $revision->
getId(),
1317 'page_touched' => $dbw->timestamp( $now ),
1318 'page_is_new' => ( $lastRevision === 0 ) ? 1 : 0,
1319 'page_is_redirect' => $rt !==
null ? 1 : 0,
1323 if ( $wgContentHandlerUseDB ) {
1327 $dbw->update(
'page',
1332 $result = $dbw->affectedRows() > 0;
1337 $this->mLatest = $revision->
getId();
1338 $this->mIsRedirect = (bool)$rt;
1359 public function updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect =
null ) {
1363 $isRedirect = !is_null( $redirectTitle );
1365 if ( !$isRedirect && $lastRevIsRedirect ===
false ) {
1370 if ( $isRedirect ) {
1374 $where =
array(
'rd_from' => $this->
getId() );
1375 $dbw->delete(
'redirect', $where, __METHOD__ );
1383 return ( $dbw->affectedRows() != 0 );
1397 $row = $dbw->selectRow(
1398 array(
'revision',
'page' ),
1399 array(
'rev_id',
'rev_timestamp',
'page_is_redirect' ),
1401 'page_id' => $this->
getId(),
1402 'page_latest=rev_id' ),
1410 $prev = $row->rev_id;
1411 $lastRevIsRedirect = (bool)$row->page_is_redirect;
1415 $lastRevIsRedirect =
null;
1436 return $handler->getUndoContent( $this->
getRevision(), $undo, $undoafter );
1453 if ( $this->mLastRevision ) {
1454 if ( is_null( $undoafter ) ) {
1459 $undone = $handler->getUndoContent( $this->mLastRevision, $undo, $undoafter );
1491 throw new MWException(
"sections not supported for content model " .
1528 $edittime =
null ) {
1537 throw new MWException(
"sections not supported for content model " .
1542 if ( is_null( $edittime ) ||
$section ==
'new' ) {
1549 wfDebug(
"WikiPage::replaceSection asked for bogus section (page: " .
1550 $this->
getId() .
"; section: $section; edittime: $edittime)\n" );
1555 $oldContent =
$rev->getContent();
1558 if ( ! $oldContent ) {
1559 wfDebug( __METHOD__ .
": no page text\n" );
1695 User $user =
null, $serialisation_format =
null
1697 global $wgUser, $wgUseAutomaticEditSummaries, $wgUseRCPatrol, $wgUseNPPatrol;
1700 if ( $this->mTitle->getText() ===
'' ) {
1701 throw new MWException(
'Something is trying to edit an article with an empty title' );
1710 $this->
getTitle()->getPrefixedText() );
1727 if ( !
wfRunHooks(
'PageContentSave', $hook_args )
1730 wfDebug( __METHOD__ .
": ArticleSave or ArticleSaveContent hook aborted save!\n" );
1732 if ( $status->isOK() ) {
1733 $status->fatal(
'edit-hook-aborted' );
1746 $oldsize = $old_content ? $old_content->getSize() : 0;
1755 if ( !$old_content ) {
1756 $old_content =
null;
1758 $summary = $handler->getAutosummary( $old_content, $content,
$flags );
1767 $content = $editInfo->pstContent;
1768 $newsize = $content->
getSize();
1772 $this->mTimestamp = $now;
1776 $status->value[
'new'] =
false;
1780 wfDebug( __METHOD__ .
": EDIT_UPDATE specified but article doesn't exist\n" );
1781 $status->fatal(
'edit-gone-missing' );
1785 } elseif ( !$old_content ) {
1788 throw new MWException(
"Could not find text for current revision {$oldid}." );
1792 'page' => $this->
getId(),
1795 'minor_edit' => $isminor,
1798 'parent_id' => $oldid,
1799 'user' =>
$user->getId(),
1800 'user_text' =>
$user->getName(),
1801 'timestamp' => $now,
1802 'content_model' => $content->
getModel(),
1803 'content_format' => $serialisation_format,
1811 throw new MWException(
"New content failed validity check!" );
1814 $dbw->begin( __METHOD__ );
1818 $status->merge( $prepStatus );
1820 if ( !$status->isOK() ) {
1821 $dbw->rollback( __METHOD__ );
1826 $revisionId = $revision->
insertOn( $dbw );
1839 $status->fatal(
'edit-conflict' );
1841 $dbw->rollback( __METHOD__ );
1851 $patrolled = $wgUseRCPatrol && !count(
1852 $this->mTitle->getUserPermissionsErrors(
'autopatrol',
$user ) );
1855 $oldid, $this->
getTimestamp(), $bot,
'', $oldsize, $newsize,
1856 $revisionId, $patrolled
1864 $user->incEditCount();
1866 $dbw->rollback( __METHOD__ );
1871 $dbw->commit( __METHOD__ );
1884 'oldcountable' => $oldcountable
1889 $status->warning(
'edit-no-change' );
1893 $this->mTitle->invalidateCache();
1897 $status->value[
'new'] =
true;
1899 $dbw->begin( __METHOD__ );
1903 $status->merge( $prepStatus );
1905 if ( !$status->isOK() ) {
1906 $dbw->rollback( __METHOD__ );
1912 $status->merge( $prepStatus );
1918 if ( $newid ===
false ) {
1919 $dbw->rollback( __METHOD__ );
1920 $status->fatal(
'edit-already-exists' );
1931 'minor_edit' => $isminor,
1934 'user' =>
$user->getId(),
1935 'user_text' =>
$user->getName(),
1936 'timestamp' => $now,
1937 'content_model' => $content->
getModel(),
1938 'content_format' => $serialisation_format,
1940 $revisionId = $revision->
insertOn( $dbw );
1946 $newsize = $content->
getSize();
1957 $patrolled = ( $wgUseRCPatrol || $wgUseNPPatrol ) && !count(
1958 $this->mTitle->getUserPermissionsErrors(
'autopatrol',
$user ) );
1961 '', $newsize, $revisionId, $patrolled );
1968 $user->incEditCount();
1971 $dbw->rollback( __METHOD__ );
1974 $dbw->commit( __METHOD__ );
1983 wfRunHooks(
'PageContentInsertComplete', $hook_args );
1992 $status->value[
'revision'] = $revision;
1998 wfRunHooks(
'PageContentSaveComplete', $hook_args );
2001 $user->addAutopromoteOnceGroups(
'onEdit' );
2024 if ( $this->
getTitle()->isConversionTable() ) {
2026 $options->disableContentConversion();
2058 $serialization_format =
null
2065 if ( $serialization_format ===
null ) {
2069 if ( $this->mPreparedEdit
2070 && $this->mPreparedEdit->newContent
2071 && $this->mPreparedEdit->newContent->equals( $content )
2072 && $this->mPreparedEdit->revid == $revid
2073 && $this->mPreparedEdit->format == $serialization_format
2084 $edit->revid = $revid;
2089 $edit->format = $serialization_format;
2091 $edit->output = $edit->pstContent ? $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts ) :
null;
2093 $edit->newContent = $content;
2099 $edit->pst = $edit->pstContent ? $edit->pstContent->serialize( $serialization_format ) :
'';
2101 $this->mPreparedEdit = $edit;
2122 global $wgEnableParserCache;
2126 $options +=
array(
'changed' =>
true,
'created' =>
false,
'oldcountable' =>
null );
2132 if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag(
'vary-revision' ) ) {
2133 wfDebug( __METHOD__ .
": No prepared edit or vary-revision is set...\n" );
2136 wfDebug( __METHOD__ .
": No vary-revision, using prepared edit...\n" );
2141 if ( $wgEnableParserCache ) {
2144 $editInfo->output, $this, $editInfo->popts, $editInfo->timestamp, $editInfo->revid
2152 $this->
getTitle(),
null, $recursive, $editInfo->output );
2158 if (
wfRunHooks(
'ArticleEditUpdatesDeleteFromRecentchanges',
array( &$this ) ) ) {
2159 if ( 0 == mt_rand( 0, 99 ) ) {
2166 if ( !$this->
exists() ) {
2171 $id = $this->
getId();
2172 $title = $this->mTitle->getPrefixedDBkey();
2173 $shortTitle = $this->mTitle->getDBkey();
2181 } elseif (
$options[
'oldcountable'] !==
null ) {
2197 && $shortTitle !=
$user->getTitleKey()
2198 && !( $revision->
isMinor() &&
$user->isAllowed(
'nominornewtalk' ) )
2201 if ( !$recipient ) {
2202 wfDebug( __METHOD__ .
": invalid username\n" );
2205 if (
wfRunHooks(
'ArticleEditUpdateNewTalk',
array( &$this, $recipient ) ) ) {
2208 $recipient->setNewtalk(
true, $revision );
2209 } elseif ( $recipient->isLoggedIn() ) {
2210 $recipient->setNewtalk(
true, $revision );
2212 wfDebug( __METHOD__ .
": don't need to notify a nonexistent user\n" );
2221 if ( $msgtext ===
false || $msgtext ===
null ) {
2268 $serialisation_format =
null
2277 'page' => $this->
getId(),
2279 'length' => $content->
getSize(),
2281 'minor_edit' => $minor ? 1 : 0,
2310 $restrictionTypes = $this->mTitle->getRestrictionTypes();
2311 $id = $this->
getId();
2322 $isProtected =
false;
2328 foreach ( $restrictionTypes
as $action ) {
2329 if ( !isset( $expiry[$action] ) ) {
2330 $expiry[$action] = $dbw->getInfinity();
2332 if ( !isset(
$limit[$action] ) ) {
2334 } elseif (
$limit[$action] !=
'' ) {
2339 $current = implode(
'', $this->mTitle->getRestrictions( $action ) );
2340 if ( $current !=
'' ) {
2341 $isProtected =
true;
2344 if (
$limit[$action] != $current ) {
2346 } elseif (
$limit[$action] !=
'' ) {
2350 if ( $this->mTitle->getRestrictionExpiry( $action ) != $expiry[$action] ) {
2356 if ( !
$changed && $protect && $this->mTitle->areRestrictionsCascading() != $cascade ) {
2366 $revCommentMsg =
'unprotectedarticle';
2367 $logAction =
'unprotect';
2368 } elseif ( $isProtected ) {
2369 $revCommentMsg =
'modifiedarticleprotection';
2370 $logAction =
'modify';
2372 $revCommentMsg =
'protectedarticle';
2373 $logAction =
'protect';
2379 $logRelationsValues =
array();
2380 $logRelationsField =
null;
2388 $editrestriction = isset(
$limit[
'edit'] ) ?
array(
$limit[
'edit'] ) : $this->mTitle->getRestrictions(
'edit' );
2389 foreach ( array_keys( $editrestriction,
'sysop' )
as $key ) {
2390 $editrestriction[$key] =
'editprotected';
2392 foreach ( array_keys( $editrestriction,
'autoconfirmed' )
as $key ) {
2393 $editrestriction[$key] =
'editsemiprotected';
2396 $cascadingRestrictionLevels = $wgCascadingRestrictionLevels;
2397 foreach ( array_keys( $cascadingRestrictionLevels,
'sysop' )
as $key ) {
2398 $cascadingRestrictionLevels[$key] =
'editprotected';
2400 foreach ( array_keys( $cascadingRestrictionLevels,
'autoconfirmed' )
as $key ) {
2401 $cascadingRestrictionLevels[$key] =
'editsemiprotected';
2405 if ( !array_intersect( $editrestriction, $cascadingRestrictionLevels ) ) {
2412 if ( $nullRevision ===
null ) {
2413 return Status::newFatal(
'no-null-revision', $this->mTitle->getPrefixedText() );
2416 $logRelationsField =
'pr_id';
2419 foreach (
$limit as $action => $restrictions ) {
2421 'page_restrictions',
2424 'pr_type' => $action
2428 if ( $restrictions !=
'' ) {
2430 'page_restrictions',
2432 'pr_id' => $dbw->nextSequenceValue(
'page_restrictions_pr_id_seq' ),
2434 'pr_type' => $action,
2435 'pr_level' => $restrictions,
2436 'pr_cascade' => ( $cascade && $action ==
'edit' ) ? 1 : 0,
2437 'pr_expiry' => $dbw->encodeExpiry( $expiry[$action] )
2441 $logRelationsValues[] = $dbw->insertId();
2448 array(
'page_restrictions' =>
'' ),
2449 array(
'page_id' => $id ),
2459 if (
$limit[
'create'] !=
'' ) {
2460 $dbw->replace(
'protected_titles',
2461 array(
array(
'pt_namespace',
'pt_title' ) ),
2463 'pt_namespace' => $this->mTitle->getNamespace(),
2464 'pt_title' => $this->mTitle->getDBkey(),
2465 'pt_create_perm' =>
$limit[
'create'],
2466 'pt_timestamp' => $dbw->timestamp(),
2467 'pt_expiry' => $dbw->encodeExpiry( $expiry[
'create'] ),
2468 'pt_user' =>
$user->getId(),
2469 'pt_reason' => $reason,
2473 $dbw->delete(
'protected_titles',
2475 'pt_namespace' => $this->mTitle->getNamespace(),
2476 'pt_title' => $this->mTitle->getDBkey()
2482 $this->mTitle->flushRestrictions();
2485 if ( $logAction ==
'unprotect' ) {
2489 $params =
array( $protectDescriptionLog, $cascade ?
'cascade' :
'' );
2493 $log =
new LogPage(
'protect' );
2494 $logId = $log->addEntry( $logAction, $this->mTitle, $reason,
$params,
$user );
2495 if ( $logRelationsField !==
null && count( $logRelationsValues ) ) {
2496 $log->addRelations( $logRelationsField, $logRelationsValues, $logId );
2520 $this->mTitle->getPrefixedText()
2521 )->inContentLanguage()->text()
2524 $editComment .=
wfMessage(
'colon-separator' )->inContentLanguage()->text() . $reason;
2527 if ( $protectDescription ) {
2528 $editComment .=
wfMessage(
'word-separator' )->inContentLanguage()->text();
2529 $editComment .=
wfMessage(
'parentheses' )->params( $protectDescription )->inContentLanguage()->text();
2532 $editComment .=
wfMessage(
'word-separator' )->inContentLanguage()->text();
2533 $editComment .=
wfMessage(
'brackets' )->params(
2534 wfMessage(
'protect-summary-cascade' )->inContentLanguage()->
text()
2535 )->inContentLanguage()->text();
2540 $nullRev->insertOn( $dbw );
2543 $oldLatest = $nullRev->getParentId();
2558 $encodedExpiry =
$dbr->encodeExpiry( $expiry );
2559 if ( $encodedExpiry !=
'infinity' ) {
2562 $wgContLang->timeanddate( $expiry,
false,
false ),
2565 )->inContentLanguage()->text();
2567 return wfMessage(
'protect-expiry-indefinite' )
2568 ->inContentLanguage()->text();
2580 $protectDescription =
'';
2582 foreach ( array_filter(
$limit )
as $action => $restrictions ) {
2583 # $action is one of $wgRestrictionTypes = array( 'create', 'edit', 'move', 'upload' ).
2584 # All possible message keys are listed here for easier grepping:
2585 # * restriction-create
2586 # * restriction-edit
2587 # * restriction-move
2588 # * restriction-upload
2589 $actionText =
wfMessage(
'restriction-' . $action )->inContentLanguage()->text();
2590 # $restrictions is one of $wgRestrictionLevels = array( '', 'autoconfirmed', 'sysop' ),
2591 # with '' filtered out. All possible message keys are listed below:
2592 # * protect-level-autoconfirmed
2593 # * protect-level-sysop
2594 $restrictionsText =
wfMessage(
'protect-level-' . $restrictions )->inContentLanguage()->text();
2598 if ( $protectDescription !==
'' ) {
2599 $protectDescription .=
wfMessage(
'word-separator' )->inContentLanguage()->text();
2601 $protectDescription .=
wfMessage(
'protect-summary-desc' )
2602 ->params( $actionText, $restrictionsText, $expiryText )
2603 ->inContentLanguage()->text();
2606 return $protectDescription;
2623 $protectDescriptionLog =
'';
2625 foreach ( array_filter(
$limit )
as $action => $restrictions ) {
2627 $protectDescriptionLog .=
$wgContLang->getDirMark() .
"[$action=$restrictions] ($expiryText)";
2630 return trim( $protectDescriptionLog );
2643 if ( !is_array(
$limit ) ) {
2644 throw new MWException(
'WikiPage::flattenRestrictions given non-array restriction set' );
2650 foreach ( array_filter(
$limit )
as $action => $restrictions ) {
2651 $bits[] =
"$action=$restrictions";
2654 return implode(
':', $bits );
2674 $reason, $suppress =
false, $id = 0, $commit =
true, &
$error =
'',
User $user =
null
2677 return $status->isGood();
2698 $reason, $suppress =
false, $id = 0, $commit =
true, &
$error =
'',
User $user =
null
2706 if ( $this->mTitle->getDBkey() ===
'' ) {
2713 if ( $status->isOK() ) {
2715 $status->fatal(
'delete-hook-aborted' );
2722 $id = $this->getID();
2738 $bitfield =
'rev_deleted';
2745 $dbw->begin( __METHOD__ );
2758 'ar_namespace' =>
'page_namespace',
2759 'ar_title' =>
'page_title',
2760 'ar_comment' =>
'rev_comment',
2761 'ar_user' =>
'rev_user',
2762 'ar_user_text' =>
'rev_user_text',
2763 'ar_timestamp' =>
'rev_timestamp',
2764 'ar_minor_edit' =>
'rev_minor_edit',
2765 'ar_rev_id' =>
'rev_id',
2766 'ar_parent_id' =>
'rev_parent_id',
2767 'ar_text_id' =>
'rev_text_id',
2768 'ar_text' =>
'\'\
'',
2769 'ar_flags' =>
'\'\
'',
2770 'ar_len' =>
'rev_len',
2771 'ar_page_id' =>
'page_id',
2772 'ar_deleted' => $bitfield,
2773 'ar_sha1' =>
'rev_sha1',
2776 if ( $wgContentHandlerUseDB ) {
2777 $row[
'ar_content_model'] =
'rev_content_model';
2778 $row[
'ar_content_format'] =
'rev_content_format';
2781 $dbw->insertSelect(
'archive',
array(
'page',
'revision' ),
2785 'page_id = rev_page'
2790 $dbw->delete(
'page',
array(
'page_id' => $id ), __METHOD__ );
2791 $ok = ( $dbw->affectedRows() > 0 );
2794 $dbw->rollback( __METHOD__ );
2799 if ( !$dbw->cascadingDeletes() ) {
2800 $dbw->delete(
'revision',
array(
'rev_page' => $id ), __METHOD__ );
2806 $logtype = $suppress ?
'suppress' :
'delete';
2809 $logEntry->setPerformer(
$user );
2810 $logEntry->setTarget( $this->mTitle );
2811 $logEntry->setComment( $reason );
2812 $logid = $logEntry->insert();
2813 $logEntry->publish( $logid );
2816 $dbw->commit( __METHOD__ );
2819 wfRunHooks(
'ArticleDeleteComplete',
array( &$this, &
$user, $reason, $id, $content, $logEntry ) );
2820 $status->value = $logid;
2843 if ( $this->mTitle->getNamespace() ==
NS_FILE ) {
2884 $resultDetails =
null;
2887 $editErrors = $this->mTitle->getUserPermissionsErrors(
'edit',
$user );
2888 $rollbackErrors = $this->mTitle->getUserPermissionsErrors(
'rollback',
$user );
2889 $errors = array_merge( $editErrors,
wfArrayDiff2( $rollbackErrors, $editErrors ) );
2891 if ( !
$user->matchEditToken( $token,
array( $this->mTitle->getPrefixedText(), $fromP ) ) ) {
2892 $errors[] =
array(
'sessionfailure' );
2895 if (
$user->pingLimiter(
'rollback' ) ||
$user->pingLimiter() ) {
2896 $errors[] =
array(
'actionthrottledtext' );
2900 if ( !empty( $errors ) ) {
2934 if ( is_null( $current ) ) {
2939 $from = str_replace(
'_',
' ', $fromP );
2942 if (
$from != $current->getUserText() ) {
2943 $resultDetails =
array(
'current' => $current );
2945 htmlspecialchars( $this->mTitle->getPrefixedText() ),
2946 htmlspecialchars( $fromP ),
2947 htmlspecialchars( $current->getUserText() )
2953 $user = intval( $current->getRawUser() );
2954 $user_text = $dbw->addQuotes( $current->getRawUserText() );
2955 $s = $dbw->selectRow(
'revision',
2956 array(
'rev_id',
'rev_timestamp',
'rev_deleted' ),
2957 array(
'rev_page' => $current->getPage(),
2958 "rev_user != {$user} OR rev_user_text != {$user_text}"
2960 array(
'USE INDEX' =>
'page_timestamp',
2961 'ORDER BY' =>
'rev_timestamp DESC' )
2963 if (
$s ===
false ) {
2974 if ( $bot && $guser->
isAllowed(
'markbotedits' ) ) {
2979 if ( $wgUseRCPatrol ) {
2981 $set[
'rc_patrolled'] = 1;
2984 if ( count( $set ) ) {
2985 $dbw->update(
'recentchanges', $set,
2987 'rc_cur_id' => $current->getPage(),
2988 'rc_user_text' => $current->getUserText(),
2989 'rc_timestamp > ' . $dbw->addQuotes(
$s->rev_timestamp ),
2997 if (
$from ==
'' ) {
3006 $target->getUserText(),
$from,
$s->rev_id,
3008 $current->getId(),
$wgContLang->timeanddate( $current->getTimestamp() )
3010 if (
$summary instanceof Message ) {
3025 if ( $guser->
isAllowed(
'minoredit' ) ) {
3029 if ( $bot && ( $guser->
isAllowedAny(
'markbotedits',
'bot' ) ) ) {
3036 if ( !$status->isOK() ) {
3037 return $status->getErrorsArray();
3041 if ( empty( $status->value[
'revision'] ) ) {
3042 $resultDetails =
array(
'current' => $current );
3044 htmlspecialchars( $this->mTitle->getPrefixedText() ),
3045 htmlspecialchars( $fromP ),
3046 htmlspecialchars( $current->getUserText() )
3050 $revId = $status->value[
'revision']->getId();
3052 wfRunHooks(
'ArticleRollbackComplete',
array( $this, $guser, $target, $current ) );
3054 $resultDetails =
array(
3056 'current' => $current,
3057 'target' => $target,
3077 if (
$title->isTalkPage() ) {
3078 $other =
$title->getSubjectPage();
3080 $other =
$title->getTalkPage();
3083 $other->invalidateCache();
3084 $other->purgeSquid();
3088 $title->deleteTitleProtection();
3098 if (
$title->isTalkPage() ) {
3099 $other =
$title->getSubjectPage();
3101 $other =
$title->getTalkPage();
3104 $other->invalidateCache();
3105 $other->purgeSquid();
3122 $update->doUpdate();
3129 $user->setNewtalk(
false );
3167 $id = $this->
getId();
3173 $res =
$dbr->select(
'categorylinks',
3177 array(
'cl_from' => $id ),
3191 $id = $this->
getId();
3198 $res =
$dbr->select(
array(
'categorylinks',
'page_props',
'page' ),
3200 array(
'cl_from' => $id,
'pp_page=page_id',
'pp_propname' =>
'hiddencat',
3201 'page_namespace' =>
NS_CATEGORY,
'page_title=cl_to' ),
3204 if (
$res !==
false ) {
3205 foreach (
$res as $row ) {
3228 $oldContent = is_null( $oldtext ) ? null : $handler->unserializeContent( $oldtext );
3229 $newContent = is_null( $newtext ) ? null : $handler->unserializeContent( $newtext );
3231 return $handler->getAutosummary( $oldContent, $newContent,
$flags );
3254 $method = __METHOD__;
3258 $dbw->onTransactionPreCommitOrIdle(
3259 function() use ( $dbw, $that, $method, $added, $deleted ) {
3260 $ns = $that->getTitle()->getNamespace();
3262 $addFields =
array(
'cat_pages = cat_pages + 1' );
3263 $removeFields =
array(
'cat_pages = cat_pages - 1' );
3265 $addFields[] =
'cat_subcats = cat_subcats + 1';
3266 $removeFields[] =
'cat_subcats = cat_subcats - 1';
3268 $addFields[] =
'cat_files = cat_files + 1';
3269 $removeFields[] =
'cat_files = cat_files - 1';
3272 if ( count( $added ) ) {
3273 $insertRows =
array();
3274 foreach ( $added
as $cat ) {
3275 $insertRows[] =
array(
3276 'cat_title' => $cat,
3279 'cat_files' => ( $ns ==
NS_FILE ) ? 1 : 0,
3285 array(
'cat_title' ),
3291 if ( count( $deleted ) ) {
3295 array(
'cat_title' => $deleted ),
3300 foreach ( $added
as $catName ) {
3305 foreach ( $deleted
as $catName ) {
3319 if (
wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) {
3331 $id = $this->
getId();
3337 array(
'tl_namespace',
'tl_title' ),
3338 array(
'tl_from' => $id ),
3342 foreach (
$res as $row ) {
3343 $dbLinks[
"{$row->tl_namespace}:{$row->tl_title}"] =
true;
3349 array(
'il_from' => $id ),
3353 foreach (
$res as $row ) {
3354 $dbLinks[
NS_FILE .
":{$row->il_to}"] =
true;
3360 foreach ( $templates
as $dbk => $id ) {
3361 $poLinks[
"$ns:$dbk"] =
true;
3364 foreach ( $parserOutput->
getImages()
as $dbk => $id ) {
3365 $poLinks[
NS_FILE .
":$dbk"] =
true;
3369 $links_diff = array_diff_key( $poLinks, $dbLinks );
3371 if ( count( $links_diff ) > 0 ) {
3374 $u =
new LinksUpdate( $this->mTitle, $parserOutput,
false );
3387 return $this->mTitle->getTemplateLinksFrom();
3409 if ( $popts ===
null ) {
3424 return $this->mTitle->isBigDeletion();
3435 return $this->mTitle->estimateRevisionCount();
3479 wfRunHooks(
'WikiPageDeletionUpdates',
array( $this, $content, &$updates ) );
3538 $modelId =
$page->getRevision()->getContentModel();
3539 $format =
$page->getRevision()->getContentFormat();
3545 $this->cacheable = $useParserCache;
3549 parent::__construct(
'ArticleView', $this->cacheKey .
':revid:' .
$revid );
3582 public function doWork() {
3588 $isCurrent = $this->revid === $this->
page->getLatest();
3590 if ( $this->
content !==
null ) {
3592 } elseif ( $isCurrent ) {
3598 if (
$rev ===
null ) {
3613 $time = - microtime(
true );
3615 $time += microtime(
true );
3620 $this->
page->getTitle()->getPrefixedDBkey() ) );
3623 if ( $this->cacheable && $this->parserOutput->isCacheable() && $isCurrent ) {
3625 $this->parserOutput, $this->
page, $this->parserOptions, $cacheTime, $this->revid );
3631 if ( !$this->parserOutput->isCacheable() || $this->parserOutput->containsOldMagic() ) {
3632 $wgUseFileCache =
false;
3636 $this->
page->doCascadeProtectionUpdates( $this->parserOutput );
3648 if ( $this->parserOutput ===
false ) {
3649 wfDebug( __METHOD__ .
": parser cache miss\n" );
3652 wfDebug( __METHOD__ .
": parser cache hit\n" );
3663 if ( $this->parserOutput ===
false ) {
3665 wfDebug( __METHOD__ .
": no dirty cache\n" );
3668 wfDebug( __METHOD__ .
": sending dirty output\n" );
3669 wfDebugLog(
'dirty',
"dirty output {$this->cacheKey}" );
3670 $this->isDirty =
true;
3679 public function error( $status ) {
3680 $this->
error = $status;
getContentHandler()
Convenience method that returns the ContentHandler singleton for handling the content model that this...
static deprecated( $func, $version, $component=false)
Logs a deprecation warning, visible if $wgDevelopmentWarnings, but only if self::$enableDeprecationWa...
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
Set options of the Parser.
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
Abstract class for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
see documentation in includes Linker php for Linker::makeImageLink & $time
static onArticleCreate( $title)
The onArticle*() functions are supposed to be a kind of hooks which should be called whenever any of ...
getUserText( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's username if it's available to the specified audience.
insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason)
Insert a new null revision for this page.
pageDataFromId( $dbr, $id, $options=array())
Fetch a page record matching the requested ID.
loadPageData( $from='fromdb')
Set the general counter, title etc data loaded from some source.
static singleton()
Get a RepoGroup instance.
serialize( $format=null)
Convenience method for serializing this Content object.
getAutoDeleteReason(&$hasHistory)
Auto-generates a deletion reason.
doDeleteUpdates( $id, Content $content=null)
Do some database updates after deletion.
doCascadeProtectionUpdates(ParserOutput $parserOutput)
Updates cascading protections.
isBigDeletion()
Check whether the number of revisions of this page surpasses $wgDeleteRevisionsLimit.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
getRedirectTarget()
If this page is a redirect, get its target.
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
per default it will return the text for text based content
clearCacheFields()
Clear the object cache fields.
replaceSectionContent( $section, Content $sectionContent, $sectionTitle='', $edittime=null)
doEditUpdates(Revision $revision, User $user, array $options=array())
Do standard deferred updates after page edit.
getUsedTemplates()
Return a list of templates used by this article.
getUndoContent(Revision $undo, Revision $undoafter=null)
Get the content that needs to be saved in order to undo all revisions between $undo and $undoafter.
updateRevisionOn( $dbw, $revision, $lastRevision=null, $lastRevIsRedirect=null)
Update the page record to point to a newly saved revision.
static runUpdates( $updates)
Convenience method, calls doUpdate() on every DataUpdate in the array.
isValid()
Returns whether the content is valid.
static newNullRevision( $dbw, $pageId, $summary, $minor)
Create a new null-revision for insertion into a page's history.
namespace and then decline to actually register it RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
static notifyEdit( $timestamp, &$title, $minor, &$user, $comment, $oldId, $lastTimestamp, $bot, $ip='', $oldSize=0, $newSize=0, $newId=0, $patrol=0)
Makes an entry in the database corresponding to an edit.
static newFromResult( $res)
doQuickEditContent(Content $content, User $user, $comment='', $minor=false, $serialisation_format=null)
Edit an article without doing all that other stuff The article must already exist; link tables etc ar...
static clearFileCache(Title $title)
Clear the file caches for a page for all actions.
getUser( $audience=Revision::FOR_PUBLIC, User $user=null)
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
doEdit( $text, $summary, $flags=0, $baseRevId=false, $user=null)
Change an existing article or create a new article.
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
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
hasViewableContent()
Check if this page is something we're going to be showing some sort of sensible content for.
setId( $id)
Set the revision ID.
static notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot, $ip='', $size=0, $newId=0, $patrol=0)
Makes an entry in the database corresponding to page creation Note: the title object must be loaded w...
getTouched()
Get the page_touched field.
static getAutosummary( $oldtext, $newtext, $flags)
Return an applicable autosummary if one exists for the given edit.
getContent( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision content if it's available to the specified audience.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static queueRecursiveJobsForTable(Title $title, $table)
Queue a RefreshLinks job for any table.
doViewUpdates(User $user, $oldid=0)
Do standard deferred updates after page view (existing or missing page)
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
return false to override stock group addition can be modified UserArrayFromResult
checkFlags( $flags)
Check flags and add EDIT_NEW or EDIT_UPDATE to them as needed.
wfProfileIn( $functionname)
Begin profiling of a function.
doEditContent(Content $content, $summary, $flags=0, $baseRevId=false, User $user=null, $serialisation_format=null)
Change an existing article or create a new article.
static onArticleEdit( $title)
Purge caches on page update etc.
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 noclasses & $ret
foreach( $res as $row) $serialized
Class representing a MediaWiki article and history.
if(!defined( 'MEDIAWIKI')) wfArrayDiff2( $a, $b)
Like array_diff( $a, $b ) except that it works with two-dimensional arrays.
static newGood( $value=null)
Factory function for good results.
getUserText( $audience=Revision::FOR_PUBLIC, User $user=null)
makeParserOptions( $context)
Get parser options suitable for rendering the primary article wikitext.
__construct(Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $content=null)
Constructor.
getRedirectURL( $rt)
Get the Title object or URL to use for a redirect.
wfReadOnly()
Check whether the wiki is in read-only mode.
wfMsgReplaceArgs( $message, $args)
Replace message parameter keys on the given formatted output.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
getRevision()
Get the latest revision.
getContentHandler()
Returns the content handler appropriate for this revision's content model.
getContributors()
Get a list of users who have edited this article, not including the user who made the most recent rev...
getDeletionUpdates(WikiPage $page, ParserOutput $parserOutput=null)
Returns a list of updates to perform when this content 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 content language as $wgContLang
getComment( $audience=Revision::FOR_PUBLIC, User $user=null)
const CONTENT_MODEL_WIKITEXT
static newFromPageId( $pageId, $revId=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given page ID.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Interface for database access objects.
getContentModel()
Returns the content model for this revision.
insertOn( $dbw)
Insert a new revision into the database, returning the new revision ID number on success and dies hor...
getSize()
Returns the content's nominal size in bogo-bytes.
getActionOverrides()
Returns overrides for action handlers.
static flattenRestrictions( $limit)
Take an array of page restrictions and flatten it to a string suitable for insertion into the page_re...
pageData( $dbr, $conditions, $options=array())
Fetch a page record with the given conditions.
static doUpdates( $commit='')
Do any deferred updates and clear the list.
prepareSave(WikiPage $page, $flags, $baseRevId, User $user)
Prepare Content for saving.
pageDataFromTitle( $dbr, $title, $options=array())
Fetch a page record matching the Title object's namespace and title using a sanitized title string.
prepareTextForEdit( $text, $revid=null, User $user=null)
Prepare text which is about to be saved.
static runLegacyHooks( $event, $args=array(), $warn=null)
Call a legacy hook that uses text instead of Content objects.
static newSimplePurge(Title $title)
protectDescription(array $limit, array $expiry)
Builds the description to serve as comment for the edit.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
ParserOptions $parserOptions
static getLocalizedName( $name)
Returns the localized name for a given content model.
getWikitextForTransclusion()
insertOn( $dbw)
Insert a new empty page record for this article.
ParserOutput bool $parserOutput
supportsSections()
Returns true if this page's content model supports sections.
getRawText()
Get the text of the current revision.
Special handling for category pages.
wfMemcKey()
Get a cache key.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
getMinorEdit()
Returns true if last revision was marked as "minor edit".
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
isParserCacheUsed(ParserOptions $parserOptions, $oldid)
Should the parser cache be used?
doDeleteArticleReal( $reason, $suppress=false, $id=0, $commit=true, &$error='', User $user=null)
Back-end article deletion Deletes the article with database consistency, writes logs,...
updateCategoryCounts(array $added, array $deleted)
Update all the appropriate counts in the category table, given that we've added the categories $added...
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
static newFromRow( $row)
Make a Title object from a DB row.
wfIncrStats( $key, $count=1)
Increment a statistics counter.
static selectFields()
Return the list of revision fields that should be selected to create a new page.
static invalidateCache(Title $title)
Clear the info cache for a given Title.
clearPreparedEdit()
Clear the mPreparedEdit cache field, as may be needed by mutable content types.
doDeleteArticle( $reason, $suppress=false, $id=0, $commit=true, &$error='', User $user=null)
Same as doDeleteArticleReal(), but returns a simple boolean.
insertRedirectEntry( $rt)
Insert or update the redirect table entry for this page to indicate it redirects to $rt .
doUpdateRestrictions(array $limit, array $expiry, &$cascade, $reason, User $user)
Update the article's restriction field, and leave a log entry.
static onArticleDelete( $title)
Clears caches when article is deleted.
static addUpdate(DeferrableUpdate $update)
Add an update to the deferred list.
getTitle()
Get the title object of the article.
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Class to simplify the use of log pages.
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 noclasses 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 and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables 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 unset offset - wrap String Wrap the message in html(usually something like "<
getContent( $audience=Revision::FOR_PUBLIC, User $user=null)
Get the content of the current revision.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
static isIP( $name)
Does the string match an anonymous IPv4 address?
__construct(Title $title)
Constructor and clear the article.
checkTouched()
Loads page_touched and returns a value indicating if it should be used.
getLinksTimestamp()
Get the page_links_updated field.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
prepareContentForEdit(Content $content, $revid=null, User $user=null, $serialization_format=null)
Prepare content which is about to be saved.
when a variable name is used in a it is silently declared as a new masking the global
Update for the 'page_counter' field, when $wgDisableCounters is false.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
setTimestamp( $ts)
Set the page timestamp (use only to avoid DB queries)
getLatest()
Get the page_latest field.
Class for handling updates to the site_stats table.
doPurge()
Perform the actions of a page purging.
isCountable( $editInfo=false)
Determine whether a page would be suitable for being counted as an article in the site_stats table ba...
processing should stop and the error should be shown to the user * false
static singleton()
Get the signleton instance of this class.
getContentModel()
Returns the page's content model id (see the CONTENT_MODEL_XXX constants).
getPrevious()
Get previous revision for this title.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
replaceSection( $section, $text, $sectionTitle='', $edittime=null)
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 & $options
updateIfNewerOn( $dbw, $revision)
If the given revision is newer than the currently set page_latest, update the page record.
setLastEdit(Revision $revision)
Set the latest revision.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
static newFromTitle( $title, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given title.
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Class to invalidate the HTML cache of all the pages linking to a given title.
getError()
Get a Status object in case of error or false otherwise.
equals(Content $that=null)
Returns true if this Content objects is conceptually equivalent to the given Content object.
getLastNAuthors( $num, $revLatest=0)
Get the last N authors.
static record( $rc, $auto=false, User $user=null)
Record a log event for a change being patrolled.
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 & $sectionContent
presenting them properly to the user as errors is done by the caller $title
static addHTMLCacheUpdate( $title, $table)
HTMLCacheUpdates are the most common deferred update people use.
protectDescriptionLog(array $limit, array $expiry)
Builds the description to serve as comment for the log entry.
static singleton()
Get an instance of this object.
insertRedirect()
Insert an entry for this page into the redirect table.
getCreator( $audience=Revision::FOR_PUBLIC, User $user=null)
Get the User object of the user who created the page.
getSecondaryDataUpdates(Title $title, Content $old=null, $recursive=true, ParserOutput $parserOutput=null)
Returns a list of DataUpdate objects for recording information about this Content in some secondary d...
static newFromID( $id, $from='fromdb')
Constructor from a page id.
updateRestrictions( $limit=array(), $reason='', &$cascade=0, $expiry=array(), User $user=null)
Update the article's restriction field, and leave a log entry.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
getHiddenCategories()
Returns a list of hidden categories this page is a member of.
static newFromRow( $row, $from='fromdb')
Constructor from a database row.
getOldestRevision()
Get the Revision object of the oldest revision.
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 account $user
loadLastEdit()
Loads everything except the text This isn't necessary for all uses, so it's only done if needed.
getText( $audience=Revision::FOR_PUBLIC, User $user=null)
Get the text of the current revision.
followRedirect()
Get the Title object or URL this page redirects to.
preSaveTransform(Title $title, User $user, ParserOptions $parserOptions)
Returns a Content object with pre-save transformations applied (or this object if no transformations ...
Base interface for content objects.
loadFromRow( $data, $from)
Load the object from a database row.
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
doQuickEdit( $text, User $user, $comment='', $minor=0)
Edit an article without doing all that other stuff The article must already exist; link tables etc ar...
Represents a title within MediaWiki.
wfRandom()
Get a random decimal value between 0 and 1, in a way not likely to give duplicate values for any real...
static getContentText(Content $content=null)
Convenience function for getting flat text from a Content object.
isAllowedAny()
Check if user is allowed to access a feature / make an action.
wfReadOnlyReason()
Get the value of $wgReadOnly or the contents of $wgReadOnlyFile.
int
one of the READ_* constants
commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser)
Backend implementation of doRollback(), please refer there for parameter and return value documentati...
getUndoText(Revision $undo, Revision $undoafter=null)
Get the text that needs to be saved in order to undo all revisions between $undo and $undoafter.
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
static purgeExpiredChanges()
Purge expired changes from the recentchanges table.
static loadFromTimestamp( $db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
static convertSelectType( $type)
Convert 'fromdb', 'fromdbmaster' and 'forupdate' to READ_* constants.
if(PHP_SAPI !='cli') $source
Class for dealing with PoolCounters using class members.
getModel()
Returns the ID of the content model used by this Content object.
Class for creating log entries manually, for example to inject them into the database.
getCachedLastEditTime()
Get the cached timestamp for the last time the page changed.
string
timestamp of the current revision or empty string if not loaded
getParserOutput()
Get the ParserOutput from this object, or false in case of failure.
Special handling for file pages.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
static newFromName( $name)
Factory function.
preSaveTransform( $text, User $user=null, ParserOptions $popts=null)
This function is called right before saving the wikitext, so we can do things like signatures and lin...
estimateRevisionCount()
Get the approximate revision count of this page.
doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user)
Roll back the most recent consecutive set of edits to a page from the same user; fails if there are n...
getParserOutput(Title $title, $revId=null, ParserOptions $options=null, $generateHtml=true)
Parse the Content object and generate a ParserOutput from the result.
updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect=null)
Add row to the redirect table if this is a redirect, remove otherwise.
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
isRedirect()
Tests if the article content represents a redirect.
setCachedLastEditTime( $timestamp)
Set the cached timestamp for the last time the page changed.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getDeletionUpdates(Content $content=null)
Returns a list of updates to be performed when this page is deleted.
static & singleton()
Get an instance of this class.
getContentHandler()
Returns the ContentHandler instance to be used to deal with the content of this WikiPage.
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 account incomplete not yet checked for validity & $retval
getIsDirty()
Get whether the ParserOutput is a dirty one (i.e.
static purgeExpiredRestrictions()
Purge expired restrictions from the page_restrictions table.
getParserOutput(ParserOptions $parserOptions, $oldid=null)
Get a ParserOutput for the given ParserOptions and revision ID.
static newFromUser( $user)
Get a ParserOptions object from a given user.
isAllowed( $action='')
Internal mechanics of testing a permission.
static newFatal( $message)
Factory function for fatal errors.
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 my talk page