Mwjames has uploaded a new change for review.

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


Change subject: Rename PropertySubjectsUpdateDispatcherJob
......................................................................

Rename PropertySubjectsUpdateDispatcherJob

Change-Id: I995b9a69dd4a9ea4b5ff88ef8dafbccd48230683
---
M includes/ChangeObserver.php
M includes/Setup.php
R includes/jobs/UpdateDispatcherJob.php
R tests/phpunit/includes/jobs/UpdateDispatcherJobTest.php
4 files changed, 41 insertions(+), 30 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticMediaWiki 
refs/changes/00/77500/1

diff --git a/includes/ChangeObserver.php b/includes/ChangeObserver.php
index 58c0920..81d9611 100644
--- a/includes/ChangeObserver.php
+++ b/includes/ChangeObserver.php
@@ -131,10 +131,10 @@
         */
        public function runUpdateDispatcher( TitleAccess $subject ) {
 
-               $dispatcher = new PropertySubjectsUpdateDispatcherJob( 
$subject->getTitle() );
+               $dispatcher = new UpdateDispatcherJob( $subject->getTitle() );
                $dispatcher->setSettings( $this->getSettings() );
 
-               if ( $this->getSettings()->get( 'smwgDeferredPropertyUpdate' ) 
) {
+               if ( $this->getSettings()->get( 'smwgDeferredPropertyUpdate' ) 
&& class_exists( '\SMW\PropertyPageIdMapper' ) ) {
                        $dispatcher->insert(); // JobQueue is handling 
dispatching
                } else {
                        $dispatcher->run();
diff --git a/includes/Setup.php b/includes/Setup.php
index daeeff8..dac5534 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -434,8 +434,8 @@
        $wgJobClasses['SMWRefreshJob']      = 'SMWRefreshJob';
        $wgAutoloadClasses['SMWRefreshJob'] = $smwgIP . 
'includes/jobs/SMW_RefreshJob.php';
 
-       $wgJobClasses['SMW\PropertySubjectsUpdateDispatcherJob']      = 
'SMW\PropertySubjectsUpdateDispatcherJob';
-       $wgAutoloadClasses['SMW\PropertySubjectsUpdateDispatcherJob'] = $smwgIP 
. 'includes/jobs/PropertySubjectsUpdateDispatcherJob.php';
+       $wgJobClasses['SMW\UpdateDispatcherJob']      = 
'SMW\UpdateDispatcherJob';
+       $wgAutoloadClasses['SMW\UpdateDispatcherJob'] = $smwgIP . 
'includes/jobs/UpdateDispatcherJob.php';
 
        // API modules
        $wgAutoloadClasses['SMW\ApiBase']    = $smwgIP . 
'includes/api/ApiBase.php';
diff --git a/includes/jobs/PropertySubjectsUpdateDispatcherJob.php 
b/includes/jobs/UpdateDispatcherJob.php
similarity index 80%
rename from includes/jobs/PropertySubjectsUpdateDispatcherJob.php
rename to includes/jobs/UpdateDispatcherJob.php
index 2752a55..9d9397e 100644
--- a/includes/jobs/PropertySubjectsUpdateDispatcherJob.php
+++ b/includes/jobs/UpdateDispatcherJob.php
@@ -6,8 +6,9 @@
 use Job;
 
 /**
- * Background dispatch to generate necessary UpdateJob's in order
- * to restore the data parity between a property in its attached subjects
+ * Dispatcher class to either run in deferred or immediate mode to generate
+ * necessary UpdateJob's to restore the data parity between a property
+ * and its attached subjects
  *
  * @file
  *
@@ -18,13 +19,14 @@
  */
 
 /**
- * Background dispatch to generate necessary UpdateJob's in order
- * to restore the data parity between a property in its attached subjects
+ * Dispatcher class to either run in deferred or immediate mode to generate
+ * necessary UpdateJob's to restore the data parity between a property
+ * and its attached subjects
  *
  * @ingroup Job
  * @ingroup Dispatcher
  */
-class PropertySubjectsUpdateDispatcherJob extends JobBase {
+class UpdateDispatcherJob extends JobBase {
 
        /** $var Job */
        protected $jobs = array();
@@ -40,8 +42,8 @@
         * @param integer $id job id
         */
        public function __construct( Title $title, $params = array(), $id = 0 ) 
{
-               parent::__construct( 'SMW\PropertySubjectsUpdateDispatcherJob', 
$title, $params, $id );
-               $this->store = StoreFactory::getStore( isset( $params['store'] 
) ? $params['store'] : null );
+               parent::__construct( 'SMW\UpdateDispatcherJob', $title, 
$params, $id );
+               $this->removeDuplicates = true;
        }
 
        /**
@@ -68,7 +70,7 @@
                Profiler::In( __METHOD__, true );
 
                if ( $this->title->getNamespace() === SMW_NS_PROPERTY ) {
-                       $this->getSubjects( DIProperty::newFromUserLabel( 
$this->title->getText() ) )->push();
+                       $this->distribute( DIProperty::newFromUserLabel( 
$this->title->getText() ) )->push();
                }
 
                Profiler::Out( __METHOD__, true );
@@ -94,11 +96,11 @@
         *
         * @param DIProperty $property
         */
-       protected function getSubjects( DIProperty $property ) {
+       protected function distribute( DIProperty $property ) {
                Profiler::In( __METHOD__, true );
 
                // Array of all subjects that have some value for the given 
property
-               $subjects = $this->store->getAllPropertySubjects( $property );
+               $subjects = $this->getStore()->getAllPropertySubjects( 
$property );
 
                $this->addJobs( $subjects );
 
@@ -110,7 +112,7 @@
 
                // Fetch all those that have an error property attached and
                // re-run it through the job-queue
-               $subjects = $this->store->getPropertySubjects(
+               $subjects = $this->getStore()->getPropertySubjects(
                        new DIProperty( DIProperty::TYPE_ERROR ),
                        DIWikiPage::newFromTitle( $this->title )
                );
diff --git 
a/tests/phpunit/includes/jobs/PropertySubjectsUpdateDispatcherJobTest.php 
b/tests/phpunit/includes/jobs/UpdateDispatcherJobTest.php
similarity index 73%
rename from 
tests/phpunit/includes/jobs/PropertySubjectsUpdateDispatcherJobTest.php
rename to tests/phpunit/includes/jobs/UpdateDispatcherJobTest.php
index 9d23694..22f850e 100644
--- a/tests/phpunit/includes/jobs/PropertySubjectsUpdateDispatcherJobTest.php
+++ b/tests/phpunit/includes/jobs/UpdateDispatcherJobTest.php
@@ -2,13 +2,13 @@
 
 namespace SMW\Test;
 
-use SMW\PropertySubjectsUpdateDispatcherJob;
+use SMW\UpdateDispatcherJob;
 use SMW\DIProperty;
 
 use Title;
 
 /**
- * Tests for the PropertySubjectsUpdateDispatcherJob class
+ * Tests for the UpdateDispatcherJob class
  *
  * @file
  *
@@ -19,14 +19,14 @@
  */
 
 /**
- * @covers \SMW\PropertySubjectsUpdateDispatcherJob
+ * @covers \SMW\UpdateDispatcherJob
  *
  * @ingroup Test
  *
  * @group SMW
  * @group SMWExtension
  */
-class PropertySubjectsUpdateDispatcherJobTest extends 
SemanticMediaWikiTestCase {
+class UpdateDispatcherJobTest extends SemanticMediaWikiTestCase {
 
        /** @var DIProperty */
        protected $property;
@@ -40,24 +40,24 @@
         * @return string|false
         */
        public function getClass() {
-               return '\SMW\PropertySubjectsUpdateDispatcherJob';
+               return '\SMW\UpdateDispatcherJob';
        }
 
        /**
-        * Helper method that returns a PropertySubjectsUpdateDispatcherJob 
object
+        * Helper method that returns a UpdateDispatcherJob object
         *
         * @since 1.9
         *
         * @param Title|null $title
         *
-        * @return PropertySubjectsUpdateDispatcherJob
+        * @return UpdateDispatcherJob
         */
        private function getInstance( Title $title = null ) {
-               return new PropertySubjectsUpdateDispatcherJob( $title === null 
? $this->getTitle() : $title );
+               return new UpdateDispatcherJob( $title === null ? 
$this->getTitle() : $title );
        }
 
        /**
-        * @test PropertySubjectsUpdateDispatcherJob::__construct
+        * @test UpdateDispatcherJob::__construct
         *
         * @since 1.9
         */
@@ -66,7 +66,7 @@
        }
 
        /**
-        * @test PropertySubjectsUpdateDispatcherJob::push
+        * @test UpdateDispatcherJob::push
         *
         * Just verify that the push method is accessible
         * without inserting any real job
@@ -78,13 +78,22 @@
        }
 
        /**
-        * @test PropertySubjectsUpdateDispatcherJob::run
+        * @test UpdateDispatcherJob::run
         *
         * @since 1.9
         */
-       public function testRun() {
+       public function testDBRun() {
+               $this->assertTrue( $this->getInstance( $this->newTitle( 
SMW_NS_PROPERTY ) )->disable()->run() );
+       }
 
-               $title = $this->getTitle( SMW_NS_PROPERTY );
+       /**
+        * @test UpdateDispatcherJob::run
+        *
+        * @since 1.9
+        */
+       public function testMockRun() {
+
+               $title = $this->newTitle( SMW_NS_PROPERTY );
 
                // Set-up expected property, accessible in the mock callback
                $this->property = DIProperty::newFromUserLabel( 
$title->getText() );
@@ -108,8 +117,8 @@
                $instance = $this->getInstance( $title );
                $instance->setStore( $mockStore );
 
-               // Disable dispatch jobs to avoid test
-               // jobs being inserted
+               // Disable distribution of generated jobs
+               // being inserted into the"real" JobQueue
                $instance->disable()->run();
 
                // Get access to protected jobs property

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I995b9a69dd4a9ea4b5ff88ef8dafbccd48230683
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to