jenkins-bot has submitted this change and it was merged.
Change subject: Make compatible with MediaWiki code sniffer 0.5.0
......................................................................
Make compatible with MediaWiki code sniffer 0.5.0
Currently we can not switch to 0.5.0 because core still requires
0.4.0. Composer fails on our CI when it tries to resolve the
dependencies for core + Wikibase. But what we can do is making core's
live easier when it switches to 0.5.0 some day.
Change-Id: Icf8d5742173adc5bd96b0f573e29180397ce9c41
---
M composer.json
M lib/includes/store/sql/PropertyInfoTable.php
M repo/includes/Dumpers/DumpGenerator.php
M repo/includes/store/sql/DispatchStats.php
M repo/includes/store/sql/ItemsPerSiteBuilder.php
M repo/includes/store/sql/SqlChangeDispatchCoordinator.php
M repo/maintenance/importProperties.php
M repo/tests/phpunit/includes/api/RemoveClaimsTest.php
8 files changed, 61 insertions(+), 52 deletions(-)
Approvals:
Daniel Kinzler: Looks good to me, approved
jenkins-bot: Verified
diff --git a/composer.json b/composer.json
index c4cb032..89b60a6 100644
--- a/composer.json
+++ b/composer.json
@@ -47,7 +47,7 @@
},
"require-dev": {
"jakub-onderka/php-parallel-lint": "0.9",
- "mediawiki/mediawiki-codesniffer": "0.4.0"
+ "mediawiki/mediawiki-codesniffer": "0.4.0|0.5.0"
},
"conflict": {
"mediawiki/mediawiki": "<1.25"
diff --git a/lib/includes/store/sql/PropertyInfoTable.php
b/lib/includes/store/sql/PropertyInfoTable.php
index 54e96bf..8fcfcfb 100644
--- a/lib/includes/store/sql/PropertyInfoTable.php
+++ b/lib/includes/store/sql/PropertyInfoTable.php
@@ -81,7 +81,7 @@
private function decodeResult( ResultWrapper $res ) {
$infos = array();
- while ( ( $row = $res->fetchObject() ) !== false ) {
+ foreach ( $res as $row ) {
$info = $this->decodeBlob( $row->pi_info );
if ( $info === null ) {
diff --git a/repo/includes/Dumpers/DumpGenerator.php
b/repo/includes/Dumpers/DumpGenerator.php
index dd60ef5..62fcd7e 100644
--- a/repo/includes/Dumpers/DumpGenerator.php
+++ b/repo/includes/Dumpers/DumpGenerator.php
@@ -264,7 +264,12 @@
$this->preDump();
// Iterate over batches of IDs, maintaining the current
position of the pager in the $position variable.
- while ( $ids = $idPager->fetchIds( $this->batchSize ) ) {
+ while ( true ) {
+ $ids = $idPager->fetchIds( $this->batchSize );
+ if ( !$ids ) {
+ break;
+ }
+
$this->dumpEntities( $ids, $dumpCount );
$this->progressReporter->reportMessage( 'Processed ' .
$dumpCount . ' entities.' );
diff --git a/repo/includes/store/sql/DispatchStats.php
b/repo/includes/store/sql/DispatchStats.php
index 763a781..fc107ea 100644
--- a/repo/includes/store/sql/DispatchStats.php
+++ b/repo/includes/store/sql/DispatchStats.php
@@ -86,7 +86,7 @@
$this->clientStates = array();
- while ( ( $row = $res->fetchObject() ) !== false ) {
+ foreach ( $res as $row ) {
if ( $this->changeStats ) {
// time between last dispatch and now
$row->chd_untouched = max( 0, $now
diff --git a/repo/includes/store/sql/ItemsPerSiteBuilder.php
b/repo/includes/store/sql/ItemsPerSiteBuilder.php
index 3133d4b..bfbdfd6 100644
--- a/repo/includes/store/sql/ItemsPerSiteBuilder.php
+++ b/repo/includes/store/sql/ItemsPerSiteBuilder.php
@@ -82,12 +82,16 @@
public function rebuild( EntityIdPager $entityIdPager ) {
$this->report( 'Start rebuild...' );
- $i = 0;
- while ( $ids = $entityIdPager->fetchIds( $this->batchSize ) ) {
- $i = $i + $this->rebuildSiteLinks( $ids );
+ $total = 0;
+ while ( true ) {
+ $ids = $entityIdPager->fetchIds( $this->batchSize );
+ if ( !$ids ) {
+ break;
+ }
- $this->report( 'Processed ' . $i . ' entities.' );
- }
+ $total += $this->rebuildSiteLinks( $ids );
+ $this->report( 'Processed ' . $total . ' entities.' );
+ };
$this->report( 'Rebuild done.' );
}
diff --git a/repo/includes/store/sql/SqlChangeDispatchCoordinator.php
b/repo/includes/store/sql/SqlChangeDispatchCoordinator.php
index 52af1ba..b4defc3 100644
--- a/repo/includes/store/sql/SqlChangeDispatchCoordinator.php
+++ b/repo/includes/store/sql/SqlChangeDispatchCoordinator.php
@@ -410,9 +410,9 @@
// Limit the list to $randomness items. Candidates will be
picked
// from the resulting list at random.
- $res = $db->select(
+ $candidates = $db->selectFieldValues(
$this->stateTable,
- array( 'chd_site' ),
+ 'chd_site',
array( '( chd_lock is NULL ' . // not locked or...
' OR chd_touched < ' . $db->addQuotes(
$staleLockTime ) . ' ) ', // ...the lock is old
'( chd_touched < ' . $db->addQuotes(
$freshDispatchTime ) . // and wasn't touched too recently or...
@@ -427,11 +427,6 @@
)
);
- $candidates = array();
- while ( $row = $res->fetchRow() ) {
- $candidates[] = $row['chd_site'];
- }
-
return $candidates;
}
@@ -442,19 +437,14 @@
public function initState() {
$db = $this->getRepoMaster();
- $res = $db->select( $this->stateTable,
- array( 'chd_site' ),
+ $trackedSiteIds = $db->selectFieldValues(
+ $this->stateTable,
+ 'chd_site',
array(),
- __METHOD__ );
+ __METHOD__
+ );
- $tracked = array();
-
- while ( $row = $res->fetchRow() ) {
- $k = $row[ 'chd_site' ];
- $tracked[$k] = $k;
- }
-
- $untracked = array_diff_key( $this->clientWikis, $tracked );
+ $untracked = array_diff_key( $this->clientWikis, array_flip(
$trackedSiteIds ) );
foreach ( $untracked as $siteID => $wikiDB ) {
$state = array(
diff --git a/repo/maintenance/importProperties.php
b/repo/maintenance/importProperties.php
index d2ed96a..84490b1 100644
--- a/repo/maintenance/importProperties.php
+++ b/repo/maintenance/importProperties.php
@@ -103,31 +103,36 @@
$currentProperties = array();
$count = 0;
$ok = true;
- while ( $link = fgetcsv( $file, 0, "\t" ) ) {
- if ( $link[0] !== $current ) {
- if ( !empty( $currentProperties ) ) {
- $ok = $this->createProperty(
$currentProperties );
-
- if ( !$ok && !$this->ignoreErrors ) {
- break;
- }
- }
-
- $count++;
- if ( ( $this->skip !== 0 ) && ( $this->skip >
$count ) ) {
- continue;
- }
- if ( ( $this->only !== 0 ) && ( $this->only !==
$count ) ) {
- if ( $this->only < $count ) {
- break;
- }
- continue;
- }
-
- $current = $link[0];
- $this->maybePrint( "Processing `$current`" );
- $currentProperties = array( $languageCode =>
$current );
+ while ( true ) {
+ $link = fgetcsv( $file, 0, "\t" );
+ if ( !$link ) {
+ break;
+ } elseif ( $link[0] === $current ) {
+ continue;
}
+
+ if ( !empty( $currentProperties ) ) {
+ $ok = $this->createProperty( $currentProperties
);
+
+ if ( !$ok && !$this->ignoreErrors ) {
+ break;
+ }
+ }
+
+ $count++;
+ if ( ( $this->skip !== 0 ) && ( $this->skip > $count )
) {
+ continue;
+ }
+ if ( ( $this->only !== 0 ) && ( $this->only !== $count
) ) {
+ if ( $this->only < $count ) {
+ break;
+ }
+ continue;
+ }
+
+ $current = $link[0];
+ $this->maybePrint( "Processing `$current`" );
+ $currentProperties = array( $languageCode => $current );
}
if ( !$ok && !$this->ignoreErrors ) {
diff --git a/repo/tests/phpunit/includes/api/RemoveClaimsTest.php
b/repo/tests/phpunit/includes/api/RemoveClaimsTest.php
index d93051d..011fac1 100644
--- a/repo/tests/phpunit/includes/api/RemoveClaimsTest.php
+++ b/repo/tests/phpunit/includes/api/RemoveClaimsTest.php
@@ -99,7 +99,12 @@
$statements = $item->getStatements()->toArray();
$obtainedStatements = null;
- while ( $statement = array_shift( $statements ) ) {
+ while ( true ) {
+ $statement = array_shift( $statements );
+ if ( !$statement ) {
+ break;
+ }
+
$this->makeTheRequest( array( $statement->getGuid() ) );
/** @var Item $obtainedItem */
--
To view, visit https://gerrit.wikimedia.org/r/250040
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icf8d5742173adc5bd96b0f573e29180397ce9c41
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: JanZerebecki <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits