Tim Starling has uploaded a new change for review.
https://gerrit.wikimedia.org/r/197245
Change subject: Fix exit code from rebuildLocalisationCache.php
......................................................................
Fix exit code from rebuildLocalisationCache.php
When --threads was used, the exit code was unconditionally 0, even if a
child thread threw an exception, because the exit code was "abused" for
the count of rebuilt languages. So, don't do that. We don't really need
a count of rebuilt languages that badly, just pass through the exit
status of the child.
Bug: T92900
Change-Id: I77922e686fe7da4fc25bb7f579ed70e1b107eaca
---
M maintenance/rebuildLocalisationCache.php
1 file changed, 15 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/45/197245/1
diff --git a/maintenance/rebuildLocalisationCache.php
b/maintenance/rebuildLocalisationCache.php
index b04639c..47866dc 100644
--- a/maintenance/rebuildLocalisationCache.php
+++ b/maintenance/rebuildLocalisationCache.php
@@ -113,6 +113,7 @@
$total = count( $codes );
$chunks = array_chunk( $codes, ceil( count( $codes ) / $threads
) );
$pids = array();
+ $parentStatus = 0;
foreach ( $chunks as $codes ) {
// Do not fork for only one thread
$pid = ( $threads > 1 ) ? pcntl_fork() : -1;
@@ -121,9 +122,8 @@
// Child, reseed because there is no bug in PHP:
// http://bugs.php.net/bug.php?id=42465
mt_srand( getmypid() );
- $numRebuilt = $this->doRebuild( $codes, $lc,
$force );
- // Abuse the exit value for the count of
rebuild languages
- exit( $numRebuilt );
+ $this->doRebuild( $codes, $lc, $force );
+ exit( 0 );
} elseif ( $pid === -1 ) {
// Fork failed or one thread, do it serialized
$numRebuilt += $this->doRebuild( $codes, $lc,
$force );
@@ -136,13 +136,20 @@
foreach ( $pids as $pid ) {
$status = 0;
pcntl_waitpid( $pid, $status );
- // Fetch the count from the return value
- $numRebuilt += pcntl_wexitstatus( $status );
+ if ( pcntl_wexitstatus( $status ) ) {
+ // Pass a fatal error code through to the caller
+ $parentStatus = pcntl_wexitstatus( $status );
+ }
}
- $this->output( "$numRebuilt languages rebuilt out of $total\n"
);
- if ( $numRebuilt === 0 ) {
- $this->output( "Use --force to rebuild the caches which
are still fresh.\n" );
+ if ( !$pids ) {
+ $this->output( "$numRebuilt languages rebuilt out of
$total\n" );
+ if ( $numRebuilt === 0 ) {
+ $this->output( "Use --force to rebuild the
caches which are still fresh.\n" );
+ }
+ }
+ if ( $parentStatus ) {
+ exit( $parentStatus );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/197245
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I77922e686fe7da4fc25bb7f579ed70e1b107eaca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Tim Starling <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits