X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiMain.php;h=7bbce976aa929ac5b7e334e2e62b98d757202533;hb=a5c7fd0db2d962834127ec2362d0dfe8ef6852d5;hp=6577c7b4c62088754b76d8b1ccc0ade53f57ccb0;hpb=8e158c68bc43106caec2c1d5aa8c656dab568818;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 6577c7b4c6..7bbce976aa 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -153,6 +153,7 @@ class ApiMain extends ApiBase { private $mModule; private $mCacheMode = 'private'; + /** @var array */ private $mCacheControl = []; private $mParamsUsed = []; private $mParamsSensitive = []; @@ -166,6 +167,7 @@ class ApiMain extends ApiBase { * @param IContextSource|WebRequest|null $context If this is an instance of * FauxRequest, errors are thrown and no printing occurs * @param bool $enableWrite Should be set to true if the api may modify data + * @suppress PhanUndeclaredMethod */ public function __construct( $context = null, $enableWrite = false ) { if ( $context === null ) { @@ -279,7 +281,10 @@ class ApiMain extends ApiBase { } $this->mResult->setErrorFormatter( $this->getErrorFormatter() ); - $this->mModuleMgr = new ApiModuleManager( $this ); + $this->mModuleMgr = new ApiModuleManager( + $this, + MediaWikiServices::getInstance()->getObjectFactory() + ); $this->mModuleMgr->addModules( self::$Modules, 'action' ); $this->mModuleMgr->addModules( $config->get( 'APIModules' ), 'action' ); $this->mModuleMgr->addModules( self::$Formats, 'format' ); @@ -291,7 +296,6 @@ class ApiMain extends ApiBase { $this->mEnableWrite = $enableWrite; $this->mCdnMaxAge = -1; // flag for executeActionWithErrorHandling() - $this->mCommit = false; } /** @@ -1539,6 +1543,12 @@ class ApiMain extends ApiBase { $this->dieWithErrorOrDebug( [ 'apierror-mustbeposted', $this->mAction ] ); } + if ( $request->wasPosted() && !$request->getHeader( 'Content-Type' ) ) { + $this->addDeprecation( + 'apiwarn-deprecation-post-without-content-type', 'post-without-content-type' + ); + } + // See if custom printer is used $this->mPrinter = $module->getCustomPrinter(); if ( is_null( $this->mPrinter ) ) { @@ -1700,7 +1710,7 @@ class ApiMain extends ApiBase { * @return string */ protected function encodeRequestLogValue( $s ) { - static $table; + static $table = []; if ( !$table ) { $chars = ';@$!*(),/:'; $numChars = strlen( $chars ); @@ -1906,6 +1916,10 @@ class ApiMain extends ApiBase { ]; } + /** + * @inheritDoc + * @phan-param array{nolead?:bool,headerlevel?:int,tocnumber?:int[]} $options + */ public function modifyHelp( array &$help, array $options, array &$tocData ) { // Wish PHP had an "array_insert_before". Instead, we have to manually // reindex the array to get 'permissions' in the right place.