aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Rest/SimpleHandler.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/Rest/SimpleHandler.php')
-rw-r--r--includes/Rest/SimpleHandler.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/includes/Rest/SimpleHandler.php b/includes/Rest/SimpleHandler.php
index 3718d66b9350..3c19e48e876e 100644
--- a/includes/Rest/SimpleHandler.php
+++ b/includes/Rest/SimpleHandler.php
@@ -14,7 +14,26 @@ namespace 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 );
}