[MediaWiki-commits] [Gerrit] Auto-populate wb_property_info in updater. - change (mediawiki...Wikibase)

2013-07-10 Thread Denny Vrandecic (Code Review)
Denny Vrandecic has submitted this change and it was merged.

Change subject: Auto-populate wb_property_info in updater.
..


Auto-populate wb_property_info in updater.

Change-Id: I7ba72849258d26a106eb39b9ac91de9b800042fc
---
M lib/includes/store/sql/PropertyInfoTable.php
M repo/includes/store/sql/PropertyInfoTableBuilder.php
2 files changed, 54 insertions(+), 2 deletions(-)

Approvals:
  Denny Vrandecic: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/includes/store/sql/PropertyInfoTable.php 
b/lib/includes/store/sql/PropertyInfoTable.php
index 8c1c3e0..cd8b99d 100644
--- a/lib/includes/store/sql/PropertyInfoTable.php
+++ b/lib/includes/store/sql/PropertyInfoTable.php
@@ -83,10 +83,40 @@
}
 
$updater-addExtensionTable( $table, $file );
+
+   // populate the table after creating it
+   $updater-addExtensionUpdate( array(
+   array( 'Wikibase\PropertyInfoTable', 
'rebuildPropertyInfo' )
+   ) );
}
}
 
/**
+* Wrapper for invoking PropertyInfoTableBuilder from DatabaseUpdater
+* during a database update.
+*
+* @param \DatabaseUpdater $updater
+*/
+   public static function rebuildPropertyInfo( \DatabaseUpdater $updater ) 
{
+   $reporter = new \ObservableMessageReporter();
+   $reporter-registerReporterCallback(
+   function ( $msg ) use ( $updater ) {
+   $updater-output( ... . $msg . \n );
+   }
+   );
+
+   $table = new PropertyInfoTable( false );
+   $entityLookup = new WikiPageEntityLookup( false );
+
+   $builder = new PropertyInfoTableBuilder( $table, $entityLookup 
);
+   $builder-setReporter( $reporter );
+   $builder-setUseTransactions( false );
+
+   $updater-output( 'Populating ' . $table-getTableName() . \n 
);
+   $builder-rebuildPropertyInfo();
+   }
+
+   /**
 * @see   PropertyInfoStore::getPropertyInfo
 *
 * @param EntityId $propertyId
diff --git a/repo/includes/store/sql/PropertyInfoTableBuilder.php 
b/repo/includes/store/sql/PropertyInfoTableBuilder.php
index 0bd53ac..f183adc 100644
--- a/repo/includes/store/sql/PropertyInfoTableBuilder.php
+++ b/repo/includes/store/sql/PropertyInfoTableBuilder.php
@@ -52,6 +52,13 @@
protected $reporter;
 
/**
+* @since 0.4
+*
+* @var bool
+*/
+   protected $useTransactions = true;
+
+   /**
 * Whether all entries should be updated, or only missing entries
 *
 * @var bool
@@ -136,6 +143,17 @@
}
 
/**
+* Enables or disables transactions.
+* The only good reason to disable transactions is to be able to
+* run the rebuild inside an already existing transaction.
+*
+* @param bool $useTransactions
+*/
+   public function setUseTransactions( $useTransactions ) {
+   $this-useTransactions = $useTransactions;
+   }
+
+   /**
 * Rebuild the property info entries.
 * Use the rebuildPropertyInfo.php maintenance script to invoke this 
from the command line.
 *
@@ -173,7 +191,9 @@
// as that would cause the site to be rendered read 
only.
$this-waitForSlaves( $dbw );
 
-   $dbw-begin();
+   if ( $this-useTransactions ) {
+   $dbw-begin();
+   }
 
$props = $dbw-select(
$tables,
@@ -208,7 +228,9 @@
$c+= 1;
}
 
-   $dbw-commit();
+   if ( $this-useTransactions ) {
+   $dbw-commit();
+   }
 
$this-report( Updated $c properties, up to ID 
$rowId. );
$total += $c;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7ba72849258d26a106eb39b9ac91de9b800042fc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler daniel.kinz...@wikimedia.de
Gerrit-Reviewer: Aude aude.w...@gmail.com
Gerrit-Reviewer: Daniel Werner daniel.wer...@wikimedia.de
Gerrit-Reviewer: Denny Vrandecic denny.vrande...@wikimedia.de
Gerrit-Reviewer: Jeroen De Dauw jeroended...@gmail.com
Gerrit-Reviewer: jenkins-bot

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org

[MediaWiki-commits] [Gerrit] Auto-populate wb_property_info in updater. - change (mediawiki...Wikibase)

2013-07-08 Thread Daniel Kinzler (Code Review)
Daniel Kinzler has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/72515


Change subject: Auto-populate wb_property_info in updater.
..

Auto-populate wb_property_info in updater.

Change-Id: I7ba72849258d26a106eb39b9ac91de9b800042fc
---
M lib/includes/store/sql/PropertyInfoTable.php
M repo/includes/store/sql/PropertyInfoTableBuilder.php
2 files changed, 54 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/15/72515/1

diff --git a/lib/includes/store/sql/PropertyInfoTable.php 
b/lib/includes/store/sql/PropertyInfoTable.php
index 8c1c3e0..cd8b99d 100644
--- a/lib/includes/store/sql/PropertyInfoTable.php
+++ b/lib/includes/store/sql/PropertyInfoTable.php
@@ -83,10 +83,40 @@
}
 
$updater-addExtensionTable( $table, $file );
+
+   // populate the table after creating it
+   $updater-addExtensionUpdate( array(
+   array( 'Wikibase\PropertyInfoTable', 
'rebuildPropertyInfo' )
+   ) );
}
}
 
/**
+* Wrapper for invoking PropertyInfoTableBuilder from DatabaseUpdater
+* during a database update.
+*
+* @param \DatabaseUpdater $updater
+*/
+   public static function rebuildPropertyInfo( \DatabaseUpdater $updater ) 
{
+   $reporter = new \ObservableMessageReporter();
+   $reporter-registerReporterCallback(
+   function ( $msg ) use ( $updater ) {
+   $updater-output( ... . $msg . \n );
+   }
+   );
+
+   $table = new PropertyInfoTable( false );
+   $entityLookup = new WikiPageEntityLookup( false );
+
+   $builder = new PropertyInfoTableBuilder( $table, $entityLookup 
);
+   $builder-setReporter( $reporter );
+   $builder-setUseTransactions( false );
+
+   $updater-output( 'Populating ' . $table-getTableName() . \n 
);
+   $builder-rebuildPropertyInfo();
+   }
+
+   /**
 * @see   PropertyInfoStore::getPropertyInfo
 *
 * @param EntityId $propertyId
diff --git a/repo/includes/store/sql/PropertyInfoTableBuilder.php 
b/repo/includes/store/sql/PropertyInfoTableBuilder.php
index 0bd53ac..f183adc 100644
--- a/repo/includes/store/sql/PropertyInfoTableBuilder.php
+++ b/repo/includes/store/sql/PropertyInfoTableBuilder.php
@@ -52,6 +52,13 @@
protected $reporter;
 
/**
+* @since 0.4
+*
+* @var bool
+*/
+   protected $useTransactions = true;
+
+   /**
 * Whether all entries should be updated, or only missing entries
 *
 * @var bool
@@ -136,6 +143,17 @@
}
 
/**
+* Enables or disables transactions.
+* The only good reason to disable transactions is to be able to
+* run the rebuild inside an already existing transaction.
+*
+* @param bool $useTransactions
+*/
+   public function setUseTransactions( $useTransactions ) {
+   $this-useTransactions = $useTransactions;
+   }
+
+   /**
 * Rebuild the property info entries.
 * Use the rebuildPropertyInfo.php maintenance script to invoke this 
from the command line.
 *
@@ -173,7 +191,9 @@
// as that would cause the site to be rendered read 
only.
$this-waitForSlaves( $dbw );
 
-   $dbw-begin();
+   if ( $this-useTransactions ) {
+   $dbw-begin();
+   }
 
$props = $dbw-select(
$tables,
@@ -208,7 +228,9 @@
$c+= 1;
}
 
-   $dbw-commit();
+   if ( $this-useTransactions ) {
+   $dbw-commit();
+   }
 
$this-report( Updated $c properties, up to ID 
$rowId. );
$total += $c;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7ba72849258d26a106eb39b9ac91de9b800042fc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler daniel.kinz...@wikimedia.de

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