2 # Class representing a Wikipedia article and history.
3 # See design.doc for an overview.
5 # Note: edit user interface and cache support functions have been
6 # moved to separate EditPage and CacheManager classes.
8 include_once( "CacheManager.php" );
11 /* private */ var $mContent, $mContentLoaded;
12 /* private */ var $mUser, $mTimestamp, $mUserText;
13 /* private */ var $mCounter, $mComment, $mCountAdjustment;
14 /* private */ var $mMinorEdit, $mRedirectedFrom;
15 /* private */ var $mTouched, $mFileCache, $mTitle;
16 /* private */ var $mId, $mTable;
18 function Article( &$title ) {
19 $this->mTitle
=& $title;
23 /* private */ function clear()
25 $this->mContentLoaded
= false;
26 $this->mCurID
= $this->mUser
= $this->mCounter
= -1; # Not loaded
27 $this->mRedirectedFrom
= $this->mUserText
=
28 $this->mTimestamp
= $this->mComment
= $this->mFileCache
= "";
29 $this->mCountAdjustment
= 0;
30 $this->mTouched
= "19700101000000";
33 /* static */ function getRevisionText( $row, $prefix = "old_" ) {
34 # Deal with optional compression of archived pages.
35 # This can be done periodically via maintenance/compressOld.php, and
36 # as pages are saved if $wgCompressRevisions is set.
37 $text = $prefix . "text";
38 $flags = $prefix . "flags";
39 if( isset( $row->$flags ) && (false !== strpos( $row->$flags, "gzip" ) ) ) {
40 return gzinflate( $row->$text );
42 if( isset( $row->$text ) ) {
48 /* static */ function compressRevisionText( &$text ) {
49 global $wgCompressRevisions;
50 if( !$wgCompressRevisions ) {
53 if( !function_exists( "gzdeflate" ) ) {
54 wfDebug( "Article::compressRevisionText() -- no zlib support, not compressing\n" );
57 $text = gzdeflate( $text );
61 # Note that getContent/loadContent may follow redirects if
62 # not told otherwise, and so may cause a change to mTitle.
64 # Return the text of this revision
65 function getContent( $noredir = false )
69 # Get variables from query string :P
70 $action = $wgRequest->getText( 'action', 'view' );
71 $section = $wgRequest->getText( 'section' );
73 $fname = "Article::getContent";
74 wfProfileIn( $fname );
76 if ( 0 == $this->getID() ) {
77 if ( "edit" == $action ) {
78 wfProfileOut( $fname );
79 return ""; # was "newarticletext", now moved above the box)
81 wfProfileOut( $fname );
82 return wfMsg( "noarticletext" );
84 $this->loadContent( $noredir );
87 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
88 ( $this->mTitle
->getNamespace() == Namespace::getTalk( Namespace::getUser()) ) &&
89 preg_match("/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/",$this->mTitle
->getText()) &&
93 wfProfileOut( $fname );
94 return $this->mContent
. "\n" .wfMsg("anontalkpagetext"); }
99 wfProfileOut( $fname );
103 $secs=preg_split("/(^=+.*?=+|^<h[1-6].*?>.*?<\/h[1-6].*?>)/mi",
105 PREG_SPLIT_DELIM_CAPTURE
);
107 wfProfileOut( $fname );
108 return trim($secs[0]);
110 wfProfileOut( $fname );
111 return trim($secs[$section*2-1] . $secs[$section*2]);
115 wfProfileOut( $fname );
116 return $this->mContent
;
121 # Load the revision (including cur_text) into this object
122 function loadContent( $noredir = false )
124 global $wgOut, $wgMwRedir, $wgRequest;
127 $oldid = $wgRequest->getVal( 'oldid' );
128 $redirect = $wgRequest->getVal( 'redirect' );
130 if ( $this->mContentLoaded
) return;
131 $fname = "Article::loadContent";
133 # Pre-fill content with error message so that if something
134 # fails we'll have something telling us what we intended.
136 $t = $this->mTitle
->getPrefixedText();
137 if ( isset( $oldid ) ) {
138 $oldid = IntVal( $oldid );
139 $t .= ",oldid={$oldid}";
141 if ( isset( $redirect ) ) {
142 $redirect = ($redirect == "no") ?
"no" : "yes";
143 $t .= ",redirect={$redirect}";
145 $this->mContent
= wfMsg( "missingarticle", $t );
147 if ( ! $oldid ) { # Retrieve current version
148 $id = $this->getID();
149 if ( 0 == $id ) return;
152 "cur_text,cur_timestamp,cur_user,cur_counter,cur_restrictions,cur_touched " .
153 "FROM cur WHERE cur_id={$id}";
155 $res = wfQuery( $sql, DB_READ
, $fname );
156 if ( 0 == wfNumRows( $res ) ) {
160 $s = wfFetchObject( $res );
161 # If we got a redirect, follow it (unless we've been told
162 # not to by either the function parameter or the query
163 if ( ( "no" != $redirect ) && ( false == $noredir ) &&
164 ( $wgMwRedir->matchStart( $s->cur_text
) ) ) {
165 if ( preg_match( "/\\[\\[([^\\]\\|]+)[\\]\\|]/",
166 $s->cur_text
, $m ) ) {
167 $rt = Title
::newFromText( $m[1] );
169 # Gotta hand redirects to special pages differently:
170 # Fill the HTTP response "Location" header and ignore
171 # the rest of the page we're on.
173 if ( $rt->getInterwiki() != "" ) {
174 $wgOut->redirect( $rt->getFullURL() ) ;
177 if ( $rt->getNamespace() == Namespace::getSpecial() ) {
178 $wgOut->redirect( $rt->getFullURL() );
181 $rid = $rt->getArticleID();
183 $sql = "SELECT cur_text,cur_timestamp,cur_user," .
184 "cur_counter,cur_restrictions,cur_touched FROM cur WHERE cur_id={$rid}";
185 $res = wfQuery( $sql, DB_READ
, $fname );
187 if ( 0 != wfNumRows( $res ) ) {
188 $this->mRedirectedFrom
= $this->mTitle
->getPrefixedText();
190 $s = wfFetchObject( $res );
197 $this->mContent
= $s->cur_text
;
198 $this->mUser
= $s->cur_user
;
199 $this->mCounter
= $s->cur_counter
;
200 $this->mTimestamp
= $s->cur_timestamp
;
201 $this->mTouched
= $s->cur_touched
;
202 $this->mTitle
->mRestrictions
= explode( ",", trim( $s->cur_restrictions
) );
203 $this->mTitle
->mRestrictionsLoaded
= true;
204 wfFreeResult( $res );
205 } else { # oldid set, retrieve historical version
206 $sql = "SELECT old_text,old_timestamp,old_user,old_flags FROM old " .
207 "WHERE old_id={$oldid}";
208 $res = wfQuery( $sql, DB_READ
, $fname );
209 if ( 0 == wfNumRows( $res ) ) { return; }
211 $s = wfFetchObject( $res );
212 $this->mContent
= Article
::getRevisionText( $s );
213 $this->mUser
= $s->old_user
;
215 $this->mTimestamp
= $s->old_timestamp
;
216 wfFreeResult( $res );
218 $this->mContentLoaded
= true;
219 return $this->mContent
;
222 # Gets the article text without using so many damn globals
223 # Returns false on error
224 function getContentWithoutUsingSoManyDamnGlobals( $oldid = 0, $noredir = false ) {
227 if ( $this->mContentLoaded
) {
228 return $this->mContent
;
230 $this->mContent
= false;
232 $fname = "Article::loadContent";
234 if ( ! $oldid ) { # Retrieve current version
235 $id = $this->getID();
241 "cur_text,cur_timestamp,cur_user,cur_counter,cur_restrictions,cur_touched " .
242 "FROM cur WHERE cur_id={$id}";
243 $res = wfQuery( $sql, DB_READ
, $fname );
244 if ( 0 == wfNumRows( $res ) ) {
248 $s = wfFetchObject( $res );
249 # If we got a redirect, follow it (unless we've been told
250 # not to by either the function parameter or the query
251 if ( !$noredir && $wgMwRedir->matchStart( $s->cur_text
) ) {
252 if ( preg_match( "/\\[\\[([^\\]\\|]+)[\\]\\|]/",
253 $s->cur_text
, $m ) ) {
254 $rt = Title
::newFromText( $m[1] );
255 if( $rt && $rt->getInterwiki() == "" && $rt->getNamespace() != Namespace::getSpecial() ) {
256 $rid = $rt->getArticleID();
258 $sql = "SELECT cur_text,cur_timestamp,cur_user," .
259 "cur_counter,cur_restrictions,cur_touched FROM cur WHERE cur_id={$rid}";
260 $res = wfQuery( $sql, DB_READ
, $fname );
262 if ( 0 != wfNumRows( $res ) ) {
263 $this->mRedirectedFrom
= $this->mTitle
->getPrefixedText();
265 $s = wfFetchObject( $res );
272 $this->mContent
= $s->cur_text
;
273 $this->mUser
= $s->cur_user
;
274 $this->mCounter
= $s->cur_counter
;
275 $this->mTimestamp
= $s->cur_timestamp
;
276 $this->mTouched
= $s->cur_touched
;
277 $this->mTitle
->mRestrictions
= explode( ",", trim( $s->cur_restrictions
) );
278 $this->mTitle
->mRestrictionsLoaded
= true;
279 wfFreeResult( $res );
280 } else { # oldid set, retrieve historical version
281 $sql = "SELECT old_text,old_timestamp,old_user,old_flags FROM old " .
282 "WHERE old_id={$oldid}";
283 $res = wfQuery( $sql, DB_READ
, $fname );
284 if ( 0 == wfNumRows( $res ) ) {
288 $s = wfFetchObject( $res );
289 $this->mContent
= Article
::getRevisionText( $s );
290 $this->mUser
= $s->old_user
;
292 $this->mTimestamp
= $s->old_timestamp
;
293 wfFreeResult( $res );
295 $this->mContentLoaded
= true;
296 return $this->mContent
;
300 if( $this->mTitle
) {
301 return $this->mTitle
->getArticleID();
309 if ( -1 == $this->mCounter
) {
310 $id = $this->getID();
311 $this->mCounter
= wfGetSQL( "cur", "cur_counter", "cur_id={$id}" );
313 return $this->mCounter
;
316 # Would the given text make this article a "good" article (i.e.,
317 # suitable for including in the article count)?
319 function isCountable( $text )
321 global $wgUseCommaCount, $wgMwRedir;
323 if ( 0 != $this->mTitle
->getNamespace() ) { return 0; }
324 if ( $wgMwRedir->matchStart( $text ) ) { return 0; }
325 $token = ($wgUseCommaCount ?
"," : "[[" );
326 if ( false === strstr( $text, $token ) ) { return 0; }
330 # Loads everything from cur except cur_text
331 # This isn't necessary for all uses, so it's only done if needed.
333 /* private */ function loadLastEdit()
336 if ( -1 != $this->mUser
) return;
338 $sql = "SELECT cur_user,cur_user_text,cur_timestamp," .
339 "cur_comment,cur_minor_edit FROM cur WHERE " .
340 "cur_id=" . $this->getID();
341 $res = wfQuery( $sql, DB_READ
, "Article::loadLastEdit" );
343 if ( wfNumRows( $res ) > 0 ) {
344 $s = wfFetchObject( $res );
345 $this->mUser
= $s->cur_user
;
346 $this->mUserText
= $s->cur_user_text
;
347 $this->mTimestamp
= $s->cur_timestamp
;
348 $this->mComment
= $s->cur_comment
;
349 $this->mMinorEdit
= $s->cur_minor_edit
;
353 function getTimestamp()
355 $this->loadLastEdit();
356 return $this->mTimestamp
;
361 $this->loadLastEdit();
365 function getUserText()
367 $this->loadLastEdit();
368 return $this->mUserText
;
371 function getComment()
373 $this->loadLastEdit();
374 return $this->mComment
;
377 function getMinorEdit()
379 $this->loadLastEdit();
380 return $this->mMinorEdit
;
383 function getContributors($limit = 0, $offset = 0)
385 # XXX: this is expensive; cache this info somewhere.
387 $title = $this->mTitle
;
391 $res = wfQuery("SELECT DISTINCT old.old_user, old.old_user_text, user.user_real_name " .
393 " WHERE old.old_user = user.user_id " .
394 " AND old.old_namespace = " . $title->getNamespace() .
395 " AND old.old_title = '" . $title->getDBkey() . "'" .
396 " AND old.old_user != 0 " .
397 " AND old.old_user != " . $this->getUser(), DB_READ
);
399 while ( $line = wfFetchObject( $res ) ) {
400 $contribs[$line->old_user
] = array($line->old_user_text
, $line->user_real_name
);
403 # Count anonymous users
405 $res = wfQuery("SELECT COUNT(*) AS cnt " .
407 " WHERE old_namespace = " . $title->getNamespace() .
408 " AND old_title = '" . $title->getDBkey() . "'" .
409 " AND old_user = 0 ", DB_READ
);
411 while ( $line = wfFetchObject( $res ) ) {
412 $contribs[0] = array($line->cnt
, 'Anonymous');
418 # This is the default action of the script: just view the page of
423 global $wgUser, $wgOut, $wgLang, $wgRequest;
424 global $wgLinkCache, $IP, $wgEnableParserCache;
426 $fname = "Article::view";
427 wfProfileIn( $fname );
429 # Get variables from query string :P
430 $oldid = $wgRequest->getVal( 'oldid' );
431 $diff = $wgRequest->getVal( 'diff' );
433 $wgOut->setArticleFlag( true );
434 $wgOut->setRobotpolicy( "index,follow" );
436 # If we got diff and oldid in the query, we want to see a
437 # diff page instead of the article.
439 if ( !is_null( $diff ) ) {
440 $wgOut->setPageTitle( $this->mTitle
->getPrefixedText() );
441 $de = new DifferenceEngine( intval($oldid), intval($diff) );
443 wfProfileOut( $fname );
447 if ( !is_null( $oldid ) and $this->checkTouched() ) {
448 if( $wgOut->checkLastModified( $this->mTouched
) ){
450 } else if ( $this->tryFileCache() ) {
451 # tell wgOut that output is taken care of
453 $this->viewUpdates();
458 $text = $this->getContent(); # May change mTitle
459 $wgOut->setPageTitle( $this->mTitle
->getPrefixedText() );
460 $wgOut->setHTMLTitle( $this->mTitle
->getPrefixedText() .
461 " - " . wfMsg( "wikititlesuffix" ) );
463 # We're looking at an old revision
465 if ( !empty( $oldid ) ) {
466 $this->setOldSubtitle();
467 $wgOut->setRobotpolicy( "noindex,follow" );
469 if ( "" != $this->mRedirectedFrom
) {
470 $sk = $wgUser->getSkin();
471 $redir = $sk->makeKnownLink( $this->mRedirectedFrom
, "",
473 $s = wfMsg( "redirectedfrom", $redir );
474 $wgOut->setSubtitle( $s );
477 $wgLinkCache->preFill( $this->mTitle
);
479 if( $wgEnableParserCache && intval($wgUser->getOption( "stubthreshold" )) == 0 ){
480 $wgOut->addWikiText( $text, true, $this );
482 $wgOut->addWikiText( $text );
485 # Add link titles as META keywords
486 $wgOut->addMetaTags() ;
488 $this->viewUpdates();
489 wfProfileOut( $fname );
492 # Theoretically we could defer these whole insert and update
493 # functions for after display, but that's taking a big leap
494 # of faith, and we want to be able to report database
495 # errors at some point.
497 /* private */ function insertNewArticle( $text, $summary, $isminor, $watchthis )
499 global $wgOut, $wgUser, $wgLinkCache, $wgMwRedir;
500 global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer;
502 $fname = "Article::insertNewArticle";
504 $this->mCountAdjustment
= $this->isCountable( $text );
506 $ns = $this->mTitle
->getNamespace();
507 $ttl = $this->mTitle
->getDBkey();
508 $text = $this->preSaveTransform( $text );
509 if ( $wgMwRedir->matchStart( $text ) ) { $redir = 1; }
512 $now = wfTimestampNow();
513 $won = wfInvertTimestamp( $now );
515 $rand = number_format( mt_rand() / mt_getrandmax(), 12, ".", "" );
516 $isminor = ( $isminor && $wgUser->getID() ) ?
1 : 0;
517 $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
518 "cur_comment,cur_user,cur_timestamp,cur_minor_edit,cur_counter," .
519 "cur_restrictions,cur_user_text,cur_is_redirect," .
520 "cur_is_new,cur_random,cur_touched,inverse_timestamp) VALUES ({$ns},'" . wfStrencode( $ttl ) . "', '" .
521 wfStrencode( $text ) . "', '" .
522 wfStrencode( $summary ) . "', '" .
523 $wgUser->getID() . "', '{$now}', " .
524 $isminor . ", 0, '', '" .
525 wfStrencode( $wgUser->getName() ) . "', $redir, 1, $rand, '{$now}', '{$won}')";
526 $res = wfQuery( $sql, DB_WRITE
, $fname );
528 $newid = wfInsertId();
529 $this->mTitle
->resetArticleID( $newid );
531 Article
::onArticleCreate( $this->mTitle
);
532 RecentChange
::notifyNew( $now, $this->mTitle
, $isminor, $wgUser, $summary );
535 if(!$this->mTitle
->userIsWatching()) $this->watch();
537 if ( $this->mTitle
->userIsWatching() ) {
542 # The talk page isn't in the regular link tables, so we need to update manually:
543 $talkns = $ns ^
1; # talk -> normal; normal -> talk
544 $sql = "UPDATE cur set cur_touched='$now' WHERE cur_namespace=$talkns AND cur_title='" . wfStrencode( $ttl ) . "'";
545 wfQuery( $sql, DB_WRITE
);
547 # standard deferred updates
548 $this->editUpdates( $text );
550 $this->showArticle( $text, wfMsg( "newarticle" ) );
554 /* Side effects: loads last edit */
555 function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = ""){
556 $this->loadLastEdit();
557 $oldtext = $this->getContent();
558 if ($section != "") {
559 if($section=="new") {
560 if($summary) $subject="== {$summary} ==\n\n";
561 $text=$oldtext."\n\n".$subject.$text;
563 $secs=preg_split("/(^=+.*?=+|^<h[1-6].*?>.*?<\/h[1-6].*?>)/mi",
564 $oldtext,-1,PREG_SPLIT_DELIM_CAPTURE
);
565 $secs[$section*2]=$text."\n\n"; // replace with edited
566 if($section) { $secs[$section*2-1]=""; } // erase old headline
567 $text=join("",$secs);
573 function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false )
575 global $wgOut, $wgUser, $wgLinkCache;
576 global $wgDBtransactions, $wgMwRedir;
577 global $wgUseSquid, $wgInternalServer;
578 $fname = "Article::updateArticle";
580 if ( $this->mMinorEdit
) { $me1 = 1; } else { $me1 = 0; }
581 if ( $minor && $wgUser->getID() ) { $me2 = 1; } else { $me2 = 0; }
582 if ( preg_match( "/^((" . $wgMwRedir->getBaseRegex() . ")[^\\n]+)/i", $text, $m ) ) {
584 $text = $m[1] . "\n"; # Remove all content but redirect
588 $text = $this->preSaveTransform( $text );
590 # Update article, but only if changed.
592 if( $wgDBtransactions ) {
594 wfQuery( $sql, DB_WRITE
);
596 $oldtext = $this->getContent( true );
598 if ( 0 != strcmp( $text, $oldtext ) ) {
599 $this->mCountAdjustment
= $this->isCountable( $text )
600 - $this->isCountable( $oldtext );
602 $now = wfTimestampNow();
603 $won = wfInvertTimestamp( $now );
604 $sql = "UPDATE cur SET cur_text='" . wfStrencode( $text ) .
605 "',cur_comment='" . wfStrencode( $summary ) .
606 "',cur_minor_edit={$me2}, cur_user=" . $wgUser->getID() .
607 ",cur_timestamp='{$now}',cur_user_text='" .
608 wfStrencode( $wgUser->getName() ) .
609 "',cur_is_redirect={$redir}, cur_is_new=0, cur_touched='{$now}', inverse_timestamp='{$won}' " .
610 "WHERE cur_id=" . $this->getID() .
611 " AND cur_timestamp='" . $this->getTimestamp() . "'";
612 $res = wfQuery( $sql, DB_WRITE
, $fname );
614 if( wfAffectedRows() == 0 ) {
615 /* Belated edit conflict! Run away!! */
619 # This overwrites $oldtext if revision compression is on
620 $flags = Article
::compressRevisionText( $oldtext );
622 $sql = "INSERT INTO old (old_namespace,old_title,old_text," .
623 "old_comment,old_user,old_user_text,old_timestamp," .
624 "old_minor_edit,inverse_timestamp,old_flags) VALUES (" .
625 $this->mTitle
->getNamespace() . ", '" .
626 wfStrencode( $this->mTitle
->getDBkey() ) . "', '" .
627 wfStrencode( $oldtext ) . "', '" .
628 wfStrencode( $this->getComment() ) . "', " .
629 $this->getUser() . ", '" .
630 wfStrencode( $this->getUserText() ) . "', '" .
631 $this->getTimestamp() . "', " . $me1 . ", '" .
632 wfInvertTimestamp( $this->getTimestamp() ) . "','$flags')";
633 $res = wfQuery( $sql, DB_WRITE
, $fname );
634 $oldid = wfInsertID( $res );
636 $bot = (int)($wgUser->isBot() ||
$forceBot);
637 RecentChange
::notifyEdit( $now, $this->mTitle
, $me2, $wgUser, $summary,
638 $oldid, $this->getTimestamp(), $bot );
639 Article
::onArticleEdit( $this->mTitle
);
642 if( $wgDBtransactions ) {
644 wfQuery( $sql, DB_WRITE
);
648 if (!$this->mTitle
->userIsWatching()) $this->watch();
650 if ( $this->mTitle
->userIsWatching() ) {
654 # standard deferred updates
655 $this->editUpdates( $text );
660 # Purge all articles linking here
661 if ( $this->mTitle
->getNamespace() == NS_TEMPLATE
) {
662 $titles = $this->mTitle
->getLinksTo();
663 Title
::touchArray( $titles );
665 foreach ( $titles as $title ) {
666 $urls[] = $title->getInternalURL();
673 $urls = array_merge( $urls, $this->mTitle
->getSquidURLs() );
674 $u = new SquidUpdate( $urls );
678 $this->showArticle( $text, wfMsg( "updated" ) );
682 # After we've either updated or inserted the article, update
683 # the link tables and redirect to the new page.
685 function showArticle( $text, $subtitle )
687 global $wgOut, $wgUser, $wgLinkCache;
690 $wgLinkCache = new LinkCache();
692 # Get old version of link table to allow incremental link updates
693 $wgLinkCache->preFill( $this->mTitle
);
694 $wgLinkCache->clear();
696 # Now update the link cache by parsing the text
697 $wgOut = new OutputPage();
698 $wgOut->addWikiText( $text );
700 if( $wgMwRedir->matchStart( $text ) )
704 $wgOut->redirect( $this->mTitle
->getFullURL( $r ) );
707 # Add this page to my watchlist
709 function watch( $add = true )
711 global $wgUser, $wgOut, $wgLang;
712 global $wgDeferredUpdateList;
714 if ( 0 == $wgUser->getID() ) {
715 $wgOut->errorpage( "watchnologin", "watchnologintext" );
718 if ( wfReadOnly() ) {
719 $wgOut->readOnlyPage();
723 $wgUser->addWatch( $this->mTitle
);
725 $wgUser->removeWatch( $this->mTitle
);
727 $wgOut->setPagetitle( wfMsg( $add ?
"addedwatch" : "removedwatch" ) );
728 $wgOut->setRobotpolicy( "noindex,follow" );
730 $sk = $wgUser->getSkin() ;
731 $link = $this->mTitle
->getPrefixedText();
734 $text = wfMsg( "addedwatchtext", $link );
736 $text = wfMsg( "removedwatchtext", $link );
737 $wgOut->addWikiText( $text );
739 $up = new UserUpdate();
740 array_push( $wgDeferredUpdateList, $up );
742 $wgOut->returnToMain( false );
747 $this->watch( false );
750 function protect( $limit = "sysop" )
752 global $wgUser, $wgOut, $wgRequest;
754 if ( ! $wgUser->isSysop() ) {
755 $wgOut->sysopRequired();
758 if ( wfReadOnly() ) {
759 $wgOut->readOnlyPage();
762 $id = $this->mTitle
->getArticleID();
764 $wgOut->fatalEror( wfMsg( "badarticleerror" ) );
768 $confirm = $wgRequest->getBool( 'wpConfirmProtect' ) && $wgRequest->wasPosted();
769 $reason = $wgRequest->getText( 'wpReasonProtect' );
773 $sql = "UPDATE cur SET cur_touched='" . wfTimestampNow() . "'," .
774 "cur_restrictions='{$limit}' WHERE cur_id={$id}";
775 wfQuery( $sql, DB_WRITE
, "Article::protect" );
777 $log = new LogPage( wfMsg( "protectlogpage" ), wfMsg( "protectlogtext" ) );
778 if ( $limit === "" ) {
779 $log->addEntry( wfMsg( "unprotectedarticle", $this->mTitle
->getPrefixedText() ), $reason );
781 $log->addEntry( wfMsg( "protectedarticle", $this->mTitle
->getPrefixedText() ), $reason );
783 $wgOut->redirect( $this->mTitle
->getFullURL() );
786 $reason = htmlspecialchars( wfMsg( "protectreason" ) );
787 return $this->confirmProtect( "", $reason, $limit );
791 # Output protection confirmation dialog
792 function confirmProtect( $par, $reason, $limit = "sysop" )
796 wfDebug( "Article::confirmProtect\n" );
798 $sub = htmlspecialchars( $this->mTitle
->getPrefixedText() );
799 $wgOut->setRobotpolicy( "noindex,nofollow" );
804 if ( $limit === "" ) {
805 $wgOut->setSubtitle( wfMsg( "unprotectsub", $sub ) );
806 $wgOut->addWikiText( wfMsg( "confirmunprotecttext" ) );
807 $check = htmlspecialchars( wfMsg( "confirmunprotect" ) );
808 $protcom = htmlspecialchars( wfMsg( "unprotectcomment" ) );
809 $formaction = $this->mTitle
->escapeLocalURL( "action=unprotect" . $par );
811 $wgOut->setSubtitle( wfMsg( "protectsub", $sub ) );
812 $wgOut->addWikiText( wfMsg( "confirmprotecttext" ) );
813 $check = htmlspecialchars( wfMsg( "confirmprotect" ) );
814 $protcom = htmlspecialchars( wfMsg( "protectcomment" ) );
815 $formaction = $this->mTitle
->escapeLocalURL( "action=protect" . $par );
818 $confirm = htmlspecialchars( wfMsg( "confirm" ) );
821 <form id='protectconfirm' method='post' action=\"{$formaction}\">
825 <label for='wpReasonProtect'>{$protcom}:</label>
828 <input type='text' size='60' name='wpReasonProtect' id='wpReasonProtect' value=\"" . htmlspecialchars( $reason ) . "\" />
836 <input type='checkbox' name='wpConfirmProtect' value='1' id='wpConfirmProtect' />
839 <label for='wpConfirmProtect'>{$check}</label>
845 <input type='submit' name='wpConfirmProtectB' value=\"{$confirm}\" />
851 $wgOut->returnToMain( false );
856 return $this->protect( "" );
859 # UI entry point for page deletion
862 global $wgUser, $wgOut, $wgMessageCache, $wgRequest;
863 $fname = "Article::delete";
864 $confirm = $wgRequest->getBool( 'wpConfirm' ) && $wgRequest->wasPosted();
865 $reason = $wgRequest->getText( 'wpReason' );
867 # This code desperately needs to be totally rewritten
870 if ( ( ! $wgUser->isSysop() ) ) {
871 $wgOut->sysopRequired();
874 if ( wfReadOnly() ) {
875 $wgOut->readOnlyPage();
879 # Better double-check that it hasn't been deleted yet!
880 $wgOut->setPagetitle( wfMsg( "confirmdelete" ) );
881 if ( ( "" == trim( $this->mTitle
->getText() ) )
882 or ( $this->mTitle
->getArticleId() == 0 ) ) {
883 $wgOut->fatalError( wfMsg( "cannotdelete" ) );
888 $this->doDelete( $reason );
892 # determine whether this page has earlier revisions
893 # and insert a warning if it does
894 # we select the text because it might be useful below
895 $ns = $this->mTitle
->getNamespace();
896 $title = $this->mTitle
->getDBkey();
897 $etitle = wfStrencode( $title );
898 $sql = "SELECT old_text,old_flags FROM old WHERE old_namespace=$ns and old_title='$etitle' ORDER BY inverse_timestamp LIMIT 1";
899 $res = wfQuery( $sql, DB_READ
, $fname );
900 if( ($old=wfFetchObject($res)) && !$confirm ) {
901 $skin=$wgUser->getSkin();
902 $wgOut->addHTML("<b>".wfMsg("historywarning"));
903 $wgOut->addHTML( $skin->historyLink() ."</b>");
906 $sql="SELECT cur_text FROM cur WHERE cur_namespace=$ns and cur_title='$etitle'";
907 $res=wfQuery($sql, DB_READ
, $fname);
908 if( ($s=wfFetchObject($res))) {
910 # if this is a mini-text, we can paste part of it into the deletion reason
912 #if this is empty, an earlier revision may contain "useful" text
914 if($s->cur_text
!="") {
918 $text = Article
::getRevisionText( $old );
924 $length=strlen($text);
926 # this should not happen, since it is not possible to store an empty, new
927 # page. Let's insert a standard text in case it does, though
928 if($length == 0 && $reason === "") {
929 $reason = wfMsg("exblank");
932 if($length < 500 && $reason === "") {
934 # comment field=255, let's grep the first 150 to have some user
936 $text=substr($text,0,150);
937 # let's strip out newlines and HTML tags
938 $text=preg_replace("/\"/","'",$text);
939 $text=preg_replace("/\</","<",$text);
940 $text=preg_replace("/\>/",">",$text);
941 $text=preg_replace("/[\n\r]/","",$text);
943 $reason=wfMsg("excontent"). " '".$text;
945 $reason=wfMsg("exbeforeblank") . " '".$text;
947 if($length>150) { $reason .= "..."; } # we've only pasted part of the text
952 return $this->confirmDelete( "", $reason );
955 # Output deletion confirmation dialog
956 function confirmDelete( $par, $reason )
960 wfDebug( "Article::confirmDelete\n" );
962 $sub = htmlspecialchars( $this->mTitle
->getPrefixedText() );
963 $wgOut->setSubtitle( wfMsg( "deletesub", $sub ) );
964 $wgOut->setRobotpolicy( "noindex,nofollow" );
965 $wgOut->addWikiText( wfMsg( "confirmdeletetext" ) );
967 $formaction = $this->mTitle
->escapeLocalURL( "action=delete" . $par );
969 $confirm = htmlspecialchars( wfMsg( "confirm" ) );
970 $check = htmlspecialchars( wfMsg( "confirmcheck" ) );
971 $delcom = htmlspecialchars( wfMsg( "deletecomment" ) );
974 <form id='deleteconfirm' method='post' action=\"{$formaction}\">
978 <label for='wpReason'>{$delcom}:</label>
981 <input type='text' size='60' name='wpReason' id='wpReason' value=\"" . htmlspecialchars( $reason ) . "\" />
989 <input type='checkbox' name='wpConfirm' value='1' id='wpConfirm' />
992 <label for='wpConfirm'>{$check}</label>
998 <input type='submit' name='wpConfirmB' value=\"{$confirm}\" />
1004 $wgOut->returnToMain( false );
1007 # Perform a deletion and output success or failure messages
1008 function doDelete( $reason )
1010 global $wgOut, $wgUser, $wgLang;
1011 $fname = "Article::doDelete";
1012 wfDebug( "$fname\n" );
1014 if ( $this->doDeleteArticle( $reason ) ) {
1015 $deleted = $this->mTitle
->getPrefixedText();
1017 $wgOut->setPagetitle( wfMsg( "actioncomplete" ) );
1018 $wgOut->setRobotpolicy( "noindex,nofollow" );
1020 $sk = $wgUser->getSkin();
1021 $loglink = $sk->makeKnownLink( $wgLang->getNsText(
1022 Namespace::getWikipedia() ) .
1023 ":" . wfMsg( "dellogpage" ), wfMsg( "deletionlog" ) );
1025 $text = wfMsg( "deletedtext", $deleted, $loglink );
1027 $wgOut->addHTML( "<p>" . $text . "</p>\n" );
1028 $wgOut->returnToMain( false );
1030 $wgOut->fatalError( wfMsg( "cannotdelete" ) );
1034 # Back-end article deletion
1035 # Deletes the article with database consistency, writes logs, purges caches
1037 function doDeleteArticle( $reason )
1039 global $wgUser, $wgLang;
1040 global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer;
1042 $fname = "Article::doDeleteArticle";
1043 wfDebug( "$fname\n" );
1045 $ns = $this->mTitle
->getNamespace();
1046 $t = wfStrencode( $this->mTitle
->getDBkey() );
1047 $id = $this->mTitle
->getArticleID();
1049 if ( "" == $t ||
$id == 0 ) {
1053 $u = new SiteStatsUpdate( 0, 1, -$this->isCountable( $this->getContent( true ) ) );
1054 array_push( $wgDeferredUpdateList, $u );
1056 $linksTo = $this->mTitle
->getLinksTo();
1059 if ( $wgUseSquid ) {
1061 $this->mTitle
->getInternalURL(),
1062 $this->mTitle
->getInternalURL( "history" )
1064 foreach ( $linksTo as $linkTo ) {
1065 $urls[] = $linkTo->getInternalURL();
1068 $u = new SquidUpdate( $urls );
1069 array_push( $wgDeferredUpdateList, $u );
1073 # Client and file cache invalidation
1074 Title
::touchArray( $linksTo );
1076 # Move article and history to the "archive" table
1077 $sql = "INSERT INTO archive (ar_namespace,ar_title,ar_text," .
1078 "ar_comment,ar_user,ar_user_text,ar_timestamp,ar_minor_edit," .
1079 "ar_flags) SELECT cur_namespace,cur_title,cur_text,cur_comment," .
1080 "cur_user,cur_user_text,cur_timestamp,cur_minor_edit,0 FROM cur " .
1081 "WHERE cur_namespace={$ns} AND cur_title='{$t}'";
1082 wfQuery( $sql, DB_WRITE
, $fname );
1084 $sql = "INSERT INTO archive (ar_namespace,ar_title,ar_text," .
1085 "ar_comment,ar_user,ar_user_text,ar_timestamp,ar_minor_edit," .
1086 "ar_flags) SELECT old_namespace,old_title,old_text,old_comment," .
1087 "old_user,old_user_text,old_timestamp,old_minor_edit,old_flags " .
1088 "FROM old WHERE old_namespace={$ns} AND old_title='{$t}'";
1089 wfQuery( $sql, DB_WRITE
, $fname );
1091 # Now that it's safely backed up, delete it
1093 $sql = "DELETE FROM cur WHERE cur_namespace={$ns} AND " .
1095 wfQuery( $sql, DB_WRITE
, $fname );
1097 $sql = "DELETE FROM old WHERE old_namespace={$ns} AND " .
1099 wfQuery( $sql, DB_WRITE
, $fname );
1101 $sql = "DELETE FROM recentchanges WHERE rc_namespace={$ns} AND " .
1103 wfQuery( $sql, DB_WRITE
, $fname );
1105 # Finally, clean up the link tables
1106 $t = wfStrencode( $this->mTitle
->getPrefixedDBkey() );
1108 Article
::onArticleDelete( $this->mTitle
);
1110 $sql = "INSERT INTO brokenlinks (bl_from,bl_to) VALUES ";
1113 foreach ( $linksTo as $titleObj ) {
1114 if ( ! $first ) { $sql .= ","; }
1116 # Get article ID. Efficient because it was loaded into the cache by getLinksTo().
1117 $linkID = $titleObj->getArticleID();
1118 $sql .= "({$linkID},'{$t}')";
1121 wfQuery( $sql, DB_WRITE
, $fname );
1124 $sql = "DELETE FROM links WHERE l_to={$id}";
1125 wfQuery( $sql, DB_WRITE
, $fname );
1127 $sql = "DELETE FROM links WHERE l_from={$id}";
1128 wfQuery( $sql, DB_WRITE
, $fname );
1130 $sql = "DELETE FROM imagelinks WHERE il_from={$id}";
1131 wfQuery( $sql, DB_WRITE
, $fname );
1133 $sql = "DELETE FROM brokenlinks WHERE bl_from={$id}";
1134 wfQuery( $sql, DB_WRITE
, $fname );
1136 $log = new LogPage( wfMsg( "dellogpage" ), wfMsg( "dellogpagetext" ) );
1137 $art = $this->mTitle
->getPrefixedText();
1138 $log->addEntry( wfMsg( "deletedarticle", $art ), $reason );
1140 # Clear the cached article id so the interface doesn't act like we exist
1141 $this->mTitle
->resetArticleID( 0 );
1142 $this->mTitle
->mArticleID
= 0;
1148 global $wgUser, $wgLang, $wgOut, $wgRequest;
1150 if ( ! $wgUser->isSysop() ) {
1151 $wgOut->sysopRequired();
1154 if ( wfReadOnly() ) {
1155 $wgOut->readOnlyPage( $this->getContent() );
1159 # Enhanced rollback, marks edits rc_bot=1
1160 $bot = $wgRequest->getBool( 'bot' );
1162 # Replace all this user's current edits with the next one down
1163 $tt = wfStrencode( $this->mTitle
->getDBKey() );
1164 $n = $this->mTitle
->getNamespace();
1166 # Get the last editor
1167 $sql = "SELECT cur_id,cur_user,cur_user_text,cur_comment FROM cur WHERE cur_title='{$tt}' AND cur_namespace={$n}";
1168 $res = wfQuery( $sql, DB_READ
);
1169 if( ($x = wfNumRows( $res )) != 1 ) {
1171 $wgOut->addHTML( wfMsg( "notanarticle" ) );
1174 $s = wfFetchObject( $res );
1175 $ut = wfStrencode( $s->cur_user_text
);
1176 $uid = $s->cur_user
;
1179 $from = str_replace( '_', ' ', $wgRequest->getVal( "from" ) );
1180 if( $from != $s->cur_user_text
) {
1181 $wgOut->setPageTitle(wfmsg("rollbackfailed"));
1182 $wgOut->addWikiText( wfMsg( "alreadyrolled",
1183 htmlspecialchars( $this->mTitle
->getPrefixedText()),
1184 htmlspecialchars( $from ),
1185 htmlspecialchars( $s->cur_user_text
) ) );
1186 if($s->cur_comment
!= "") {
1188 wfMsg("editcomment",
1189 htmlspecialchars( $s->cur_comment
) ) );
1194 # Get the last edit not by this guy
1195 $sql = "SELECT old_text,old_user,old_user_text,old_timestamp,old_flags
1196 FROM old USE INDEX (name_title_timestamp)
1197 WHERE old_namespace={$n} AND old_title='{$tt}'
1198 AND (old_user <> {$uid} OR old_user_text <> '{$ut}')
1199 ORDER BY inverse_timestamp LIMIT 1";
1200 $res = wfQuery( $sql, DB_READ
);
1201 if( wfNumRows( $res ) != 1 ) {
1203 $wgOut->setPageTitle(wfMsg("rollbackfailed"));
1204 $wgOut->addHTML( wfMsg( "cantrollback" ) );
1207 $s = wfFetchObject( $res );
1210 # Mark all reverted edits as bot
1211 $sql = "UPDATE recentchanges SET rc_bot=1 WHERE
1212 rc_cur_id=$pid AND rc_user=$uid AND rc_timestamp > '{$s->old_timestamp}'";
1213 wfQuery( $sql, DB_WRITE
, $fname );
1217 $newcomment = wfMsg( "revertpage", $s->old_user_text
, $from );
1218 $wgOut->setPagetitle( wfMsg( "actioncomplete" ) );
1219 $wgOut->setRobotpolicy( "noindex,nofollow" );
1220 $wgOut->addHTML( "<h2>" . $newcomment . "</h2>\n<hr />\n" );
1221 $this->updateArticle( Article
::getRevisionText( $s ), $newcomment, 1, $this->mTitle
->userIsWatching(), $bot );
1222 Article
::onArticleEdit( $this->mTitle
);
1223 $wgOut->returnToMain( false );
1227 # Do standard deferred updates after page view
1229 /* private */ function viewUpdates()
1231 global $wgDeferredUpdateList;
1232 if ( 0 != $this->getID() ) {
1233 global $wgDisableCounters;
1234 if( !$wgDisableCounters ) {
1235 Article
::incViewCount( $this->getID() );
1236 $u = new SiteStatsUpdate( 1, 0, 0 );
1237 array_push( $wgDeferredUpdateList, $u );
1239 $u = new UserTalkUpdate( 0, $this->mTitle
->getNamespace(),
1240 $this->mTitle
->getDBkey() );
1241 array_push( $wgDeferredUpdateList, $u );
1245 # Do standard deferred updates after page edit.
1246 # Every 1000th edit, prune the recent changes table.
1248 /* private */ function editUpdates( $text )
1250 global $wgDeferredUpdateList, $wgDBname, $wgMemc;
1251 global $wgMessageCache;
1254 if ( 0 == mt_rand( 0, 999 ) ) {
1255 $cutoff = wfUnix2Timestamp( time() - ( 7 * 86400 ) );
1256 $sql = "DELETE FROM recentchanges WHERE rc_timestamp < '{$cutoff}'";
1257 wfQuery( $sql, DB_WRITE
);
1259 $id = $this->getID();
1260 $title = $this->mTitle
->getPrefixedDBkey();
1261 $shortTitle = $this->mTitle
->getDBkey();
1263 $adj = $this->mCountAdjustment
;
1266 $u = new LinksUpdate( $id, $title );
1267 array_push( $wgDeferredUpdateList, $u );
1268 $u = new SiteStatsUpdate( 0, 1, $adj );
1269 array_push( $wgDeferredUpdateList, $u );
1270 $u = new SearchUpdate( $id, $title, $text );
1271 array_push( $wgDeferredUpdateList, $u );
1273 $u = new UserTalkUpdate( 1, $this->mTitle
->getNamespace(), $shortTitle );
1274 array_push( $wgDeferredUpdateList, $u );
1276 if ( $this->mTitle
->getNamespace() == NS_MEDIAWIKI
) {
1277 $wgMessageCache->replace( $shortTitle, $text );
1282 /* private */ function setOldSubtitle()
1284 global $wgLang, $wgOut;
1286 $td = $wgLang->timeanddate( $this->mTimestamp
, true );
1287 $r = wfMsg( "revisionasof", $td );
1288 $wgOut->setSubtitle( "({$r})" );
1291 # This function is called right before saving the wikitext,
1292 # so we can do things like signatures and links-in-context.
1294 function preSaveTransform( $text )
1296 global $wgParser, $wgUser;
1297 return $wgParser->preSaveTransform( $text, $this->mTitle
, $wgUser, ParserOptions
::newFromUser( $wgUser ) );
1300 /* Caching functions */
1302 # checkLastModified returns true if it has taken care of all
1303 # output to the client that is necessary for this request.
1304 # (that is, it has sent a cached version of the page)
1305 function tryFileCache() {
1306 static $called = false;
1308 wfDebug( " tryFileCache() -- called twice!?\n" );
1312 if($this->isFileCacheable()) {
1313 $touched = $this->mTouched
;
1314 if( $this->mTitle
->getPrefixedDBkey() == wfMsg( "mainpage" ) ) {
1315 # Expire the main page quicker
1316 $expire = wfUnix2Timestamp( time() - 3600 );
1317 $touched = max( $expire, $touched );
1319 $cache = new CacheManager( $this->mTitle
);
1320 if($cache->isFileCacheGood( $touched )) {
1322 wfDebug( " tryFileCache() - about to load\n" );
1323 $cache->loadFromFileCache();
1326 wfDebug( " tryFileCache() - starting buffer\n" );
1327 ob_start( array(&$cache, 'saveToFileCache' ) );
1330 wfDebug( " tryFileCache() - not cacheable\n" );
1334 function isFileCacheable() {
1335 global $wgUser, $wgUseFileCache, $wgShowIPinHeader, $wgRequest;
1336 extract( $wgRequest->getValues( 'action', 'oldid', 'diff', 'redirect', 'printable' ) );
1338 return $wgUseFileCache
1339 and (!$wgShowIPinHeader)
1340 and ($this->getID() != 0)
1341 and ($wgUser->getId() == 0)
1342 and (!$wgUser->getNewtalk())
1343 and ($this->mTitle
->getNamespace() != Namespace::getSpecial())
1344 and ($action == "view")
1345 and (!isset($oldid))
1347 and (!isset($redirect))
1348 and (!isset($printable))
1349 and (!$this->mRedirectedFrom
);
1352 function checkTouched() {
1353 $id = $this->getID();
1354 $sql = "SELECT cur_touched,cur_is_redirect FROM cur WHERE cur_id=$id";
1355 $res = wfQuery( $sql, DB_READ
, "Article::checkTouched" );
1356 if( $s = wfFetchObject( $res ) ) {
1357 $this->mTouched
= $s->cur_touched
;
1358 return !$s->cur_is_redirect
;
1364 /* static */ function incViewCount( $id )
1366 $id = intval( $id );
1367 global $wgHitcounterUpdateFreq;
1369 if( $wgHitcounterUpdateFreq <= 1 ){ //
1370 wfQuery("UPDATE cur SET cur_counter = cur_counter + 1 " .
1371 "WHERE cur_id = $id", DB_WRITE
);
1375 # Not important enough to warrant an error page in case of failure
1376 $oldignore = wfIgnoreSQLErrors( true );
1378 wfQuery("INSERT INTO hitcounter (hc_id) VALUES ({$id})", DB_WRITE
);
1380 $checkfreq = intval( $wgHitcounterUpdateFreq/25 +
1 );
1381 if( (rand() %
$checkfreq != 0) or (wfLastErrno() != 0) ){
1382 # Most of the time (or on SQL errors), skip row count check
1383 wfIgnoreSQLErrors( $oldignore );
1387 $res = wfQuery("SELECT COUNT(*) as n FROM hitcounter", DB_WRITE
);
1388 $row = wfFetchObject( $res );
1389 $rown = intval( $row->n
);
1390 if( $rown >= $wgHitcounterUpdateFreq ){
1391 wfProfileIn( "Article::incViewCount-collect" );
1392 $old_user_abort = ignore_user_abort( true );
1394 wfQuery("LOCK TABLES hitcounter WRITE", DB_WRITE
);
1395 wfQuery("CREATE TEMPORARY TABLE acchits TYPE=HEAP ".
1396 "SELECT hc_id,COUNT(*) AS hc_n FROM hitcounter ".
1397 "GROUP BY hc_id", DB_WRITE
);
1398 wfQuery("DELETE FROM hitcounter", DB_WRITE
);
1399 wfQuery("UNLOCK TABLES", DB_WRITE
);
1400 wfQuery("UPDATE cur,acchits SET cur_counter=cur_counter + hc_n ".
1401 "WHERE cur_id = hc_id", DB_WRITE
);
1402 wfQuery("DROP TABLE acchits", DB_WRITE
);
1404 ignore_user_abort( $old_user_abort );
1405 wfProfileOut( "Article::incViewCount-collect" );
1407 wfIgnoreSQLErrors( $oldignore );
1410 # The onArticle*() functions are supposed to be a kind of hooks
1411 # which should be called whenever any of the specified actions
1414 # This is a good place to put code to clear caches, for instance.
1416 # This is called on page move and undelete, as well as edit
1417 /* static */ function onArticleCreate($title_obj){
1418 global $wgEnablePersistentLC, $wgEnableParserCache, $wgUseSquid, $wgDeferredUpdateList;
1420 $titles = $title_obj->getBrokenLinksTo();
1423 if ( $wgUseSquid ) {
1424 $urls = $title_obj->getSquidURLs();
1425 foreach ( $titles as $linkTitle ) {
1426 $urls[] = $linkTitle->getInternalURL();
1428 $u = new SquidUpdate( $urls );
1429 array_push( $wgDeferredUpdateList, $u );
1432 # Clear persistent link cache
1433 if ( $wgEnablePersistentLC ) {
1434 LinkCache
::linksccClearBrokenLinksTo( $title_obj->getPrefixedDBkey() );
1437 # Clear parser cache (not really used)
1438 if ( $wgEnableParserCache ) {
1439 OutputPage
::parsercacheClearBrokenLinksTo( $title_obj->getPrefixedDBkey() );
1443 /* static */ function onArticleDelete($title_obj){
1444 global $wgEnablePersistentLC, $wgEnableParserCache;
1445 if ( $wgEnablePersistentLC ) {
1446 LinkCache
::linksccClearLinksTo( $title_obj->getArticleID() );
1448 if ( $wgEnableParserCache ) {
1449 OutputPage
::parsercacheClearLinksTo( $title_obj->getArticleID() );
1453 /* static */ function onArticleEdit($title_obj){
1454 global $wgEnablePersistentLC, $wgEnableParserCache;
1455 if ( $wgEnablePersistentLC ) {
1456 LinkCache
::linksccClearPage( $title_obj->getArticleID() );
1458 if ( $wgEnableParserCache ) {
1459 OutputPage
::parsercacheClearPage( $title_obj->getArticleID(), $title_obj->getNamespace() );