X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FRest%2FSimpleHandler.php;h=3c19e48e876e27ba7d79c8fd3f09f59c428e6bb4;hb=a775c6888bdecd03cea73f5540a8323b6dcbe78f;hp=85749c6229363cb0711525a4536409e1d1dff717;hpb=caeaed1019b9f7934fb7dcd03fc4cf0b2f189581;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Rest/SimpleHandler.php b/includes/Rest/SimpleHandler.php index 85749c6229..3c19e48e87 100644 --- a/includes/Rest/SimpleHandler.php +++ b/includes/Rest/SimpleHandler.php @@ -8,12 +8,33 @@ namespace MediaWiki\Rest; * * run() must be declared in the subclass. It cannot be declared as abstract * here because it has a variable parameter list. + * @todo Declare it as abstract after dropping HHVM * * @package MediaWiki\Rest */ class SimpleHandler extends Handler { public function execute() { - $params = array_values( $this->getRequest()->getPathParams() ); + $paramSettings = $this->getParamSettings(); + $validatedParams = $this->getValidatedParams(); + $unvalidatedParams = []; + $params = []; + foreach ( $this->getRequest()->getPathParams() as $name => $value ) { + $source = $paramSettings[$name][self::PARAM_SOURCE] ?? 'unknown'; + if ( $source !== 'path' ) { + $unvalidatedParams[] = $name; + $params[] = $value; + } else { + $params[] = $validatedParams[$name]; + } + } + + if ( $unvalidatedParams ) { + throw new \LogicException( + 'Path parameters were not validated: ' . implode( ', ', $unvalidatedParams ) + ); + } + + // @phan-suppress-next-line PhanUndeclaredMethod return $this->run( ...$params ); } }