Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/264102
Change subject: Revert "Add simple JobQueueMemory class for testing"
......................................................................
Revert "Add simple JobQueueMemory class for testing"
Causes zend phpunit tests to segfault, shouldn't have been merged over CI.
This reverts commit 3592f8cea3710fd6f284c5b07625e588edbab0d0.
Change-Id: I4b4456b1e41811d448f73e6cc34ff6723fc1fc33
---
M autoload.php
D includes/jobqueue/JobQueueMemory.php
M tests/phpunit/phpunit.php
3 files changed, 0 insertions(+), 175 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/02/264102/1
diff --git a/autoload.php b/autoload.php
index 7dec6b7..7fde81c 100644
--- a/autoload.php
+++ b/autoload.php
@@ -611,7 +611,6 @@
'JobQueueError' => __DIR__ . '/includes/jobqueue/JobQueue.php',
'JobQueueFederated' => __DIR__ .
'/includes/jobqueue/JobQueueFederated.php',
'JobQueueGroup' => __DIR__ . '/includes/jobqueue/JobQueueGroup.php',
- 'JobQueueMemory' => __DIR__ . '/includes/jobqueue/JobQueueMemory.php',
'JobQueueRedis' => __DIR__ . '/includes/jobqueue/JobQueueRedis.php',
'JobRunner' => __DIR__ . '/includes/jobqueue/JobRunner.php',
'JobSpecification' => __DIR__ .
'/includes/jobqueue/JobSpecification.php',
diff --git a/includes/jobqueue/JobQueueMemory.php
b/includes/jobqueue/JobQueueMemory.php
deleted file mode 100644
index c5d7257..0000000
--- a/includes/jobqueue/JobQueueMemory.php
+++ /dev/null
@@ -1,169 +0,0 @@
-<?php
-/**
- * PHP memory-backed job queue code.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @author Aaron Schulz
- */
-
-/**
- * Class to handle job queues stored in PHP memory for testing
- *
- * JobQueueGroup does not remember every queue instance, so statically track
it here
- *
- * @ingroup JobQueue
- * @since 1.27
- */
-class JobQueueMemory extends JobQueue {
- /** @var array[] */
- protected static $data = array();
-
- protected function doBatchPush( array $jobs, $flags ) {
- $unclaimed =& $this->getQueueData( 'unclaimed', array() );
-
- /** @var IJobSpecification[] $jobs */
- foreach ( $jobs as $job ) {
- if ( $job->ignoreDuplicates() ) {
- $sha1 = Wikimedia\base_convert(
- sha1( serialize(
$job->getDeduplicationInfo() ) ),
- 16, 36, 31
- );
- if ( !isset( $unclaimed[$sha1] ) ) {
- $unclaimed[$sha1] = $job;
- }
- } else {
- $unclaimed[] = $job;
- }
- }
- }
-
- protected function supportedOrders() {
- return array( 'random', 'timestamp', 'fifo' );
- }
-
- protected function optimalOrder() {
- return array( 'fifo' );
- }
-
- protected function doIsEmpty() {
- return ( $this->doGetSize() == 0 );
- }
-
- protected function doGetSize() {
- $unclaimed = $this->getQueueData( 'unclaimed' );
-
- return $unclaimed ? count( $unclaimed ) : 0;
- }
-
- protected function doGetAcquiredCount() {
- $claimed = $this->getQueueData( 'claimed' );
-
- return $claimed ? count( $claimed ) : 0;
- }
-
- protected function doPop() {
- if ( $this->doGetSize() == 0 ) {
- return false;
- }
-
- $unclaimed =& $this->getQueueData( 'unclaimed' );
- $claimed =& $this->getQueueData( 'claimed', array() );
-
- if ( $this->order === 'random' ) {
- $key = array_rand( $unclaimed );
- } else {
- reset( $unclaimed );
- $key = key( $unclaimed );
- }
-
- $spec = $unclaimed[$key];
- unset( $unclaimed[$key] );
- $claimed[] = $spec;
-
- $job = $this->jobFromSpecInternal( $spec );
-
- end( $claimed );
- $job->metadata['claimId'] = key( $claimed );
-
- return $job;
- }
-
- protected function doAck( Job $job ) {
- if ( $this->getAcquiredCount() == 0 ) {
- return;
- }
-
- $claimed =& $this->getQueueData( 'claimed' );
- unset( $claimed[$job->metadata['claimId']] );
- }
-
- protected function doDelete() {
- if ( isset( self::$data[$this->type][$this->wiki] ) ) {
- unset( self::$data[$this->type][$this->wiki] );
- if ( !self::$data[$this->type] ) {
- unset( self::$data[$this->type] );
- }
- }
- }
-
- public function getAllQueuedJobs() {
- $unclaimed = $this->getQueueData( 'unclaimed' );
- if ( !$unclaimed ) {
- return new ArrayIterator( array() );
- }
-
- $that = $this;
- return new MappedIterator(
- $unclaimed,
- function ( $value ) use ( $that ) {
- $that->jobFromSpecInternal( $value );
- }
- );
- }
-
- public function getAllAcquiredJobs() {
- $claimed = $this->getQueueData( 'claimed' );
- if ( !$claimed ) {
- return new ArrayIterator( array() );
- }
-
- $that = $this;
- return new MappedIterator(
- $claimed,
- function ( $value ) use ( $that ) {
- $that->jobFromSpecInternal( $value );
- }
- );
- }
-
- public function jobFromSpecInternal( IJobSpecification $spec ) {
- return Job::factory( $spec->getType(), $spec->getTitle(),
$spec->getParams() );
- }
-
- private function &getQueueData( $field, $init = null ) {
- if ( !isset( self::$data[$this->type][$this->wiki][$field] ) ) {
- if ( $init !== null ) {
- self::$data[$this->type][$this->wiki][$field] =
$init;
- } else {
- return null;
- }
- }
-
- return self::$data[$this->type][$this->wiki][$field];
- }
-}
diff --git a/tests/phpunit/phpunit.php b/tests/phpunit/phpunit.php
index 0ae0b21..ee0358c 100755
--- a/tests/phpunit/phpunit.php
+++ b/tests/phpunit/phpunit.php
@@ -75,7 +75,6 @@
global $wgLocaltimezone, $wgLocalisationCacheConf;
global $wgDevelopmentWarnings;
global $wgSessionProviders;
- global $wgJobTypeConf;
// Inject test autoloader
require_once __DIR__ . '/../TestsAutoLoader.php';
@@ -98,10 +97,6 @@
$wgLanguageConverterCacheType = 'hash';
// Uses db-replicated in DefaultSettings
$wgMainStash = 'hash';
- // Use memory job queue
- $wgJobTypeConf = array(
- 'default' => array( 'class' => 'JobQueueMemory',
'order' => 'fifo' ),
- );
$wgUseDatabaseMessages = false; # Set for future resets
--
To view, visit https://gerrit.wikimedia.org/r/264102
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4b4456b1e41811d448f73e6cc34ff6723fc1fc33
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits