Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/263856
Change subject: Use Maintenance DB transaction methods
......................................................................
Use Maintenance DB transaction methods
Change-Id: I8427150bb86949173a56637acdddb042dc0cdc6f
---
M maintenance/updateIndexGranularity.php
1 file changed, 56 insertions(+), 54 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GeoData
refs/changes/56/263856/1
diff --git a/maintenance/updateIndexGranularity.php
b/maintenance/updateIndexGranularity.php
index d9e43f8..77d2de3 100644
--- a/maintenance/updateIndexGranularity.php
+++ b/maintenance/updateIndexGranularity.php
@@ -1,54 +1,56 @@
-<?php
-
-
-$IP = getenv( 'MW_INSTALL_PATH' );
-if ( $IP === false ) {
- $IP = dirname( __FILE__ ) . '/../../..';
-}
-require_once( "$IP/maintenance/Maintenance.php" );
-
-class UpdateIndexGranularity extends Maintenance {
- const BATCH_SIZE = 500;
-
- public function __construct() {
- parent::__construct();
- $this->mDescription = 'Updates GeoData database after
$wgGeoDataIndexGranularity has been changed';
- }
-
- public function execute() {
- global $wgGeoDataIndexGranularity;
- if ( !isset( $wgGeoDataIndexGranularity ) ) {
- $this->error( 'Please install GeoData properly', true );
- }
- $id = 0;
- $dbw = wfGetDB( DB_MASTER );
- do {
- $ids = array();
- $dbw->begin( __METHOD__ );
- $res = $dbw->select( 'geo_tags', 'gt_id',
- array( "gt_id > $id" ),
- __METHOD__,
- array( 'LIMIT' => self::BATCH_SIZE )
- );
- foreach ( $res as $row ) {
- $id = $row->gt_id;
- $ids[] = $id;
- }
- $dbw->update( 'geo_tags',
- array(
- "gt_lat_int = ROUND(gt_lat *
$wgGeoDataIndexGranularity)",
- "gt_lon_int = ROUND(gt_lon *
$wgGeoDataIndexGranularity)"
- ),
- array( 'gt_id' => $ids ),
- __METHOD__
- );
- $dbw->commit( __METHOD__ );
- $this->output( "$id\n" );
- wfWaitForSlaves();
- } while ( count( $ids ) === self::BATCH_SIZE );
- }
-}
-
-$maintClass = 'UpdateIndexGranularity';
-require_once( DO_MAINTENANCE );
-
+<?php
+
+
+$IP = getenv( 'MW_INSTALL_PATH' );
+if ( $IP === false ) {
+ $IP = dirname( __FILE__ ) . '/../../..';
+}
+require_once( "$IP/maintenance/Maintenance.php" );
+
+class UpdateIndexGranularity extends Maintenance {
+ const BATCH_SIZE = 500;
+
+ public function __construct() {
+ parent::__construct();
+ $this->mDescription = 'Updates GeoData database after
$wgGeoDataIndexGranularity has been changed';
+ }
+
+ public function execute() {
+ global $wgGeoDataIndexGranularity;
+ if ( !isset( $wgGeoDataIndexGranularity ) ) {
+ $this->error( 'Please install GeoData properly', true );
+ }
+ $id = 0;
+ $dbw = wfGetDB( DB_MASTER );
+ do {
+ $ids = array();
+
+ $this->beginTransaction( $dbw, __METHOD__ );
+ $res = $dbw->select( 'geo_tags', 'gt_id',
+ array( "gt_id > $id" ),
+ __METHOD__,
+ array( 'LIMIT' => self::BATCH_SIZE )
+ );
+ foreach ( $res as $row ) {
+ $id = $row->gt_id;
+ $ids[] = $id;
+ }
+ $dbw->update( 'geo_tags',
+ array(
+ "gt_lat_int = ROUND(gt_lat *
$wgGeoDataIndexGranularity)",
+ "gt_lon_int = ROUND(gt_lon *
$wgGeoDataIndexGranularity)"
+ ),
+ array( 'gt_id' => $ids ),
+ __METHOD__
+ );
+ $this->commitTransaction( $dbw, __METHOD__ );
+
+ $this->output( "$id\n" );
+ wfWaitForSlaves();
+ } while ( count( $ids ) === self::BATCH_SIZE );
+ }
+}
+
+$maintClass = 'UpdateIndexGranularity';
+require_once( DO_MAINTENANCE );
+
--
To view, visit https://gerrit.wikimedia.org/r/263856
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8427150bb86949173a56637acdddb042dc0cdc6f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GeoData
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits