Merge "Fix 'Tags' padding to keep it farther from the edge and document the source...
[lhc/web/wiklou.git] / includes / api / ApiMain.php
index b7b13c5..f324eff 100644 (file)
@@ -1258,6 +1258,8 @@ class ApiMain extends ApiBase {
                        }
                }
 
+               Hooks::runWithoutAbort( 'ApiMaxLagInfo', [ &$lagInfo ] );
+
                return $lagInfo;
        }
 
@@ -1552,6 +1554,11 @@ class ApiMain extends ApiBase {
         */
        protected function executeAction() {
                $params = $this->setupExecuteAction();
+
+               // Check asserts early so e.g. errors in parsing a module's parameters due to being
+               // logged out don't override the client's intended "am I logged in?" check.
+               $this->checkAsserts( $params );
+
                $module = $this->setupModule();
                $this->mModule = $module;
 
@@ -1573,8 +1580,6 @@ class ApiMain extends ApiBase {
                        $this->setupExternalResponse( $module, $params );
                }
 
-               $this->checkAsserts( $params );
-
                // Execute
                $module->execute();
                Hooks::run( 'APIAfterExecute', [ &$module ] );
@@ -1888,6 +1893,7 @@ class ApiMain extends ApiBase {
                        $help[$k] = $v;
                }
                $help['datatypes'] = '';
+               $help['templatedparams'] = '';
                $help['credits'] = '';
 
                // Fill 'permissions'
@@ -1920,7 +1926,7 @@ class ApiMain extends ApiBase {
                $help['permissions'] .= Html::closeElement( 'dl' );
                $help['permissions'] .= Html::closeElement( 'div' );
 
-               // Fill 'datatypes' and 'credits', if applicable
+               // Fill 'datatypes', 'templatedparams', and 'credits', if applicable
                if ( empty( $options['nolead'] ) ) {
                        $level = $options['headerlevel'];
                        $tocnumber = &$options['tocnumber'];
@@ -1954,6 +1960,35 @@ class ApiMain extends ApiBase {
                                ];
                        }
 
+                       $header = $this->msg( 'api-help-templatedparams-header' )->parse();
+
+                       $id = Sanitizer::escapeIdForAttribute( 'main/templatedparams', Sanitizer::ID_PRIMARY );
+                       $idFallback = Sanitizer::escapeIdForAttribute( 'main/templatedparams', Sanitizer::ID_FALLBACK );
+                       $headline = Linker::makeHeadline( min( 6, $level ),
+                               ' class="apihelp-header">',
+                               $id,
+                               $header,
+                               '',
+                               $idFallback
+                       );
+                       // Ensure we have a sane anchor
+                       if ( $id !== 'main/templatedparams' && $idFallback !== 'main/templatedparams' ) {
+                               $headline = '<div id="main/templatedparams"></div>' . $headline;
+                       }
+                       $help['templatedparams'] .= $headline;
+                       $help['templatedparams'] .= $this->msg( 'api-help-templatedparams' )->parseAsBlock();
+                       if ( !isset( $tocData['main/templatedparams'] ) ) {
+                               $tocnumber[$level]++;
+                               $tocData['main/templatedparams'] = [
+                                       'toclevel' => count( $tocnumber ),
+                                       'level' => $level,
+                                       'anchor' => 'main/templatedparams',
+                                       'line' => $header,
+                                       'number' => implode( '.', $tocnumber ),
+                                       'index' => false,
+                               ];
+                       }
+
                        $header = $this->msg( 'api-credits-header' )->parse();
                        $id = Sanitizer::escapeIdForAttribute( 'main/credits', Sanitizer::ID_PRIMARY );
                        $idFallback = Sanitizer::escapeIdForAttribute( 'main/credits', Sanitizer::ID_FALLBACK );