API: Fix simplified continuation module skipping
authorBrad Jorsch <bjorsch@wikimedia.org>
Thu, 30 Oct 2014 17:30:45 +0000 (13:30 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Thu, 30 Oct 2014 17:32:49 +0000 (13:32 -0400)
The simplified continuation includes a continuation parameter to
indicate when the prop/list/meta modules are complete, so it can skip
executing them.

But if someone submitted a malformed value for 'continue', it might
decide that the generator was complete but still try to uselessly
execute the prop modules.

Bug: 72764
Change-Id: I6af24e5d4f30e64782fb7dd1c2211ebdd4ec2317

includes/api/ApiQueryBase.php
includes/api/ApiResult.php

index b1581f3..998cc91 100644 (file)
@@ -70,6 +70,10 @@ abstract class ApiQueryBase extends ApiBase {
        /**
         * Override this method to request extra fields from the pageSet
         * using $pageSet->requestField('fieldName')
+        *
+        * Note this only makes sense for 'prop' modules, as 'list' and 'meta'
+        * modules should not be using the pageset.
+        *
         * @param ApiPageSet $pageSet
         */
        public function requestExtraData( $pageSet ) {
index 946977d..5bc2efb 100644 (file)
@@ -481,10 +481,14 @@ class ApiResult extends ApiBase {
                        $continue = explode( '||', $continue );
                        $this->dieContinueUsageIf( count( $continue ) !== 2 );
                        $this->generatorDone = ( $continue[0] === '-' );
+                       $skip = explode( '|', $continue[1] );
                        if ( !$this->generatorDone ) {
                                $this->generatorParams = explode( '|', $continue[0] );
+                       } else {
+                               // When the generator is complete, don't run any modules that
+                               // depend on it.
+                               $skip += $this->continueGeneratedModules;
                        }
-                       $skip = explode( '|', $continue[1] );
                }
 
                $this->continueAllModules = array();