API: Move stats update for API module execution to when the module is actually executed
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 7 Jul 2015 17:46:17 +0000 (13:46 -0400)
committerAnomie <bjorsch@wikimedia.org>
Tue, 7 Jul 2015 17:49:43 +0000 (17:49 +0000)
The place it was before could easily be reached without actually
executing (or even constructing) the module.

Change-Id: I6f807adc9cbf71c5d7b83c7eec43965dce1d2a16

includes/api/ApiMain.php

index fec750f..46dc7df 100644 (file)
@@ -404,8 +404,6 @@ class ApiMain extends ApiBase {
                } else {
                        $this->executeActionWithErrorHandling();
                }
-               $this->getContext()->getStats()->increment(
-                       'api.modules.' . strtr( $this->getModule()->getModulePath(), '+', '.' ) );
        }
 
        /**
@@ -1092,6 +1090,8 @@ class ApiMain extends ApiBase {
                $this->checkAsserts( $params );
 
                // Execute
+               $this->getContext()->getStats()->increment(
+                       'api.modules.' . strtr( $module->getModulePath(), '+', '.' ) );
                $module->execute();
                Hooks::run( 'APIAfterExecute', array( &$module ) );