Index: trunk/phase3/includes/Defines.php |
— | — | @@ -164,5 +164,15 @@ |
165 | 165 | define( 'RC_MOVE_OVER_REDIRECT', 4); |
166 | 166 | /**#@-*/ |
167 | 167 | |
| 168 | +/**#@+ |
| 169 | + * Article edit flags |
| 170 | + */ |
| 171 | +define( 'EDIT_NEW', 1 ); |
| 172 | +define( 'EDIT_UPDATE', 2 ); |
| 173 | +define( 'EDIT_MINOR', 4 ); |
| 174 | +define( 'EDIT_SUPPRESS_RC', 8 ); |
| 175 | +define( 'EDIT_FORCE_BOT', 16 ); |
| 176 | +define( 'EDIT_DEFER_UPDATES', 32 ); |
| 177 | +/**#@-*/ |
168 | 178 | |
169 | 179 | ?> |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -26,10 +26,8 @@ |
27 | 27 | var $mContent; //!< |
28 | 28 | var $mContentLoaded; //!< |
29 | 29 | var $mCounter; //!< |
30 | | - var $mFileCache; //!< |
31 | 30 | var $mForUpdate; //!< |
32 | 31 | var $mGoodAdjustment; //!< |
33 | | - var $mId; //!< |
34 | 32 | var $mLatest; //!< |
35 | 33 | var $mMinorEdit; //!< |
36 | 34 | var $mOldId; //!< |
— | — | @@ -37,7 +35,6 @@ |
38 | 36 | var $mRedirectUrl; //!< |
39 | 37 | var $mRevIdFetched; //!< |
40 | 38 | var $mRevision; //!< |
41 | | - var $mTable; //!< |
42 | 39 | var $mTimestamp; //!< |
43 | 40 | var $mTitle; //!< |
44 | 41 | var $mTotalAdjustment; //!< |
— | — | @@ -125,7 +122,7 @@ |
126 | 123 | $this->mCurID = $this->mUser = $this->mCounter = -1; # Not loaded |
127 | 124 | $this->mRedirectedFrom = null; # Title object if set |
128 | 125 | $this->mUserText = |
129 | | - $this->mTimestamp = $this->mComment = $this->mFileCache = ''; |
| 126 | + $this->mTimestamp = $this->mComment = ''; |
130 | 127 | $this->mGoodAdjustment = $this->mTotalAdjustment = 0; |
131 | 128 | $this->mTouched = '19700101000000'; |
132 | 129 | $this->mForUpdate = false; |
— | — | @@ -154,12 +151,11 @@ |
155 | 152 | $section = $wgRequest->getText( 'section' ); |
156 | 153 | $preload = $wgRequest->getText( 'preload' ); |
157 | 154 | |
158 | | - $fname = 'Article::getContent'; |
159 | | - wfProfileIn( $fname ); |
| 155 | + wfProfileIn( __METHOD__ ); |
160 | 156 | |
161 | 157 | if ( 0 == $this->getID() ) { |
162 | 158 | if ( 'edit' == $action ) { |
163 | | - wfProfileOut( $fname ); |
| 159 | + wfProfileOut( __METHOD__ ); |
164 | 160 | |
165 | 161 | # If requested, preload some text. |
166 | 162 | $text=$this->getPreloadedText($preload); |
— | — | @@ -169,7 +165,7 @@ |
170 | 166 | # This is now shown above the edit box instead. |
171 | 167 | return $text; |
172 | 168 | } |
173 | | - wfProfileOut( $fname ); |
| 169 | + wfProfileOut( __METHOD__ ); |
174 | 170 | $wgOut->setRobotpolicy( 'noindex,nofollow' ); |
175 | 171 | |
176 | 172 | if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
— | — | @@ -184,7 +180,7 @@ |
185 | 181 | if($action=='edit') { |
186 | 182 | if($section!='') { |
187 | 183 | if($section=='new') { |
188 | | - wfProfileOut( $fname ); |
| 184 | + wfProfileOut( __METHOD__ ); |
189 | 185 | $text=$this->getPreloadedText($preload); |
190 | 186 | return $text; |
191 | 187 | } |
— | — | @@ -192,11 +188,11 @@ |
193 | 189 | # strip NOWIKI etc. to avoid confusion (true-parameter causes HTML |
194 | 190 | # comments to be stripped as well) |
195 | 191 | $rv=$this->getSection($this->mContent,$section); |
196 | | - wfProfileOut( $fname ); |
| 192 | + wfProfileOut( __METHOD__ ); |
197 | 193 | return $rv; |
198 | 194 | } |
199 | 195 | } |
200 | | - wfProfileOut( $fname ); |
| 196 | + wfProfileOut( __METHOD__ ); |
201 | 197 | return $this->mContent; |
202 | 198 | } |
203 | 199 | } |
— | — | @@ -400,7 +396,6 @@ |
401 | 397 | } |
402 | 398 | |
403 | 399 | $dbr =& $this->getDB(); |
404 | | - $fname = 'Article::fetchContent'; |
405 | 400 | |
406 | 401 | # Pre-fill content with error message so that if something |
407 | 402 | # fails we'll have something telling us what we intended. |
— | — | @@ -413,12 +408,12 @@ |
414 | 409 | if( $oldid ) { |
415 | 410 | $revision = Revision::newFromId( $oldid ); |
416 | 411 | if( is_null( $revision ) ) { |
417 | | - wfDebug( "$fname failed to retrieve specified revision, id $oldid\n" ); |
| 412 | + wfDebug( __METHOD__." failed to retrieve specified revision, id $oldid\n" ); |
418 | 413 | return false; |
419 | 414 | } |
420 | 415 | $data = $this->pageDataFromId( $dbr, $revision->getPage() ); |
421 | 416 | if( !$data ) { |
422 | | - wfDebug( "$fname failed to get page data linked to revision id $oldid\n" ); |
| 417 | + wfDebug( __METHOD__." failed to get page data linked to revision id $oldid\n" ); |
423 | 418 | return false; |
424 | 419 | } |
425 | 420 | $this->mTitle = Title::makeTitle( $data->page_namespace, $data->page_title ); |
— | — | @@ -427,14 +422,14 @@ |
428 | 423 | if( !$this->mDataLoaded ) { |
429 | 424 | $data = $this->pageDataFromTitle( $dbr, $this->mTitle ); |
430 | 425 | if( !$data ) { |
431 | | - wfDebug( "$fname failed to find page data for title " . $this->mTitle->getPrefixedText() . "\n" ); |
| 426 | + wfDebug( __METHOD__." failed to find page data for title " . $this->mTitle->getPrefixedText() . "\n" ); |
432 | 427 | return false; |
433 | 428 | } |
434 | 429 | $this->loadPageData( $data ); |
435 | 430 | } |
436 | 431 | $revision = Revision::newFromId( $this->mLatest ); |
437 | 432 | if( is_null( $revision ) ) { |
438 | | - wfDebug( "$fname failed to retrieve current page, rev_id {$data->page_latest}\n" ); |
| 433 | + wfDebug( __METHOD__." failed to retrieve current page, rev_id {$data->page_latest}\n" ); |
439 | 434 | return false; |
440 | 435 | } |
441 | 436 | } |
— | — | @@ -637,8 +632,6 @@ |
638 | 633 | * @param $offset Integer: default 0. |
639 | 634 | */ |
640 | 635 | function getContributors($limit = 0, $offset = 0) { |
641 | | - $fname = 'Article::getContributors'; |
642 | | - |
643 | 636 | # XXX: this is expensive; cache this info somewhere. |
644 | 637 | |
645 | 638 | $title = $this->mTitle; |
— | — | @@ -661,7 +654,7 @@ |
662 | 655 | if ($limit > 0) { $sql .= ' LIMIT '.$limit; } |
663 | 656 | $sql .= ' '. $this->getSelectOptions(); |
664 | 657 | |
665 | | - $res = $dbr->query($sql, $fname); |
| 658 | + $res = $dbr->query($sql, __METHOD__); |
666 | 659 | |
667 | 660 | while ( $line = $dbr->fetchObject( $res ) ) { |
668 | 661 | $contribs[] = array($line->rev_user, $line->rev_user_text, $line->user_real_name); |
— | — | @@ -681,8 +674,7 @@ |
682 | 675 | global $wgUseTrackbacks, $wgNamespaceRobotPolicies; |
683 | 676 | $sk = $wgUser->getSkin(); |
684 | 677 | |
685 | | - $fname = 'Article::view'; |
686 | | - wfProfileIn( $fname ); |
| 678 | + wfProfileIn( __METHOD__ ); |
687 | 679 | |
688 | 680 | $parserCache =& ParserCache::singleton(); |
689 | 681 | $ns = $this->mTitle->getNamespace(); # shortcut |
— | — | @@ -693,7 +685,7 @@ |
694 | 686 | # getOldID may want us to redirect somewhere else |
695 | 687 | if ( $this->mRedirectUrl ) { |
696 | 688 | $wgOut->redirect( $this->mRedirectUrl ); |
697 | | - wfProfileOut( $fname ); |
| 689 | + wfProfileOut( __METHOD__ ); |
698 | 690 | return; |
699 | 691 | } |
700 | 692 | |
— | — | @@ -725,7 +717,7 @@ |
726 | 718 | # Run view updates for current revision only |
727 | 719 | $this->viewUpdates(); |
728 | 720 | } |
729 | | - wfProfileOut( $fname ); |
| 721 | + wfProfileOut( __METHOD__ ); |
730 | 722 | return; |
731 | 723 | } |
732 | 724 | |
— | — | @@ -733,13 +725,13 @@ |
734 | 726 | $wgOut->setETag($parserCache->getETag($this, $wgUser)); |
735 | 727 | |
736 | 728 | if( $wgOut->checkLastModified( $this->mTouched ) ){ |
737 | | - wfProfileOut( $fname ); |
| 729 | + wfProfileOut( __METHOD__ ); |
738 | 730 | return; |
739 | 731 | } else if ( $this->tryFileCache() ) { |
740 | 732 | # tell wgOut that output is taken care of |
741 | 733 | $wgOut->disable(); |
742 | 734 | $this->viewUpdates(); |
743 | | - wfProfileOut( $fname ); |
| 735 | + wfProfileOut( __METHOD__ ); |
744 | 736 | return; |
745 | 737 | } |
746 | 738 | } |
— | — | @@ -904,7 +896,7 @@ |
905 | 897 | $this->addTrackbacks(); |
906 | 898 | |
907 | 899 | $this->viewUpdates(); |
908 | | - wfProfileOut( $fname ); |
| 900 | + wfProfileOut( __METHOD__ ); |
909 | 901 | } |
910 | 902 | |
911 | 903 | function addTrackbacks() { |
— | — | @@ -1027,8 +1019,7 @@ |
1028 | 1020 | * @private |
1029 | 1021 | */ |
1030 | 1022 | function insertOn( &$dbw, $restrictions = '' ) { |
1031 | | - $fname = 'Article::insertOn'; |
1032 | | - wfProfileIn( $fname ); |
| 1023 | + wfProfileIn( __METHOD__ ); |
1033 | 1024 | |
1034 | 1025 | $page_id = $dbw->nextSequenceValue( 'page_page_id_seq' ); |
1035 | 1026 | $dbw->insert( 'page', array( |
— | — | @@ -1043,12 +1034,12 @@ |
1044 | 1035 | 'page_touched' => $dbw->timestamp(), |
1045 | 1036 | 'page_latest' => 0, # Fill this in shortly... |
1046 | 1037 | 'page_len' => 0, # Fill this in shortly... |
1047 | | - ), $fname ); |
| 1038 | + ), __METHOD__ ); |
1048 | 1039 | $newid = $dbw->insertId(); |
1049 | 1040 | |
1050 | 1041 | $this->mTitle->resetArticleId( $newid ); |
1051 | 1042 | |
1052 | | - wfProfileOut( $fname ); |
| 1043 | + wfProfileOut( __METHOD__ ); |
1053 | 1044 | return $newid; |
1054 | 1045 | } |
1055 | 1046 | |
— | — | @@ -1066,8 +1057,7 @@ |
1067 | 1058 | * @private |
1068 | 1059 | */ |
1069 | 1060 | function updateRevisionOn( &$dbw, $revision, $lastRevision = null ) { |
1070 | | - $fname = 'Article::updateToRevision'; |
1071 | | - wfProfileIn( $fname ); |
| 1061 | + wfProfileIn( __METHOD__ ); |
1072 | 1062 | |
1073 | 1063 | $conditions = array( 'page_id' => $this->getId() ); |
1074 | 1064 | if( !is_null( $lastRevision ) ) { |
— | — | @@ -1085,9 +1075,9 @@ |
1086 | 1076 | 'page_len' => strlen( $text ), |
1087 | 1077 | ), |
1088 | 1078 | $conditions, |
1089 | | - $fname ); |
| 1079 | + __METHOD__ ); |
1090 | 1080 | |
1091 | | - wfProfileOut( $fname ); |
| 1081 | + wfProfileOut( __METHOD__ ); |
1092 | 1082 | return ( $dbw->affectedRows() != 0 ); |
1093 | 1083 | } |
1094 | 1084 | |
— | — | @@ -1099,8 +1089,7 @@ |
1100 | 1090 | * @param Revision $revision |
1101 | 1091 | */ |
1102 | 1092 | function updateIfNewerOn( &$dbw, $revision ) { |
1103 | | - $fname = 'Article::updateIfNewerOn'; |
1104 | | - wfProfileIn( $fname ); |
| 1093 | + wfProfileIn( __METHOD__ ); |
1105 | 1094 | |
1106 | 1095 | $row = $dbw->selectRow( |
1107 | 1096 | array( 'revision', 'page' ), |
— | — | @@ -1108,10 +1097,10 @@ |
1109 | 1098 | array( |
1110 | 1099 | 'page_id' => $this->getId(), |
1111 | 1100 | 'page_latest=rev_id' ), |
1112 | | - $fname ); |
| 1101 | + __METHOD__ ); |
1113 | 1102 | if( $row ) { |
1114 | 1103 | if( wfTimestamp(TS_MW, $row->rev_timestamp) >= $revision->getTimestamp() ) { |
1115 | | - wfProfileOut( $fname ); |
| 1104 | + wfProfileOut( __METHOD__ ); |
1116 | 1105 | return false; |
1117 | 1106 | } |
1118 | 1107 | $prev = $row->rev_id; |
— | — | @@ -1121,115 +1110,15 @@ |
1122 | 1111 | } |
1123 | 1112 | |
1124 | 1113 | $ret = $this->updateRevisionOn( $dbw, $revision, $prev ); |
1125 | | - wfProfileOut( $fname ); |
| 1114 | + wfProfileOut( __METHOD__ ); |
1126 | 1115 | return $ret; |
1127 | 1116 | } |
1128 | 1117 | |
1129 | 1118 | /** |
1130 | | - * Insert a new article into the database |
1131 | | - * @private |
1132 | | - */ |
1133 | | - function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false ) { |
1134 | | - global $wgUser; |
1135 | | - |
1136 | | - $fname = 'Article::insertNewArticle'; |
1137 | | - wfProfileIn( $fname ); |
1138 | | - |
1139 | | - if( !wfRunHooks( 'ArticleSave', array( &$this, &$wgUser, &$text, |
1140 | | - &$summary, &$isminor, &$watchthis, NULL ) ) ) { |
1141 | | - wfDebug( "$fname: ArticleSave hook aborted save!\n" ); |
1142 | | - wfProfileOut( $fname ); |
1143 | | - return false; |
1144 | | - } |
1145 | | - |
1146 | | - $ns = $this->mTitle->getNamespace(); |
1147 | | - $ttl = $this->mTitle->getDBkey(); |
1148 | | - |
1149 | | - # If this is a comment, add the summary as headline |
1150 | | - if($comment && $summary!="") { |
1151 | | - $text="== {$summary} ==\n\n".$text; |
1152 | | - } |
1153 | | - $text = $this->preSaveTransform( $text ); |
1154 | | - |
1155 | | - |
1156 | | - # Set statistics members |
1157 | | - # We work out if it's countable after PST to avoid counter drift |
1158 | | - # when articles are created with {{subst:}} |
1159 | | - $this->mGoodAdjustment = (int)$this->isCountable( $text ); |
1160 | | - $this->mTotalAdjustment = 1; |
1161 | | - |
1162 | | - /* Silently ignore minoredit if not allowed */ |
1163 | | - $isminor = $isminor && $wgUser->isAllowed('minoredit'); |
1164 | | - $now = wfTimestampNow(); |
1165 | | - |
1166 | | - $dbw =& wfGetDB( DB_MASTER ); |
1167 | | - |
1168 | | - # Add the page record; stake our claim on this title! |
1169 | | - $newid = $this->insertOn( $dbw ); |
1170 | | - |
1171 | | - # Save the revision text... |
1172 | | - $revision = new Revision( array( |
1173 | | - 'page' => $newid, |
1174 | | - 'comment' => $summary, |
1175 | | - 'minor_edit' => $isminor, |
1176 | | - 'text' => $text |
1177 | | - ) ); |
1178 | | - $revisionId = $revision->insertOn( $dbw ); |
1179 | | - |
1180 | | - $this->mTitle->resetArticleID( $newid ); |
1181 | | - |
1182 | | - # Update the page record with revision data |
1183 | | - $this->updateRevisionOn( $dbw, $revision, 0 ); |
1184 | | - |
1185 | | - if(!$suppressRC) { |
1186 | | - $rcid = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary, 'default', |
1187 | | - '', strlen( $text ), $revisionId ); |
1188 | | - # Mark as patrolled if the user can and has the option set |
1189 | | - if( $wgUser->isAllowed( 'patrol' ) && $wgUser->getOption( 'autopatrol' ) ) { |
1190 | | - RecentChange::markPatrolled( $rcid ); |
1191 | | - } |
1192 | | - } |
1193 | | - |
1194 | | - if ($watchthis) { |
1195 | | - if(!$this->mTitle->userIsWatching()) $this->doWatch(); |
1196 | | - } else { |
1197 | | - if ( $this->mTitle->userIsWatching() ) { |
1198 | | - $this->doUnwatch(); |
1199 | | - } |
1200 | | - } |
1201 | | - |
1202 | | - # The talk page isn't in the regular link tables, so we need to update manually: |
1203 | | - $talkns = $ns ^ 1; # talk -> normal; normal -> talk |
1204 | | - $dbw->update( 'page', |
1205 | | - array( 'page_touched' => $dbw->timestamp($now) ), |
1206 | | - array( 'page_namespace' => $talkns, |
1207 | | - 'page_title' => $ttl ), |
1208 | | - $fname ); |
1209 | | - |
1210 | | - # Update links, etc. |
1211 | | - $this->editUpdates( $text, $summary, $isminor, $now, $revisionId ); |
1212 | | - |
1213 | | - # Clear caches |
1214 | | - Article::onArticleCreate( $this->mTitle ); |
1215 | | - |
1216 | | - # Output a redirect back to the article |
1217 | | - $this->doRedirect( $this->isRedirect( $text ) ); |
1218 | | - |
1219 | | - wfRunHooks( 'ArticleInsertComplete', array( &$this, &$wgUser, $text, |
1220 | | - $summary, $isminor, |
1221 | | - $watchthis, NULL ) ); |
1222 | | - wfRunHooks( 'ArticleSaveComplete', array( &$this, &$wgUser, $text, |
1223 | | - $summary, $isminor, |
1224 | | - $watchthis, NULL ) ); |
1225 | | - wfProfileOut( $fname ); |
1226 | | - } |
1227 | | - |
1228 | | - /** |
1229 | 1119 | * @return string Complete article text, or null if error |
1230 | 1120 | */ |
1231 | 1121 | function replaceSection($section, $text, $summary = '', $edittime = NULL) { |
1232 | | - $fname = 'Article::replaceSection'; |
1233 | | - wfProfileIn( $fname ); |
| 1122 | + wfProfileIn( __METHOD__ ); |
1234 | 1123 | |
1235 | 1124 | if( $section == '' ) { |
1236 | 1125 | // Whole-page edit; let the text through unmolested. |
— | — | @@ -1256,132 +1145,280 @@ |
1257 | 1146 | } |
1258 | 1147 | } |
1259 | 1148 | |
1260 | | - wfProfileOut( $fname ); |
| 1149 | + wfProfileOut( __METHOD__ ); |
1261 | 1150 | return $text; |
1262 | 1151 | } |
1263 | 1152 | |
1264 | 1153 | /** |
1265 | | - * Change an existing article. Puts the previous version back into the old table, updates RC |
1266 | | - * and all necessary caches, mostly via the deferred update array. |
| 1154 | + * @deprecated use Article::doEdit() |
| 1155 | + */ |
| 1156 | + function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false ) { |
| 1157 | + $flags = EDIT_NEW | EDIT_DEFER_UPDATES | |
| 1158 | + ( $isminor ? EDIT_MINOR : 0 ) | |
| 1159 | + ( $suppressRC ? EDIT_SUPPRESS_RC : 0 ); |
| 1160 | + |
| 1161 | + # If this is a comment, add the summary as headline |
| 1162 | + if ( $comment && $summary != "" ) { |
| 1163 | + $text = "== {$summary} ==\n\n".$text; |
| 1164 | + } |
| 1165 | + |
| 1166 | + $this->doEdit( $text, $summary, $flags ); |
| 1167 | + |
| 1168 | + $dbw =& wfGetDB( DB_MASTER ); |
| 1169 | + if ($watchthis) { |
| 1170 | + if (!$this->mTitle->userIsWatching()) { |
| 1171 | + $dbw->begin(); |
| 1172 | + $this->doWatch(); |
| 1173 | + $dbw->commit(); |
| 1174 | + } |
| 1175 | + } else { |
| 1176 | + if ( $this->mTitle->userIsWatching() ) { |
| 1177 | + $dbw->begin(); |
| 1178 | + $this->doUnwatch(); |
| 1179 | + $dbw->commit(); |
| 1180 | + } |
| 1181 | + } |
| 1182 | + $this->doRedirect( $this->isRedirect( $text ) ); |
| 1183 | + } |
| 1184 | + |
| 1185 | + /** |
| 1186 | + * @deprecated use Article::doEdit() |
| 1187 | + */ |
| 1188 | + function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) { |
| 1189 | + $flags = EDIT_UPDATE | EDIT_DEFER_UPDATES | |
| 1190 | + ( $minor ? EDIT_MINOR : 0 ) | |
| 1191 | + ( $forceBot ? EDIT_FORCE_BOT : 0 ); |
| 1192 | + |
| 1193 | + $good = $this->doEdit( $text, $summary, $flags ); |
| 1194 | + if ( $good ) { |
| 1195 | + $dbw =& wfGetDB( DB_MASTER ); |
| 1196 | + if ($watchthis) { |
| 1197 | + if (!$this->mTitle->userIsWatching()) { |
| 1198 | + $dbw->begin(); |
| 1199 | + $this->doWatch(); |
| 1200 | + $dbw->commit(); |
| 1201 | + } |
| 1202 | + } else { |
| 1203 | + if ( $this->mTitle->userIsWatching() ) { |
| 1204 | + $dbw->begin(); |
| 1205 | + $this->doUnwatch(); |
| 1206 | + $dbw->commit(); |
| 1207 | + } |
| 1208 | + } |
| 1209 | + |
| 1210 | + $this->doRedirect( $this->isRedirect( $text ), $sectionanchor ); |
| 1211 | + } |
| 1212 | + return $good; |
| 1213 | + } |
| 1214 | + |
| 1215 | + /** |
| 1216 | + * Article::doEdit() |
1267 | 1217 | * |
| 1218 | + * Change an existing article or create a new article. Updates RC and all necessary caches, |
| 1219 | + * optionally via the deferred update array. |
| 1220 | + * |
1268 | 1221 | * It is possible to call this function from a command-line script, but note that you should |
1269 | 1222 | * first set $wgUser, and clean up $wgDeferredUpdates after each edit. |
| 1223 | + * |
| 1224 | + * $wgUser must be set before calling this function. |
| 1225 | + * |
| 1226 | + * @param string $text New text |
| 1227 | + * @param string $summary Edit summary |
| 1228 | + * @param integer $flags bitfield: |
| 1229 | + * EDIT_NEW |
| 1230 | + * Article is known or assumed to be non-existent, create a new one |
| 1231 | + * EDIT_UPDATE |
| 1232 | + * Article is known or assumed to be pre-existing, update it |
| 1233 | + * EDIT_MINOR |
| 1234 | + * Mark this edit minor, if the user is allowed to do so |
| 1235 | + * EDIT_SUPPRESS_RC |
| 1236 | + * Do not log the change in recentchanges |
| 1237 | + * EDIT_FORCE_BOT |
| 1238 | + * Mark the edit a "bot" edit regardless of user rights |
| 1239 | + * EDIT_DEFER_UPDATES |
| 1240 | + * Defer some of the updates until the end of index.php |
| 1241 | + * |
| 1242 | + * If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the article will be detected. |
| 1243 | + * If EDIT_UPDATE is specified and the article doesn't exist, the function will return false. If |
| 1244 | + * EDIT_NEW is specified and the article does exist, a duplicate key error will cause an exception |
| 1245 | + * to be thrown from the Database. These two conditions are also possible with auto-detection due |
| 1246 | + * to MediaWiki's performance-optimised locking strategy. |
| 1247 | + * |
| 1248 | + * @return bool success |
1270 | 1249 | */ |
1271 | | - function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) { |
1272 | | - global $wgUser, $wgDBtransactions, $wgUseSquid; |
1273 | | - global $wgPostCommitUpdateList, $wgUseFileCache; |
| 1250 | + function doEdit( $text, $summary, $flags = 0 ) { |
| 1251 | + global $wgUser, $wgDBtransactions; |
1274 | 1252 | |
1275 | | - $fname = 'Article::updateArticle'; |
1276 | | - wfProfileIn( $fname ); |
| 1253 | + wfProfileIn( __METHOD__ ); |
1277 | 1254 | $good = true; |
1278 | 1255 | |
| 1256 | + if ( !($flags & EDIT_NEW) && !($flags & EDIT_UPDATE) ) { |
| 1257 | + $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE ); |
| 1258 | + if ( $aid ) { |
| 1259 | + $flags |= EDIT_UPDATE; |
| 1260 | + } else { |
| 1261 | + $flags |= EDIT_NEW; |
| 1262 | + } |
| 1263 | + } |
| 1264 | + |
1279 | 1265 | if( !wfRunHooks( 'ArticleSave', array( &$this, &$wgUser, &$text, |
1280 | | - &$summary, &$minor, |
1281 | | - &$watchthis, &$sectionanchor ) ) ) { |
1282 | | - wfDebug( "$fname: ArticleSave hook aborted save!\n" ); |
1283 | | - wfProfileOut( $fname ); |
| 1266 | + &$summary, $flags & EDIT_MINOR, |
| 1267 | + null, null, &$flags ) ) ) |
| 1268 | + { |
| 1269 | + wfDebug( __METHOD__ . ": ArticleSave hook aborted save!\n" ); |
| 1270 | + wfProfileOut( __METHOD__ ); |
1284 | 1271 | return false; |
1285 | 1272 | } |
1286 | 1273 | |
1287 | | - $isminor = $minor && $wgUser->isAllowed('minoredit'); |
| 1274 | + # Silently ignore EDIT_MINOR if not allowed |
| 1275 | + $isminor = ( $flags & EDIT_MINOR ) && $wgUser->isAllowed('minoredit'); |
| 1276 | + $bot = $wgUser->isBot() || ( $flags & EDIT_FORCE_BOT ); |
1288 | 1277 | |
1289 | 1278 | $text = $this->preSaveTransform( $text ); |
| 1279 | + |
1290 | 1280 | $dbw =& wfGetDB( DB_MASTER ); |
1291 | 1281 | $now = wfTimestampNow(); |
| 1282 | + |
| 1283 | + if ( $flags & EDIT_UPDATE ) { |
| 1284 | + # Update article, but only if changed. |
1292 | 1285 | |
1293 | | - # Update article, but only if changed. |
| 1286 | + # Make sure the revision is either completely inserted or not inserted at all |
| 1287 | + if( !$wgDBtransactions ) { |
| 1288 | + $userAbort = ignore_user_abort( true ); |
| 1289 | + } |
1294 | 1290 | |
1295 | | - # It's important that we either rollback or complete, otherwise an attacker could |
1296 | | - # overwrite cur entries by sending precisely timed user aborts. Random bored users |
1297 | | - # could conceivably have the same effect, especially if cur is locked for long periods. |
1298 | | - if( !$wgDBtransactions ) { |
1299 | | - $userAbort = ignore_user_abort( true ); |
1300 | | - } |
| 1291 | + $oldtext = $this->getContent(); |
| 1292 | + $oldsize = strlen( $oldtext ); |
| 1293 | + $newsize = strlen( $text ); |
| 1294 | + $lastRevision = 0; |
| 1295 | + $revisionId = 0; |
1301 | 1296 | |
1302 | | - $oldtext = $this->getContent(); |
1303 | | - $oldsize = strlen( $oldtext ); |
1304 | | - $newsize = strlen( $text ); |
1305 | | - $lastRevision = 0; |
1306 | | - $revisionId = 0; |
| 1297 | + if ( 0 != strcmp( $text, $oldtext ) ) { |
| 1298 | + $this->mGoodAdjustment = (int)$this->isCountable( $text ) |
| 1299 | + - (int)$this->isCountable( $oldtext ); |
| 1300 | + $this->mTotalAdjustment = 0; |
1307 | 1301 | |
1308 | | - if ( 0 != strcmp( $text, $oldtext ) ) { |
1309 | | - $this->mGoodAdjustment = (int)$this->isCountable( $text ) |
1310 | | - - (int)$this->isCountable( $oldtext ); |
1311 | | - $this->mTotalAdjustment = 0; |
1312 | | - $now = wfTimestampNow(); |
| 1302 | + $lastRevision = $dbw->selectField( |
| 1303 | + 'page', 'page_latest', array( 'page_id' => $this->getId() ) ); |
1313 | 1304 | |
1314 | | - $lastRevision = $dbw->selectField( |
1315 | | - 'page', 'page_latest', array( 'page_id' => $this->getId() ) ); |
| 1305 | + if ( !$lastRevision ) { |
| 1306 | + # Article gone missing |
| 1307 | + wfDebug( __METHOD__.": EDIT_UPDATE specified but article doesn't exist\n" ); |
| 1308 | + wfProfileOut( __METHOD__ ); |
| 1309 | + return false; |
| 1310 | + } |
| 1311 | + |
| 1312 | + $revision = new Revision( array( |
| 1313 | + 'page' => $this->getId(), |
| 1314 | + 'comment' => $summary, |
| 1315 | + 'minor_edit' => $isminor, |
| 1316 | + 'text' => $text |
| 1317 | + ) ); |
1316 | 1318 | |
| 1319 | + $dbw->begin(); |
| 1320 | + $revisionId = $revision->insertOn( $dbw ); |
| 1321 | + |
| 1322 | + # Update page |
| 1323 | + $ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision ); |
| 1324 | + |
| 1325 | + if( !$ok ) { |
| 1326 | + /* Belated edit conflict! Run away!! */ |
| 1327 | + $good = false; |
| 1328 | + $dbw->rollback(); |
| 1329 | + } else { |
| 1330 | + # Update recentchanges |
| 1331 | + if( !( $flags & EDIT_SUPPRESS_RC ) ) { |
| 1332 | + $rcid = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $wgUser, $summary, |
| 1333 | + $lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize, |
| 1334 | + $revisionId ); |
| 1335 | + |
| 1336 | + # Mark as patrolled if the user can do so and has it set in their options |
| 1337 | + if( $wgUser->isAllowed( 'patrol' ) && $wgUser->getOption( 'autopatrol' ) ) { |
| 1338 | + RecentChange::markPatrolled( $rcid ); |
| 1339 | + } |
| 1340 | + } |
| 1341 | + $dbw->commit(); |
| 1342 | + } |
| 1343 | + } else { |
| 1344 | + // Keep the same revision ID, but do some updates on it |
| 1345 | + $revisionId = $this->getRevIdFetched(); |
| 1346 | + // Update page_touched, this is usually implicit in the page update |
| 1347 | + // Other cache updates are done in onArticleEdit() |
| 1348 | + $this->mTitle->invalidateCache(); |
| 1349 | + } |
| 1350 | + |
| 1351 | + if( !$wgDBtransactions ) { |
| 1352 | + ignore_user_abort( $userAbort ); |
| 1353 | + } |
| 1354 | + |
| 1355 | + if ( $good ) { |
| 1356 | + # Invalidate cache of this article and all pages using this article |
| 1357 | + # as a template. Partly deferred. |
| 1358 | + Article::onArticleEdit( $this->mTitle ); |
| 1359 | + |
| 1360 | + # Update links tables, site stats, etc. |
| 1361 | + $this->editUpdates( $text, $summary, $isminor, $now, $revisionId ); |
| 1362 | + } |
| 1363 | + } else { |
| 1364 | + # Create new article |
| 1365 | + |
| 1366 | + # Set statistics members |
| 1367 | + # We work out if it's countable after PST to avoid counter drift |
| 1368 | + # when articles are created with {{subst:}} |
| 1369 | + $this->mGoodAdjustment = (int)$this->isCountable( $text ); |
| 1370 | + $this->mTotalAdjustment = 1; |
| 1371 | + |
| 1372 | + $dbw->begin(); |
| 1373 | + |
| 1374 | + # Add the page record; stake our claim on this title! |
| 1375 | + # This will fail with a database query exception if the article already exists |
| 1376 | + $newid = $this->insertOn( $dbw ); |
| 1377 | + |
| 1378 | + # Save the revision text... |
1317 | 1379 | $revision = new Revision( array( |
1318 | | - 'page' => $this->getId(), |
| 1380 | + 'page' => $newid, |
1319 | 1381 | 'comment' => $summary, |
1320 | 1382 | 'minor_edit' => $isminor, |
1321 | 1383 | 'text' => $text |
1322 | 1384 | ) ); |
1323 | | - |
1324 | | - $dbw->begin(); |
1325 | 1385 | $revisionId = $revision->insertOn( $dbw ); |
1326 | 1386 | |
1327 | | - # Update page |
1328 | | - $ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision ); |
| 1387 | + $this->mTitle->resetArticleID( $newid ); |
1329 | 1388 | |
1330 | | - if( !$ok ) { |
1331 | | - /* Belated edit conflict! Run away!! */ |
1332 | | - $good = false; |
1333 | | - $dbw->rollback(); |
1334 | | - } else { |
1335 | | - # Update recentchanges |
1336 | | - $bot = (int)($wgUser->isBot() || $forceBot); |
1337 | | - $rcid = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $wgUser, $summary, |
1338 | | - $lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize, |
1339 | | - $revisionId ); |
1340 | | - |
1341 | | - # Mark as patrolled if the user can do so and has it set in their options |
| 1389 | + # Update the page record with revision data |
| 1390 | + $this->updateRevisionOn( $dbw, $revision, 0 ); |
| 1391 | + |
| 1392 | + if( !( $flags & EDIT_SUPPRESS_RC ) ) { |
| 1393 | + $rcid = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary, $bot, |
| 1394 | + '', strlen( $text ), $revisionId ); |
| 1395 | + # Mark as patrolled if the user can and has the option set |
1342 | 1396 | if( $wgUser->isAllowed( 'patrol' ) && $wgUser->getOption( 'autopatrol' ) ) { |
1343 | 1397 | RecentChange::markPatrolled( $rcid ); |
1344 | 1398 | } |
1345 | | - |
1346 | | - $dbw->commit(); |
1347 | 1399 | } |
1348 | | - } else { |
1349 | | - // Keep the same revision ID, but do some updates on it |
1350 | | - $revisionId = $this->getRevIdFetched(); |
| 1400 | + $dbw->commit(); |
| 1401 | + |
| 1402 | + # Update links, etc. |
| 1403 | + $this->editUpdates( $text, $summary, $isminor, $now, $revisionId ); |
| 1404 | + |
| 1405 | + # Clear caches |
| 1406 | + Article::onArticleCreate( $this->mTitle ); |
| 1407 | + |
| 1408 | + wfRunHooks( 'ArticleInsertComplete', array( &$this, &$wgUser, $text, |
| 1409 | + $summary, $flags & EDIT_MINOR, |
| 1410 | + null, null, &$flags ) ); |
1351 | 1411 | } |
1352 | 1412 | |
1353 | | - if( !$wgDBtransactions ) { |
1354 | | - ignore_user_abort( $userAbort ); |
| 1413 | + if ( $good && !( $flags & EDIT_DEFER_UPDATES ) ) { |
| 1414 | + wfDoUpdates(); |
1355 | 1415 | } |
1356 | 1416 | |
1357 | | - if ( $good ) { |
1358 | | - # Invalidate cache of this article and all pages using this article |
1359 | | - # as a template. Partly deferred. |
1360 | | - Article::onArticleEdit( $this->mTitle ); |
1361 | | - |
1362 | | - if ($watchthis) { |
1363 | | - if (!$this->mTitle->userIsWatching()) { |
1364 | | - $dbw->begin(); |
1365 | | - $this->doWatch(); |
1366 | | - $dbw->commit(); |
1367 | | - } |
1368 | | - } else { |
1369 | | - if ( $this->mTitle->userIsWatching() ) { |
1370 | | - $dbw->begin(); |
1371 | | - $this->doUnwatch(); |
1372 | | - $dbw->commit(); |
1373 | | - } |
1374 | | - } |
1375 | | - # Update links tables, site stats, etc. |
1376 | | - $this->editUpdates( $text, $summary, $minor, $now, $revisionId ); |
1377 | | - |
1378 | | - # Output a redirect back to the article |
1379 | | - $this->doRedirect( $this->isRedirect( $text ), $sectionanchor ); |
1380 | | - } |
1381 | 1417 | wfRunHooks( 'ArticleSaveComplete', |
1382 | 1418 | array( &$this, &$wgUser, $text, |
1383 | | - $summary, $minor, |
1384 | | - $watchthis, $sectionanchor ) ); |
1385 | | - wfProfileOut( $fname ); |
| 1419 | + $summary, $flags & EDIT_MINOR, |
| 1420 | + null, null, &$flags ) ); |
| 1421 | + |
| 1422 | + wfProfileOut( __METHOD__ ); |
1386 | 1423 | return $good; |
1387 | 1424 | } |
1388 | 1425 | |
— | — | @@ -1651,7 +1688,6 @@ |
1652 | 1689 | */ |
1653 | 1690 | function delete() { |
1654 | 1691 | global $wgUser, $wgOut, $wgRequest; |
1655 | | - $fname = 'Article::delete'; |
1656 | 1692 | $confirm = $wgRequest->wasPosted() && |
1657 | 1693 | $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ); |
1658 | 1694 | $reason = $wgRequest->getText( 'wpReason' ); |
— | — | @@ -1679,7 +1715,7 @@ |
1680 | 1716 | # Better double-check that it hasn't been deleted yet! |
1681 | 1717 | $dbw =& wfGetDB( DB_MASTER ); |
1682 | 1718 | $conds = $this->mTitle->pageCond(); |
1683 | | - $latest = $dbw->selectField( 'page', 'page_latest', $conds, $fname ); |
| 1719 | + $latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__ ); |
1684 | 1720 | if ( $latest === false ) { |
1685 | 1721 | $wgOut->showFatalError( wfMsg( 'cannotdelete' ) ); |
1686 | 1722 | return; |
— | — | @@ -1769,8 +1805,7 @@ |
1770 | 1806 | * @return array Array of authors, duplicates not removed |
1771 | 1807 | */ |
1772 | 1808 | function getLastNAuthors( $num, $revLatest = 0 ) { |
1773 | | - $fname = 'Article::getLastNAuthors'; |
1774 | | - wfProfileIn( $fname ); |
| 1809 | + wfProfileIn( __METHOD__ ); |
1775 | 1810 | |
1776 | 1811 | // First try the slave |
1777 | 1812 | // If that doesn't have the latest revision, try the master |
— | — | @@ -1783,13 +1818,13 @@ |
1784 | 1819 | 'page_namespace' => $this->mTitle->getNamespace(), |
1785 | 1820 | 'page_title' => $this->mTitle->getDBkey(), |
1786 | 1821 | 'rev_page = page_id' |
1787 | | - ), $fname, $this->getSelectOptions( array( |
| 1822 | + ), __METHOD__, $this->getSelectOptions( array( |
1788 | 1823 | 'ORDER BY' => 'rev_timestamp DESC', |
1789 | 1824 | 'LIMIT' => $num |
1790 | 1825 | ) ) |
1791 | 1826 | ); |
1792 | 1827 | if ( !$res ) { |
1793 | | - wfProfileOut( $fname ); |
| 1828 | + wfProfileOut( __METHOD__ ); |
1794 | 1829 | return array(); |
1795 | 1830 | } |
1796 | 1831 | $row = $db->fetchObject( $res ); |
— | — | @@ -1805,7 +1840,7 @@ |
1806 | 1841 | while ( $row = $db->fetchObject( $res ) ) { |
1807 | 1842 | $authors[] = $row->rev_user_text; |
1808 | 1843 | } |
1809 | | - wfProfileOut( $fname ); |
| 1844 | + wfProfileOut( __METHOD__ ); |
1810 | 1845 | return $authors; |
1811 | 1846 | } |
1812 | 1847 | |
— | — | @@ -1858,8 +1893,7 @@ |
1859 | 1894 | */ |
1860 | 1895 | function doDelete( $reason ) { |
1861 | 1896 | global $wgOut, $wgUser; |
1862 | | - $fname = 'Article::doDelete'; |
1863 | | - wfDebug( $fname."\n" ); |
| 1897 | + wfDebug( __METHOD__."\n" ); |
1864 | 1898 | |
1865 | 1899 | if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason))) { |
1866 | 1900 | if ( $this->doDeleteArticle( $reason ) ) { |
— | — | @@ -1889,8 +1923,7 @@ |
1890 | 1924 | global $wgUseSquid, $wgDeferredUpdateList; |
1891 | 1925 | global $wgPostCommitUpdateList, $wgUseTrackbacks; |
1892 | 1926 | |
1893 | | - $fname = 'Article::doDeleteArticle'; |
1894 | | - wfDebug( $fname."\n" ); |
| 1927 | + wfDebug( __METHOD__."\n" ); |
1895 | 1928 | |
1896 | 1929 | $dbw =& wfGetDB( DB_MASTER ); |
1897 | 1930 | $ns = $this->mTitle->getNamespace(); |
— | — | @@ -1928,18 +1961,18 @@ |
1929 | 1962 | ), array( |
1930 | 1963 | 'page_id' => $id, |
1931 | 1964 | 'page_id = rev_page' |
1932 | | - ), $fname |
| 1965 | + ), __METHOD__ |
1933 | 1966 | ); |
1934 | 1967 | |
1935 | 1968 | # Now that it's safely backed up, delete it |
1936 | | - $dbw->delete( 'revision', array( 'rev_page' => $id ), $fname ); |
1937 | | - $dbw->delete( 'page', array( 'page_id' => $id ), $fname); |
| 1969 | + $dbw->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ ); |
| 1970 | + $dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__); |
1938 | 1971 | |
1939 | 1972 | if ($wgUseTrackbacks) |
1940 | | - $dbw->delete( 'trackbacks', array( 'tb_page' => $id ), $fname ); |
| 1973 | + $dbw->delete( 'trackbacks', array( 'tb_page' => $id ), __METHOD__ ); |
1941 | 1974 | |
1942 | 1975 | # Clean up recentchanges entries... |
1943 | | - $dbw->delete( 'recentchanges', array( 'rc_namespace' => $ns, 'rc_title' => $t ), $fname ); |
| 1976 | + $dbw->delete( 'recentchanges', array( 'rc_namespace' => $ns, 'rc_title' => $t ), __METHOD__ ); |
1944 | 1977 | |
1945 | 1978 | # Finally, clean up the link tables |
1946 | 1979 | $t = $this->mTitle->getPrefixedDBkey(); |
— | — | @@ -1970,7 +2003,6 @@ |
1971 | 2004 | */ |
1972 | 2005 | function rollback() { |
1973 | 2006 | global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol; |
1974 | | - $fname = 'Article::rollback'; |
1975 | 2007 | |
1976 | 2008 | if( $wgUser->isAllowed( 'rollback' ) ) { |
1977 | 2009 | if( $wgUser->isBlocked() ) { |
— | — | @@ -2033,7 +2065,7 @@ |
2034 | 2066 | array( |
2035 | 2067 | 'rev_page' => $current->getPage(), |
2036 | 2068 | "rev_user <> {$user} OR rev_user_text <> {$user_text}" |
2037 | | - ), $fname, |
| 2069 | + ), __METHOD__, |
2038 | 2070 | array( |
2039 | 2071 | 'USE INDEX' => 'page_timestamp', |
2040 | 2072 | 'ORDER BY' => 'rev_timestamp DESC' ) |
— | — | @@ -2061,7 +2093,7 @@ |
2062 | 2094 | 'rc_cur_id' => $current->getPage(), |
2063 | 2095 | 'rc_user_text' => $current->getUserText(), |
2064 | 2096 | "rc_timestamp > '{$s->rev_timestamp}'", |
2065 | | - ), $fname |
| 2097 | + ), __METHOD__ |
2066 | 2098 | ); |
2067 | 2099 | } |
2068 | 2100 | |
— | — | @@ -2113,8 +2145,7 @@ |
2114 | 2146 | function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange, $newid) { |
2115 | 2147 | global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgParser; |
2116 | 2148 | |
2117 | | - $fname = 'Article::editUpdates'; |
2118 | | - wfProfileIn( $fname ); |
| 2149 | + wfProfileIn( __METHOD__ ); |
2119 | 2150 | |
2120 | 2151 | # Parse the text |
2121 | 2152 | $options = new ParserOptions; |
— | — | @@ -2148,7 +2179,7 @@ |
2149 | 2180 | $shortTitle = $this->mTitle->getDBkey(); |
2150 | 2181 | |
2151 | 2182 | if ( 0 == $id ) { |
2152 | | - wfProfileOut( $fname ); |
| 2183 | + wfProfileOut( __METHOD__ ); |
2153 | 2184 | return; |
2154 | 2185 | } |
2155 | 2186 | |
— | — | @@ -2177,7 +2208,7 @@ |
2178 | 2209 | $wgMessageCache->replace( $shortTitle, $text ); |
2179 | 2210 | } |
2180 | 2211 | |
2181 | | - wfProfileOut( $fname ); |
| 2212 | + wfProfileOut( __METHOD__ ); |
2182 | 2213 | } |
2183 | 2214 | |
2184 | 2215 | /** |
— | — | @@ -2277,7 +2308,6 @@ |
2278 | 2309 | * |
2279 | 2310 | */ |
2280 | 2311 | function checkTouched() { |
2281 | | - $fname = 'Article::checkTouched'; |
2282 | 2312 | if( !$this->mDataLoaded ) { |
2283 | 2313 | $this->loadPageData(); |
2284 | 2314 | } |
— | — | @@ -2315,8 +2345,7 @@ |
2316 | 2346 | * @param bool $minor whereas it's a minor modification |
2317 | 2347 | */ |
2318 | 2348 | function quickEdit( $text, $comment = '', $minor = 0 ) { |
2319 | | - $fname = 'Article::quickEdit'; |
2320 | | - wfProfileIn( $fname ); |
| 2349 | + wfProfileIn( __METHOD__ ); |
2321 | 2350 | |
2322 | 2351 | $dbw =& wfGetDB( DB_MASTER ); |
2323 | 2352 | $dbw->begin(); |
— | — | @@ -2331,7 +2360,7 @@ |
2332 | 2361 | $this->updateRevisionOn( $dbw, $revision ); |
2333 | 2362 | $dbw->commit(); |
2334 | 2363 | |
2335 | | - wfProfileOut( $fname ); |
| 2364 | + wfProfileOut( __METHOD__ ); |
2336 | 2365 | } |
2337 | 2366 | |
2338 | 2367 | /** |
— | — | @@ -2405,6 +2434,15 @@ |
2406 | 2435 | */ |
2407 | 2436 | |
2408 | 2437 | static function onArticleCreate($title) { |
| 2438 | + # The talk page isn't in the regular link tables, so we need to update manually: |
| 2439 | + if ( $title->isTalkPage() ) { |
| 2440 | + $other = $title->getSubjectPage(); |
| 2441 | + } else { |
| 2442 | + $other = $title->getTalkPage(); |
| 2443 | + } |
| 2444 | + $other->invalidateCache(); |
| 2445 | + $other->purgeSquid(); |
| 2446 | + |
2409 | 2447 | $title->touchLinks(); |
2410 | 2448 | $title->purgeSquid(); |
2411 | 2449 | } |
— | — | @@ -2458,7 +2496,6 @@ |
2459 | 2497 | */ |
2460 | 2498 | function info() { |
2461 | 2499 | global $wgLang, $wgOut, $wgAllowPageInfo, $wgUser; |
2462 | | - $fname = 'Article::info'; |
2463 | 2500 | |
2464 | 2501 | if ( !$wgAllowPageInfo ) { |
2465 | 2502 | $wgOut->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
— | — | @@ -2487,7 +2524,7 @@ |
2488 | 2525 | 'watchlist', |
2489 | 2526 | 'COUNT(*)', |
2490 | 2527 | $wl_clause, |
2491 | | - $fname, |
| 2528 | + __METHOD__, |
2492 | 2529 | $this->getSelectOptions() ); |
2493 | 2530 | |
2494 | 2531 | $pageInfo = $this->pageCountInfo( $page ); |
— | — | @@ -2524,20 +2561,19 @@ |
2525 | 2562 | $dbr =& wfGetDB( DB_SLAVE ); |
2526 | 2563 | |
2527 | 2564 | $rev_clause = array( 'rev_page' => $id ); |
2528 | | - $fname = 'Article::pageCountInfo'; |
2529 | 2565 | |
2530 | 2566 | $edits = $dbr->selectField( |
2531 | 2567 | 'revision', |
2532 | 2568 | 'COUNT(rev_page)', |
2533 | 2569 | $rev_clause, |
2534 | | - $fname, |
| 2570 | + __METHOD__, |
2535 | 2571 | $this->getSelectOptions() ); |
2536 | 2572 | |
2537 | 2573 | $authors = $dbr->selectField( |
2538 | 2574 | 'revision', |
2539 | 2575 | 'COUNT(DISTINCT rev_user_text)', |
2540 | 2576 | $rev_clause, |
2541 | | - $fname, |
| 2577 | + __METHOD__, |
2542 | 2578 | $this->getSelectOptions() ); |
2543 | 2579 | |
2544 | 2580 | return array( 'edits' => $edits, 'authors' => $authors ); |