Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -1004,6 +1004,7 @@ |
1005 | 1005 | |
1006 | 1006 | $oldtext = $this->getRawText(); // current revision |
1007 | 1007 | $oldsize = strlen( $oldtext ); |
| 1008 | + $oldcountable = $this->isCountable(); |
1008 | 1009 | |
1009 | 1010 | # Provide autosummaries if one is not provided and autosummaries are enabled. |
1010 | 1011 | if ( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) { |
— | — | @@ -1027,6 +1028,17 @@ |
1028 | 1029 | $userAbort = ignore_user_abort( true ); |
1029 | 1030 | } |
1030 | 1031 | |
| 1032 | + $revision = new Revision( array( |
| 1033 | + 'page' => $this->getId(), |
| 1034 | + 'comment' => $summary, |
| 1035 | + 'minor_edit' => $isminor, |
| 1036 | + 'text' => $text, |
| 1037 | + 'parent_id' => $this->mLatest, |
| 1038 | + 'user' => $user->getId(), |
| 1039 | + 'user_text' => $user->getName(), |
| 1040 | + 'timestamp' => $now |
| 1041 | + ) ); |
| 1042 | + |
1031 | 1043 | $changed = ( strcmp( $text, $oldtext ) != 0 ); |
1032 | 1044 | |
1033 | 1045 | if ( $changed ) { |
— | — | @@ -1039,17 +1051,6 @@ |
1040 | 1052 | return $status; |
1041 | 1053 | } |
1042 | 1054 | |
1043 | | - $revision = new Revision( array( |
1044 | | - 'page' => $this->getId(), |
1045 | | - 'comment' => $summary, |
1046 | | - 'minor_edit' => $isminor, |
1047 | | - 'text' => $text, |
1048 | | - 'parent_id' => $this->mLatest, |
1049 | | - 'user' => $user->getId(), |
1050 | | - 'user_text' => $user->getName(), |
1051 | | - 'timestamp' => $now |
1052 | | - ) ); |
1053 | | - |
1054 | 1055 | $dbw->begin(); |
1055 | 1056 | $revisionId = $revision->insertOn( $dbw ); |
1056 | 1057 | |
— | — | @@ -1095,14 +1096,6 @@ |
1096 | 1097 | $user->incEditCount(); |
1097 | 1098 | $dbw->commit(); |
1098 | 1099 | } |
1099 | | - } else { |
1100 | | - $status->warning( 'edit-no-change' ); |
1101 | | - $revision = null; |
1102 | | - // Keep the same revision ID, but do some updates on it |
1103 | | - $revisionId = $this->getLatest(); |
1104 | | - // Update page_touched, this is usually implicit in the page update |
1105 | | - // Other cache updates are done in onArticleEdit() |
1106 | | - $this->mTitle->invalidateCache(); |
1107 | 1100 | } |
1108 | 1101 | |
1109 | 1102 | if ( !$wgDBtransactions ) { |
— | — | @@ -1115,11 +1108,19 @@ |
1116 | 1109 | return $status; |
1117 | 1110 | } |
1118 | 1111 | |
1119 | | - # Invalidate cache of this article and all pages using this article |
1120 | | - # as a template. Partly deferred. |
1121 | | - self::onArticleEdit( $this->mTitle ); |
1122 | 1112 | # Update links tables, site stats, etc. |
1123 | | - $this->doEditUpdates( $text, $user, $summary, $isminor, $revisionId, $changed ); |
| 1113 | + $this->doEditUpdates( $revision, $user, array( 'changed' => $changed, |
| 1114 | + 'oldcountable' => $oldcountable ) ); |
| 1115 | + |
| 1116 | + if ( !$changed ) { |
| 1117 | + $status->warning( 'edit-no-change' ); |
| 1118 | + $revision = null; |
| 1119 | + // Keep the same revision ID, but do some updates on it |
| 1120 | + $revisionId = $this->getLatest(); |
| 1121 | + // Update page_touched, this is usually implicit in the page update |
| 1122 | + // Other cache updates are done in onArticleEdit() |
| 1123 | + $this->mTitle->invalidateCache(); |
| 1124 | + } |
1124 | 1125 | } else { |
1125 | 1126 | # Create new article |
1126 | 1127 | $status->value['new'] = true; |
— | — | @@ -1180,11 +1181,8 @@ |
1181 | 1182 | $dbw->commit(); |
1182 | 1183 | |
1183 | 1184 | # Update links, etc. |
1184 | | - $this->doEditUpdates( $text, $user, $summary, $isminor, $revisionId, true, true ); |
| 1185 | + $this->doEditUpdates( $revision, $user, array( 'created' => true ) ); |
1185 | 1186 | |
1186 | | - # Clear caches |
1187 | | - self::onArticleCreate( $this->mTitle ); |
1188 | | - |
1189 | 1187 | wfRunHooks( 'ArticleInsertComplete', array( &$this, &$user, $text, $summary, |
1190 | 1188 | $flags & EDIT_MINOR, null, null, &$flags, $revision ) ); |
1191 | 1189 | } |
— | — | @@ -1900,26 +1898,29 @@ |
1901 | 1899 | * Every 100th edit, prune the recent changes table. |
1902 | 1900 | * |
1903 | 1901 | * @private |
1904 | | - * @param $text String: New text of the article |
1905 | | - * @param $user User object: User doing the edit |
1906 | | - * @param $summary String: Edit summary |
1907 | | - * @param $minoredit Boolean: Minor edit |
1908 | | - * @param $newid Integer: rev_id value of the new revision |
1909 | | - * @param $changed Boolean: Whether or not the content actually changed |
1910 | | - * @param $created Boolean: Whether the edit created the page |
| 1902 | + * @param $revision Revision object |
| 1903 | + * @param $user User object that did the revision |
| 1904 | + * @param $options Array of options, following indexes are used: |
| 1905 | + * - changed: boolean, whether the revision changed the content (default true) |
| 1906 | + * - created: boolean, whether the revision created the page (default false) |
| 1907 | + * - oldcountable: boolean or null (default null): |
| 1908 | + * - boolean: whether the page was counted as an article before that |
| 1909 | + * revision, only used in changed is true and created is false |
| 1910 | + * - null: don't change the article count |
1911 | 1911 | */ |
1912 | | - public function doEditUpdates( |
1913 | | - $text, $user, $summary, $minoredit, $newid, $changed = true, $created = false |
1914 | | - ) { |
| 1912 | + public function doEditUpdates( Revision $revision, User $user, array $options = array() ) { |
1915 | 1913 | global $wgDeferredUpdateList, $wgEnableParserCache; |
1916 | 1914 | |
1917 | 1915 | wfProfileIn( __METHOD__ ); |
1918 | 1916 | |
| 1917 | + $options += array( 'changed' => true, 'created' => false, 'oldcountable' => null ); |
| 1918 | + $text = $revision->getText(); |
| 1919 | + |
1919 | 1920 | # Parse the text |
1920 | 1921 | # Be careful not to double-PST: $text is usually already PST-ed once |
1921 | 1922 | if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) { |
1922 | 1923 | wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" ); |
1923 | | - $editInfo = $this->prepareTextForEdit( $text, $newid, $user ); |
| 1924 | + $editInfo = $this->prepareTextForEdit( $text, $revision->getId(), $user ); |
1924 | 1925 | } else { |
1925 | 1926 | wfDebug( __METHOD__ . ": No vary-revision, using prepared edit...\n" ); |
1926 | 1927 | $editInfo = $this->mPreparedEdit; |
— | — | @@ -1935,7 +1936,7 @@ |
1936 | 1937 | $u = new LinksUpdate( $this->mTitle, $editInfo->output ); |
1937 | 1938 | $u->doUpdate(); |
1938 | 1939 | |
1939 | | - wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $changed ) ); |
| 1940 | + wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $options['changed'] ) ); |
1940 | 1941 | |
1941 | 1942 | if ( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) { |
1942 | 1943 | if ( 0 == mt_rand( 0, 99 ) ) { |
— | — | @@ -1962,14 +1963,17 @@ |
1963 | 1964 | return; |
1964 | 1965 | } |
1965 | 1966 | |
1966 | | - if ( !$changed ) { |
| 1967 | + if ( !$options['changed'] ) { |
1967 | 1968 | $good = 0; |
1968 | 1969 | $total = 0; |
1969 | | - } elseif ( $created ) { |
| 1970 | + } elseif ( $options['created'] ) { |
1970 | 1971 | $good = (int)$this->isCountable( $editInfo ); |
1971 | 1972 | $total = 1; |
| 1973 | + } elseif ( $options['oldcountable'] !== null ) { |
| 1974 | + $good = (int)$this->isCountable( $editInfo ) - (int)$options['oldcountable']; |
| 1975 | + $total = 0; |
1972 | 1976 | } else { |
1973 | | - $good = (int)$this->isCountable( $editInfo ) - (int)$this->isCountable(); |
| 1977 | + $good = 0; |
1974 | 1978 | $total = 0; |
1975 | 1979 | } |
1976 | 1980 | |
— | — | @@ -1981,7 +1985,7 @@ |
1982 | 1986 | # load of user talk pages and piss people off, nor if it's a minor edit |
1983 | 1987 | # by a properly-flagged bot. |
1984 | 1988 | if ( $this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $user->getTitleKey() && $changed |
1985 | | - && !( $minoredit && $user->isAllowed( 'nominornewtalk' ) ) |
| 1989 | + && !( $revision->isMinor() && $user->isAllowed( 'nominornewtalk' ) ) |
1986 | 1990 | ) { |
1987 | 1991 | if ( wfRunHooks( 'ArticleEditUpdateNewTalk', array( &$this ) ) ) { |
1988 | 1992 | $other = User::newFromName( $shortTitle, false ); |
— | — | @@ -2002,6 +2006,12 @@ |
2003 | 2007 | MessageCache::singleton()->replace( $shortTitle, $text ); |
2004 | 2008 | } |
2005 | 2009 | |
| 2010 | + if( $options['created'] ) { |
| 2011 | + self::onArticleCreate( $this->mTitle ); |
| 2012 | + } else { |
| 2013 | + self::onArticleEdit( $this->mTitle ); |
| 2014 | + } |
| 2015 | + |
2006 | 2016 | wfProfileOut( __METHOD__ ); |
2007 | 2017 | } |
2008 | 2018 | |
— | — | @@ -2017,8 +2027,7 @@ |
2018 | 2028 | */ |
2019 | 2029 | public function createUpdates( $rev ) { |
2020 | 2030 | global $wgUser; |
2021 | | - $this->doEditUpdates( $rev->getText(), $wgUser, $rev->getComment(), |
2022 | | - $rev->isMinor(), $rev->getId(), true, true ); |
| 2031 | + $this->doEditUpdates( $rev, $wgUser, array( 'created' => true ) ); |
2023 | 2032 | } |
2024 | 2033 | |
2025 | 2034 | /** |
— | — | @@ -2419,17 +2428,6 @@ |
2420 | 2429 | /* |
2421 | 2430 | * @deprecated since 1.19 |
2422 | 2431 | */ |
2423 | | - public function editUpdates( |
2424 | | - $text, $summary, $minoredit, $timestamp_of_pagechange, $newid, |
2425 | | - $changed = true, User $user = null, $created = false |
2426 | | - ) { |
2427 | | - global $wgUser; |
2428 | | - return $this->doEditUpdates( $text, $wgUser, $summary, $minoredit, $newid, $changed, $created ); |
2429 | | - } |
2430 | | - |
2431 | | - /* |
2432 | | - * @deprecated since 1.19 |
2433 | | - */ |
2434 | 2432 | public function viewUpdates() { |
2435 | 2433 | global $wgUser; |
2436 | 2434 | return $this->doViewUpdates( $wgUser ); |
Index: trunk/phase3/includes/specials/SpecialUndelete.php |
— | — | @@ -532,23 +532,18 @@ |
533 | 533 | } |
534 | 534 | |
535 | 535 | $created = (bool)$newid; |
| 536 | + $oldcountable = $article->isCountable(); |
536 | 537 | |
537 | 538 | // Attach the latest revision to the page... |
538 | 539 | $wasnew = $article->updateIfNewerOn( $dbw, $revision, $previousRevId ); |
539 | 540 | if ( $created || $wasnew ) { |
540 | 541 | // Update site stats, link tables, etc |
541 | | - $article->editUpdates( $revision->getText(), $revision->getComment(), |
542 | | - $revision->isMinor(), wfTimestamp(), $revision->getId(), true, null, $created ); |
| 542 | + $user = User::newFromName( $revision->getRawUserText() ); |
| 543 | + $article->doEditUpdates( $revision, $user, array( 'created' => $created, 'oldcountable' => $oldcountable ) ); |
543 | 544 | } |
544 | 545 | |
545 | 546 | wfRunHooks( 'ArticleUndelete', array( &$this->title, $created, $comment ) ); |
546 | 547 | |
547 | | - if( $created ) { |
548 | | - Article::onArticleCreate( $this->title ); |
549 | | - } else { |
550 | | - Article::onArticleEdit( $this->title ); |
551 | | - } |
552 | | - |
553 | 548 | if( $this->title->getNamespace() == NS_FILE ) { |
554 | 549 | $update = new HTMLCacheUpdate( $this->title, 'imagelinks' ); |
555 | 550 | $update->doUpdate(); |
Index: trunk/phase3/includes/Import.php |
— | — | @@ -1000,9 +1000,11 @@ |
1001 | 1001 | if( $user ) { |
1002 | 1002 | $userId = intval( $user->getId() ); |
1003 | 1003 | $userText = $user->getName(); |
| 1004 | + $userObj = $user; |
1004 | 1005 | } else { |
1005 | 1006 | $userId = 0; |
1006 | 1007 | $userText = $this->getUser(); |
| 1008 | + $userObj = new User; |
1007 | 1009 | } |
1008 | 1010 | |
1009 | 1011 | // avoid memory leak...? |
— | — | @@ -1015,6 +1017,7 @@ |
1016 | 1018 | # must create the page... |
1017 | 1019 | $pageId = $article->insertOn( $dbw ); |
1018 | 1020 | $created = true; |
| 1021 | + $oldcountable = null; |
1019 | 1022 | } else { |
1020 | 1023 | $created = false; |
1021 | 1024 | |
— | — | @@ -1031,6 +1034,7 @@ |
1032 | 1035 | $this->title->getPrefixedText() . "]], timestamp " . $this->timestamp . "\n" ); |
1033 | 1036 | return false; |
1034 | 1037 | } |
| 1038 | + $oldcountable = $article->isCountable(); |
1035 | 1039 | } |
1036 | 1040 | |
1037 | 1041 | # @todo FIXME: Use original rev_id optionally (better for backups) |
— | — | @@ -1044,34 +1048,14 @@ |
1045 | 1049 | 'timestamp' => $this->timestamp, |
1046 | 1050 | 'minor_edit' => $this->minor, |
1047 | 1051 | ) ); |
1048 | | - $revId = $revision->insertOn( $dbw ); |
| 1052 | + $revision->insertOn( $dbw ); |
1049 | 1053 | $changed = $article->updateIfNewerOn( $dbw, $revision ); |
1050 | 1054 | |
1051 | | - # To be on the safe side... |
1052 | | - $tempTitle = $GLOBALS['wgTitle']; |
1053 | | - $GLOBALS['wgTitle'] = $this->title; |
1054 | | - |
1055 | | - if ( $created ) { |
1056 | | - wfDebug( __METHOD__ . ": running onArticleCreate\n" ); |
1057 | | - Article::onArticleCreate( $this->title ); |
1058 | | - } elseif( $changed ) { |
1059 | | - wfDebug( __METHOD__ . ": running onArticleEdit\n" ); |
1060 | | - Article::onArticleEdit( $this->title ); |
| 1055 | + if ( $changed !== false ) { |
| 1056 | + wfDebug( __METHOD__ . ": running updates\n" ); |
| 1057 | + $article->doEditUpdates( $revision, $userObj, array( 'created' => $created, 'oldcountable' => $oldcountable ) ); |
1061 | 1058 | } |
1062 | 1059 | |
1063 | | - wfDebug( __METHOD__ . ": running updates\n" ); |
1064 | | - $article->editUpdates( |
1065 | | - $this->getText(), |
1066 | | - $this->getComment(), |
1067 | | - $this->minor, |
1068 | | - $this->timestamp, |
1069 | | - $revId, |
1070 | | - true, |
1071 | | - null, |
1072 | | - $created ); |
1073 | | - |
1074 | | - $GLOBALS['wgTitle'] = $tempTitle; |
1075 | | - |
1076 | 1060 | return true; |
1077 | 1061 | } |
1078 | 1062 | |