Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinter.php |
— | — | @@ -152,8 +152,15 @@ |
153 | 153 | $this->hasTemplates = false; |
154 | 154 | |
155 | 155 | if ( $this->useValidator ) { |
156 | | - // TODO: retain behaviour of base readParameters |
157 | | - $this->handleParameters( $this->handleRawParameters( $params ), $outputmode ); |
| 156 | + $paramValidationResult = $this->handleRawParameters( $params ); |
| 157 | + |
| 158 | + if ( is_array( $paramValidationResult ) ) { |
| 159 | + $this->handleParameters( $paramValidationResult, $outputmode ); |
| 160 | + } |
| 161 | + else { |
| 162 | + $this->addError( $paramValidationResult ); |
| 163 | + return $this->getErrorString( $results ); |
| 164 | + } |
158 | 165 | } |
159 | 166 | else { |
160 | 167 | $this->readParameters( $params, $outputmode ); |
— | — | @@ -277,25 +284,26 @@ |
278 | 285 | |
279 | 286 | /** |
280 | 287 | * Handles the user-provided parameters and returns the processes key-value pairs. |
| 288 | + * If there is a fatal error, a string with the error message will be returned intsead. |
281 | 289 | * |
282 | 290 | * @since 1.6 |
283 | 291 | * |
284 | 292 | * @param array $keyValuePairs |
285 | 293 | * |
286 | | - * @return array |
| 294 | + * @return array or string |
287 | 295 | */ |
288 | 296 | protected function handleRawParameters( array $keyValuePairs ) { |
289 | 297 | $validator = new Validator(); |
290 | 298 | $validator->setParameters( $keyValuePairs, $this->getParameters() ); |
291 | 299 | $validator->validateParameters(); |
| 300 | + $fatalError = $validator->hasFatalError(); |
292 | 301 | |
293 | | - if ( $validator->hasFatalError() ) { |
294 | | - // TODO |
295 | | - throw new Exception( 'Validator: fatal param validation error' ); |
| 302 | + if ( $fatalError === false ) { |
| 303 | + $this->mErrors = $validator->getErrorMessages(); |
| 304 | + return $validator->getParameterValues(); |
296 | 305 | } |
297 | 306 | else { |
298 | | - $this->mErrors = $validator->getErrorMessages(); |
299 | | - return $validator->getParameterValues(); |
| 307 | + return $fatalError->getMessage(); |
300 | 308 | } |
301 | 309 | } |
302 | 310 | |