Index: trunk/phase3/includes/Title.php |
— | — | @@ -3488,15 +3488,14 @@ |
3489 | 3489 | return $status->getErrorsArray(); |
3490 | 3490 | } |
3491 | 3491 | } |
| 3492 | + // Clear RepoGroup process cache |
| 3493 | + RepoGroup::singleton()->clearCache( $this ); |
| 3494 | + RepoGroup::singleton()->clearCache( $nt ); # clear false negative cache |
3492 | 3495 | } |
3493 | | - // Clear RepoGroup process cache |
3494 | | - RepoGroup::singleton()->clearCache( $this ); |
3495 | | - RepoGroup::singleton()->clearCache( $nt ); # clear false negative cache |
3496 | 3496 | |
3497 | 3497 | $dbw->begin(); # If $file was a LocalFile, its transaction would have closed our own. |
3498 | 3498 | $pageid = $this->getArticleID( self::GAID_FOR_UPDATE ); |
3499 | 3499 | $protected = $this->isProtected(); |
3500 | | - $pageCountChange = ( $createRedirect ? 1 : 0 ) - ( $nt->exists() ? 1 : 0 ); |
3501 | 3500 | |
3502 | 3501 | // Do the actual move |
3503 | 3502 | $err = $this->moveToInternal( $nt, $reason, $createRedirect ); |
— | — | @@ -3506,8 +3505,6 @@ |
3507 | 3506 | return $err; |
3508 | 3507 | } |
3509 | 3508 | |
3510 | | - $redirid = $this->getArticleID(); |
3511 | | - |
3512 | 3509 | // Refresh the sortkey for this row. Be careful to avoid resetting |
3513 | 3510 | // cl_timestamp, which may disturb time-based lists on some sites. |
3514 | 3511 | $prefixes = $dbw->select( |
— | — | @@ -3531,6 +3528,8 @@ |
3532 | 3529 | ); |
3533 | 3530 | } |
3534 | 3531 | |
| 3532 | + $redirid = $this->getArticleID(); |
| 3533 | + |
3535 | 3534 | if ( $protected ) { |
3536 | 3535 | # Protect the redirect title as the title used to be... |
3537 | 3536 | $dbw->insertSelect( 'page_restrictions', 'page_restrictions', |
— | — | @@ -3566,50 +3565,8 @@ |
3567 | 3566 | WatchedItem::duplicateEntries( $this, $nt ); |
3568 | 3567 | } |
3569 | 3568 | |
3570 | | - # Update search engine |
3571 | | - $u = new SearchUpdate( $pageid, $nt->getPrefixedDBkey() ); |
3572 | | - $u->doUpdate(); |
3573 | | - $u = new SearchUpdate( $redirid, $this->getPrefixedDBkey(), '' ); |
3574 | | - $u->doUpdate(); |
3575 | | - |
3576 | 3569 | $dbw->commit(); |
3577 | 3570 | |
3578 | | - # Update site_stats |
3579 | | - if ( $this->isContentPage() && !$nt->isContentPage() ) { |
3580 | | - # No longer a content page |
3581 | | - # Not viewed, edited, removing |
3582 | | - $u = new SiteStatsUpdate( 0, 1, -1, $pageCountChange ); |
3583 | | - } elseif ( !$this->isContentPage() && $nt->isContentPage() ) { |
3584 | | - # Now a content page |
3585 | | - # Not viewed, edited, adding |
3586 | | - $u = new SiteStatsUpdate( 0, 1, + 1, $pageCountChange ); |
3587 | | - } elseif ( $pageCountChange ) { |
3588 | | - # Redirect added |
3589 | | - $u = new SiteStatsUpdate( 0, 0, 0, 1 ); |
3590 | | - } else { |
3591 | | - # Nothing special |
3592 | | - $u = false; |
3593 | | - } |
3594 | | - if ( $u ) { |
3595 | | - $u->doUpdate(); |
3596 | | - } |
3597 | | - |
3598 | | - # Update message cache for interface messages |
3599 | | - if ( $this->getNamespace() == NS_MEDIAWIKI ) { |
3600 | | - # @bug 17860: old article can be deleted, if this the case, |
3601 | | - # delete it from message cache |
3602 | | - if ( $this->getArticleID() === 0 ) { |
3603 | | - MessageCache::singleton()->replace( $this->getDBkey(), false ); |
3604 | | - } else { |
3605 | | - $rev = Revision::newFromTitle( $this ); |
3606 | | - MessageCache::singleton()->replace( $this->getDBkey(), $rev->getText() ); |
3607 | | - } |
3608 | | - } |
3609 | | - if ( $nt->getNamespace() == NS_MEDIAWIKI ) { |
3610 | | - $rev = Revision::newFromTitle( $nt ); |
3611 | | - MessageCache::singleton()->replace( $nt->getDBkey(), $rev->getText() ); |
3612 | | - } |
3613 | | - |
3614 | 3571 | wfRunHooks( 'TitleMoveComplete', array( &$this, &$nt, &$wgUser, $pageid, $redirid ) ); |
3615 | 3572 | return true; |
3616 | 3573 | } |
— | — | @@ -3659,36 +3616,18 @@ |
3660 | 3617 | |
3661 | 3618 | $dbw = wfGetDB( DB_MASTER ); |
3662 | 3619 | |
3663 | | - if ( $moveOverRedirect ) { |
3664 | | - $rcts = $dbw->timestamp( $nt->getEarliestRevTime() ); |
| 3620 | + $newpage = WikiPage::factory( $nt ); |
3665 | 3621 | |
| 3622 | + if ( $moveOverRedirect ) { |
3666 | 3623 | $newid = $nt->getArticleID(); |
3667 | | - $newns = $nt->getNamespace(); |
3668 | | - $newdbk = $nt->getDBkey(); |
3669 | 3624 | |
3670 | 3625 | # Delete the old redirect. We don't save it to history since |
3671 | 3626 | # by definition if we've got here it's rather uninteresting. |
3672 | 3627 | # We have to remove it so that the next step doesn't trigger |
3673 | 3628 | # a conflict on the unique namespace+title index... |
3674 | 3629 | $dbw->delete( 'page', array( 'page_id' => $newid ), __METHOD__ ); |
3675 | | - if ( !$dbw->cascadingDeletes() ) { |
3676 | | - $dbw->delete( 'revision', array( 'rev_page' => $newid ), __METHOD__ ); |
3677 | 3630 | |
3678 | | - $dbw->delete( 'pagelinks', array( 'pl_from' => $newid ), __METHOD__ ); |
3679 | | - $dbw->delete( 'imagelinks', array( 'il_from' => $newid ), __METHOD__ ); |
3680 | | - $dbw->delete( 'categorylinks', array( 'cl_from' => $newid ), __METHOD__ ); |
3681 | | - $dbw->delete( 'templatelinks', array( 'tl_from' => $newid ), __METHOD__ ); |
3682 | | - $dbw->delete( 'externallinks', array( 'el_from' => $newid ), __METHOD__ ); |
3683 | | - $dbw->delete( 'langlinks', array( 'll_from' => $newid ), __METHOD__ ); |
3684 | | - $dbw->delete( 'iwlinks', array( 'iwl_from' => $newid ), __METHOD__ ); |
3685 | | - $dbw->delete( 'redirect', array( 'rd_from' => $newid ), __METHOD__ ); |
3686 | | - $dbw->delete( 'page_props', array( 'pp_page' => $newid ), __METHOD__ ); |
3687 | | - } |
3688 | | - // If the target page was recently created, it may have an entry in recentchanges still |
3689 | | - $dbw->delete( 'recentchanges', |
3690 | | - array( 'rc_timestamp' => $rcts, 'rc_namespace' => $newns, 'rc_title' => $newdbk, 'rc_new' => 1 ), |
3691 | | - __METHOD__ |
3692 | | - ); |
| 3631 | + $newpage->doDeleteUpdates( $newid ); |
3693 | 3632 | } |
3694 | 3633 | |
3695 | 3634 | # Save a null revision in the page's history notifying of the move |
— | — | @@ -3698,27 +3637,30 @@ |
3699 | 3638 | } |
3700 | 3639 | $nullRevId = $nullRevision->insertOn( $dbw ); |
3701 | 3640 | |
3702 | | - $now = wfTimestampNow(); |
3703 | 3641 | # Change the name of the target page: |
3704 | 3642 | $dbw->update( 'page', |
3705 | 3643 | /* SET */ array( |
3706 | | - 'page_touched' => $dbw->timestamp( $now ), |
3707 | 3644 | 'page_namespace' => $nt->getNamespace(), |
3708 | 3645 | 'page_title' => $nt->getDBkey(), |
3709 | | - 'page_latest' => $nullRevId, |
3710 | 3646 | ), |
3711 | 3647 | /* WHERE */ array( 'page_id' => $oldid ), |
3712 | 3648 | __METHOD__ |
3713 | 3649 | ); |
| 3650 | + |
| 3651 | + $this->resetArticleID( 0 ); |
3714 | 3652 | $nt->resetArticleID( $oldid ); |
3715 | 3653 | |
3716 | | - $article = WikiPage::factory( $nt ); |
| 3654 | + $newpage->updateRevisionOn( $dbw, $nullRevision ); |
| 3655 | + |
3717 | 3656 | wfRunHooks( 'NewRevisionFromEditComplete', |
3718 | | - array( $article, $nullRevision, $latest, $wgUser ) ); |
3719 | | - $article->setCachedLastEditTime( $now ); |
| 3657 | + array( $newpage, $nullRevision, $latest, $wgUser ) ); |
3720 | 3658 | |
| 3659 | + $newpage->doEditUpdates( $nullRevision, $wgUser, array( 'changed' => false ) ); |
| 3660 | + |
3721 | 3661 | # Recreate the redirect, this time in the other direction. |
3722 | | - if ( $createRedirect || !$wgUser->isAllowed( 'suppressredirect' ) ) { |
| 3662 | + if ( $redirectSuppressed ) { |
| 3663 | + WikiPage::onArticleDelete( $this ); |
| 3664 | + } else { |
3723 | 3665 | $mwRedir = MagicWord::get( 'redirect' ); |
3724 | 3666 | $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n"; |
3725 | 3667 | $redirectArticle = WikiPage::factory( $this ); |
— | — | @@ -3734,33 +3676,13 @@ |
3735 | 3677 | wfRunHooks( 'NewRevisionFromEditComplete', |
3736 | 3678 | array( $redirectArticle, $redirectRevision, false, $wgUser ) ); |
3737 | 3679 | |
3738 | | - # Now, we record the link from the redirect to the new title. |
3739 | | - # It should have no other outgoing links... |
3740 | | - $dbw->delete( 'pagelinks', array( 'pl_from' => $newid ), __METHOD__ ); |
3741 | | - $dbw->insert( 'pagelinks', |
3742 | | - array( |
3743 | | - 'pl_from' => $newid, |
3744 | | - 'pl_namespace' => $nt->getNamespace(), |
3745 | | - 'pl_title' => $nt->getDBkey() ), |
3746 | | - __METHOD__ ); |
| 3680 | + $redirectArticle->doEditUpdates( $redirectRevision, $wgUser, array( 'created' => true ) ); |
3747 | 3681 | } |
3748 | | - } else { |
3749 | | - $this->resetArticleID( 0 ); |
3750 | 3682 | } |
3751 | 3683 | |
3752 | 3684 | # Log the move |
3753 | 3685 | $logid = $logEntry->insert(); |
3754 | 3686 | $logEntry->publish( $logid ); |
3755 | | - |
3756 | | - # Purge caches for old and new titles |
3757 | | - if ( $moveOverRedirect ) { |
3758 | | - # A simple purge is enough when moving over a redirect |
3759 | | - $nt->purgeSquid(); |
3760 | | - } else { |
3761 | | - # Purge caches as per article creation, including any pages that link to this title |
3762 | | - WikiPage::onArticleCreate( $nt ); |
3763 | | - } |
3764 | | - $this->purgeSquid(); |
3765 | 3687 | } |
3766 | 3688 | |
3767 | 3689 | /** |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -1901,10 +1901,6 @@ |
1902 | 1902 | return false; |
1903 | 1903 | } |
1904 | 1904 | |
1905 | | - DeferredUpdates::addUpdate( |
1906 | | - new SiteStatsUpdate( 0, 1, - (int)$this->isCountable(), -1 ) |
1907 | | - ); |
1908 | | - |
1909 | 1905 | // Bitfields to further suppress the content |
1910 | 1906 | if ( $suppress ) { |
1911 | 1907 | $bitfield = 0; |
— | — | @@ -1952,9 +1948,6 @@ |
1953 | 1949 | ), __METHOD__ |
1954 | 1950 | ); |
1955 | 1951 | |
1956 | | - # Delete restrictions for it |
1957 | | - $dbw->delete( 'page_restrictions', array ( 'pr_page' => $id ), __METHOD__ ); |
1958 | | - |
1959 | 1952 | # Now that it's safely backed up, delete it |
1960 | 1953 | $dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__ ); |
1961 | 1954 | $ok = ( $dbw->affectedRows() > 0 ); // getArticleId() uses slave, could be laggy |
— | — | @@ -1964,6 +1957,39 @@ |
1965 | 1958 | return false; |
1966 | 1959 | } |
1967 | 1960 | |
| 1961 | + $this->doDeleteUpdates( $id ); |
| 1962 | + |
| 1963 | + # Log the deletion, if the page was suppressed, log it at Oversight instead |
| 1964 | + $logtype = $suppress ? 'suppress' : 'delete'; |
| 1965 | + |
| 1966 | + $logEntry = new ManualLogEntry( $logtype, 'delete' ); |
| 1967 | + $logEntry->setPerformer( $user ); |
| 1968 | + $logEntry->setTarget( $this->mTitle ); |
| 1969 | + $logEntry->setComment( $reason ); |
| 1970 | + $logid = $logEntry->insert(); |
| 1971 | + $logEntry->publish( $logid ); |
| 1972 | + |
| 1973 | + if ( $commit ) { |
| 1974 | + $dbw->commit(); |
| 1975 | + } |
| 1976 | + |
| 1977 | + wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$user, $reason, $id ) ); |
| 1978 | + return true; |
| 1979 | + } |
| 1980 | + |
| 1981 | + /** |
| 1982 | + * Do some database updates after deletion |
| 1983 | + * |
| 1984 | + * @param $id Int: page_id value of the page being deleted |
| 1985 | + */ |
| 1986 | + public function doDeleteUpdates( $id ) { |
| 1987 | + DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, - (int)$this->isCountable(), -1 ) ); |
| 1988 | + |
| 1989 | + $dbw = wfGetDB( DB_MASTER ); |
| 1990 | + |
| 1991 | + # Delete restrictions for it |
| 1992 | + $dbw->delete( 'page_restrictions', array ( 'pr_page' => $id ), __METHOD__ ); |
| 1993 | + |
1968 | 1994 | # Fix category table counts |
1969 | 1995 | $cats = array(); |
1970 | 1996 | $res = $dbw->select( 'categorylinks', 'cl_to', array( 'cl_from' => $id ), __METHOD__ ); |
— | — | @@ -2008,23 +2034,6 @@ |
2009 | 2035 | |
2010 | 2036 | # Clear the cached article id so the interface doesn't act like we exist |
2011 | 2037 | $this->mTitle->resetArticleID( 0 ); |
2012 | | - |
2013 | | - # Log the deletion, if the page was suppressed, log it at Oversight instead |
2014 | | - $logtype = $suppress ? 'suppress' : 'delete'; |
2015 | | - |
2016 | | - $logEntry = new ManualLogEntry( $logtype, 'delete' ); |
2017 | | - $logEntry->setPerformer( $user ); |
2018 | | - $logEntry->setTarget( $this->mTitle ); |
2019 | | - $logEntry->setComment( $reason ); |
2020 | | - $logid = $logEntry->insert(); |
2021 | | - $logEntry->publish( $logid ); |
2022 | | - |
2023 | | - if ( $commit ) { |
2024 | | - $dbw->commit(); |
2025 | | - } |
2026 | | - |
2027 | | - wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$user, $reason, $id ) ); |
2028 | | - return true; |
2029 | 2038 | } |
2030 | 2039 | |
2031 | 2040 | /** |