Yaron Koren has submitted this change and it was merged.

Change subject: Added deletion of auxiliary tables to setCargoPageData.php
......................................................................


Added deletion of auxiliary tables to setCargoPageData.php

Change-Id: I4423985c1af54ec96f82efdfe3969422fd45ccff
---
M maintenance/setCargoPageData.php
1 file changed, 14 insertions(+), 9 deletions(-)

Approvals:
  Yaron Koren: Checked; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/maintenance/setCargoPageData.php b/maintenance/setCargoPageData.php
index 6fa4236..31ad4f1 100644
--- a/maintenance/setCargoPageData.php
+++ b/maintenance/setCargoPageData.php
@@ -34,28 +34,33 @@
 
        public function __construct() {
                parent::__construct();
-               
+
                $this->mDescription = "Stores a set of data each page in the 
wiki in one or more database tables, for use within Cargo queries.";
        }
 
        public function execute() {
                global $wgCargoPageDataColumns;
 
-               $cdb = CargoUtils::getDB();
-               $dbw = wfGetDB( DB_MASTER );
+               $dbr = wfGetDB( DB_SLAVE );
+               $res = $dbr->select( 'cargo_tables', array( 'field_tables' ),
+                       array( 'main_table' => '_pageData' ) );
 
-               $cdb->dropTable( '_pageData' );
-               $dbw->delete( 'cargo_tables', array( 'main_table' => 
'_pageData' ) );
+               $numRows = $res->numRows();
+               if ( $numRows > 0 ) {
+                       $row = $res->fetchRow();
+                       $fieldTables = unserialize( $row['field_tables'] );
+                       CargoDeleteCargoTable::deleteTable( '_pageData', 
$fieldTables );
+               }
 
                $tableSchema = CargoPageData::getTableSchema();
                $tableSchemaString = $tableSchema->toDBString();
 
+               $cdb = CargoUtils::getDB();
+               $dbw = wfGetDB( DB_MASTER );
                CargoUtils::createCargoTableOrTables( $cdb, $dbw, '_pageData', 
$tableSchema, $tableSchemaString, 0 );
 
-               $dbr = wfGetDB( DB_SLAVE );
-               
-               $pages = $dbr->select( 'page', array( 'page_id' ) ); 
-               
+               $pages = $dbr->select( 'page', array( 'page_id' ) );
+
                while ( $page = $pages->fetchObject() ) {
                        $title = Title::newFromID( $page->page_id );
                        if ( $title == null ) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4423985c1af54ec96f82efdfe3969422fd45ccff
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
Gerrit-Reviewer: Yaron Koren <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to