[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: Fix to not delete data from "read-only" tables

2018-01-21 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/405660 )

Change subject: Fix to not delete data from "read-only" tables
..


Fix to not delete data from "read-only" tables

i.e., tables that have an existing "replacement table".

Change-Id: Ie0dc47b5e5b81aabbae68f2a50a2441dd1d2cfdf
---
M Cargo.hooks.php
1 file changed, 8 insertions(+), 1 deletion(-)

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



diff --git a/Cargo.hooks.php b/Cargo.hooks.php
index e7ab103..58b7a9b 100644
--- a/Cargo.hooks.php
+++ b/Cargo.hooks.php
@@ -122,7 +122,9 @@
}
 
/**
-* Delete a page
+* Deletes all Cargo data for a specific page - *except* data
+* contained in Cargo tables which are read-only because their
+* "replacement table" exists.
 *
 * @param int $pageID
 * @TODO - move this to a different class, like CargoUtils?
@@ -142,6 +144,11 @@
while ( $row = $dbw->fetchRow( $res ) ) {
$curMainTable = $row['table_name'];
 
+   if ( $cdb->tableExists( $curMainTable . '__NEXT' ) ) {
+   // It's a "read-only" table - ignore.
+   continue;
+   }
+
// First, delete from the "field" tables.
$res2 = $dbw->select( 'cargo_tables', 'field_tables', 
array( 'main_table' => $curMainTable ) );
$row2 = $dbw->fetchRow( $res2 );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie0dc47b5e5b81aabbae68f2a50a2441dd1d2cfdf
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren 
Gerrit-Reviewer: Yaron Koren 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...Cargo[master]: Fix to not delete data from "read-only" tables

2018-01-21 Thread Yaron Koren (Code Review)
Yaron Koren has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405660 )

Change subject: Fix to not delete data from "read-only" tables
..

Fix to not delete data from "read-only" tables

i.e., tables that have an existing "replacement table".

Change-Id: Ie0dc47b5e5b81aabbae68f2a50a2441dd1d2cfdf
---
M Cargo.hooks.php
1 file changed, 8 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/60/405660/2

diff --git a/Cargo.hooks.php b/Cargo.hooks.php
index e7ab103..58b7a9b 100644
--- a/Cargo.hooks.php
+++ b/Cargo.hooks.php
@@ -122,7 +122,9 @@
}
 
/**
-* Delete a page
+* Deletes all Cargo data for a specific page - *except* data
+* contained in Cargo tables which are read-only because their
+* "replacement table" exists.
 *
 * @param int $pageID
 * @TODO - move this to a different class, like CargoUtils?
@@ -142,6 +144,11 @@
while ( $row = $dbw->fetchRow( $res ) ) {
$curMainTable = $row['table_name'];
 
+   if ( $cdb->tableExists( $curMainTable . '__NEXT' ) ) {
+   // It's a "read-only" table - ignore.
+   continue;
+   }
+
// First, delete from the "field" tables.
$res2 = $dbw->select( 'cargo_tables', 'field_tables', 
array( 'main_table' => $curMainTable ) );
$row2 = $dbw->fetchRow( $res2 );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie0dc47b5e5b81aabbae68f2a50a2441dd1d2cfdf
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits