Tpt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/392204 )

Change subject: Uses IndexForPageLookup in ProofreadPage.body.php
......................................................................

Uses IndexForPageLookup in ProofreadPage.body.php

Change-Id: I2f5c4de9d90243ddfd03e203a46e83e229621fce
---
M ProofreadPage.body.php
1 file changed, 15 insertions(+), 49 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage 
refs/changes/04/392204/1

diff --git a/ProofreadPage.body.php b/ProofreadPage.body.php
index 8e7a3b6..e10c3f4 100644
--- a/ProofreadPage.body.php
+++ b/ProofreadPage.body.php
@@ -119,42 +119,6 @@
        }
 
        /**
-        * Query the database to find if the current page is referred in an 
Index page.
-        * @param Title $title
-        */
-       public static function loadIndex( $title ) {
-               $title->prpIndexTitle = null;
-               $result = ProofreadIndexDbConnector::getRowsFromTitle( $title );
-
-               foreach ( $result as $x ) {
-                       $refTitle = Title::makeTitle( $x->page_namespace, 
$x->page_title );
-                       if ( $refTitle !== null && $refTitle->inNamespace( 
self::getIndexNamespaceId() ) ) {
-                               $title->prpIndexTitle = $refTitle;
-                               return;
-                       }
-               }
-
-               $m = explode( '/', $title->getText(), 2 );
-               if ( !isset( $m[1] ) ) {
-                       return;
-               }
-               $imageTitle = Title::makeTitleSafe( NS_FILE, $m[0] );
-               if ( $imageTitle === null ) {
-                       return;
-               }
-               $image = wfFindFile( $imageTitle );
-               // if it is multipage, we use the page order of the file
-               if ( $image && $image->exists() && $image->isMultipage() ) {
-                       $indexTitle = Title::makeTitle(
-                               self::getIndexNamespaceId(), 
$image->getTitle()->getText()
-                       );
-                       if ( $indexTitle !== null ) {
-                               $title->prpIndexTitle = $indexTitle;
-                       }
-               }
-       }
-
-       /**
         * Append javascript variables and code to the page.
         * @param OutputPage $out
         * @return bool
@@ -294,9 +258,9 @@
         * @param boolean $deleted indicates whether the page was deleted
         */
        private static function updateIndexOfPage( Title $title, $deleted = 
false ) {
-               self::loadIndex( $title );
-               if ( $title->prpIndexTitle !== null ) {
-                       $indexTitle = $title->prpIndexTitle;
+               $indexTitle = Context::getDefaultContext()
+                       ->getIndexForPageLookup()->getIndexForPageTitle( $title 
);
+               if ( $indexTitle !== null ) {
                        $indexTitle->invalidateCache();
                        $index = WikiPage::factory( $indexTitle );
                        if ( $index ) {
@@ -325,22 +289,21 @@
                }
 
                /* check if there is an index */
-               if ( !isset( $title->prpIndexTitle ) ) {
-                       self::loadIndex( $title );
-               }
-               if ( $title->prpIndexTitle === null ) {
+               $indexTitle = Context::getDefaultContext()
+                       ->getIndexForPageLookup()->getIndexForPageTitle( $title 
);
+               if ( $indexTitle === null ) {
                        return true;
                }
 
                /**
                 * invalidate the cache of the index page
                 */
-               $title->prpIndexTitle->invalidateCache();
+               $indexTitle->invalidateCache();
 
                /**
                 * update pr_index iteratively
                 */
-               $indexId = $title->prpIndexTitle->getArticleID();
+               $indexId = $indexTitle->getArticleID();
                $indexData = 
ProofreadIndexDbConnector::getIndexDataFromIndexPageId( $indexId );
                if ( $indexData ) {
                        ProofreadIndexDbConnector::replaceIndexById( 
$indexData, $indexId, $article );
@@ -420,10 +383,13 @@
                }
 
                if ( $nt->inNamespace( self::getPageNamespaceId() ) ) {
-                       self::loadIndex( $nt );
-                       if ( $nt->prpIndexTitle !== null
-                               && ( !isset( $ot->prpIndexTitle ) ||
-                               ( $nt->prpIndexTitle->equals( 
$ot->prpIndexTitle ) ) )
+                       $oldIndexTitle = Context::getDefaultContext()
+                               
->getIndexForPageLookup()->getIndexForPageTitle( $ot );
+                       $newIndexTitle = Context::getDefaultContext()
+                               
->getIndexForPageLookup()->getIndexForPageTitle( $nt );
+                       if ( $newIndexTitle !== null
+                               && ( $oldIndexTitle === null ||
+                               ( $newIndexTitle->equals( $oldIndexTitle ) ) )
                        ) {
                                self::updateIndexOfPage( $nt );
                        }

-- 
To view, visit https://gerrit.wikimedia.org/r/392204
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2f5c4de9d90243ddfd03e203a46e83e229621fce
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Tpt <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to