Add a Status and a $reason parameter to TitleMove hook
[lhc/web/wiklou.git] / includes / page / WikiPage.php
index 081af19..6a6b2a6 100644 (file)
@@ -1045,20 +1045,22 @@ class WikiPage implements Page, IDBAccessObject {
                $dbw->startAtomic( __METHOD__ );
 
                if ( !$oldLatest || $oldLatest == $this->lockAndGetLatest() ) {
+                       $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+                       $truncatedFragment = $contLang->truncateForDatabase( $rt->getFragment(), 255 );
                        $dbw->upsert(
                                'redirect',
                                [
                                        'rd_from' => $this->getId(),
                                        'rd_namespace' => $rt->getNamespace(),
                                        'rd_title' => $rt->getDBkey(),
-                                       'rd_fragment' => $rt->getFragment(),
+                                       'rd_fragment' => $truncatedFragment,
                                        'rd_interwiki' => $rt->getInterwiki(),
                                ],
                                [ 'rd_from' ],
                                [
                                        'rd_namespace' => $rt->getNamespace(),
                                        'rd_title' => $rt->getDBkey(),
-                                       'rd_fragment' => $rt->getFragment(),
+                                       'rd_fragment' => $truncatedFragment,
                                        'rd_interwiki' => $rt->getInterwiki(),
                                ],
                                __METHOD__
@@ -2727,8 +2729,13 @@ class WikiPage implements Page, IDBAccessObject {
                        // in the job queue to avoid simultaneous deletion operations would add overhead.
                        // Number of archived revisions cannot be known beforehand, because edits can be made
                        // while deletion operations are being processed, changing the number of archivals.
-                       $archivedRevisionCount = $dbw->selectRowCount(
-                               'archive', '1', [ 'ar_page_id' => $id ], __METHOD__
+                       $archivedRevisionCount = $dbw->selectField(
+                               'archive', 'COUNT(*)',
+                               [
+                                       'ar_namespace' => $this->getTitle()->getNamespace(),
+                                       'ar_title' => $this->getTitle()->getDBkey(),
+                                       'ar_page_id' => $id
+                               ], __METHOD__
                        );
 
                        // Clone the title and wikiPage, so we have the information we need when
@@ -3481,7 +3488,11 @@ class WikiPage implements Page, IDBAccessObject {
                                // Do not include the namespace since there can be multiple aliases to it
                                // due to different namespace text definitions on different wikis. This only
                                // means that some cache invalidations happen that are not strictly needed.
-                               $cache->makeGlobalKey( 'interwiki-page', wfWikiID(), $title->getDBkey() )
+                               $cache->makeGlobalKey(
+                                       'interwiki-page',
+                                       WikiMap::getCurrentWikiDomain()->getId(),
+                                       $title->getDBkey()
+                               )
                        );
                } );
        }