X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles_versions%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryBase.php;h=e36109a2d3d7fcaa8d91c3ac90c29762a493b8b8;hb=983545c362921cd1a60b5f00d1d0088c51072cdc;hp=92fabddd005bb479e37189f5327afb09318b98a4;hpb=cf1ea333e74076a80fdd419e7a7c5919eda1fae9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index 92fabddd00..e36109a2d3 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -4,7 +4,7 @@ * * Created on Sep 7, 2006 * - * Copyright © 2006 Yuri Astrakhan @gmail.com + * Copyright © 2006 Yuri Astrakhan "@gmail.com" * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -374,6 +374,19 @@ abstract class ApiQueryBase extends ApiBase { $result->enableSizeCheck(); } + /** + * Die with the $prefix.'badcontinue' error. This call is common enough to make it into the base method. + * @param $condition boolean will only die if this value is true + * @since 1.21 + */ + protected function dieContinueUsageIf( $condition ) { + if ( $condition ) { + $this->dieUsage( + 'Invalid continue param. You should pass the original value returned by the previous query', + 'badcontinue' ); + } + } + /** * Get the Query database connection (read-only) * @return DatabaseBase @@ -534,7 +547,7 @@ abstract class ApiQueryBase extends ApiBase { * @return bool */ public function validateSha1Hash( $hash ) { - return preg_match( '/[a-fA-F0-9]{40}/', $hash ); + return preg_match( '/^[a-f0-9]{40}$/', $hash ); } /** @@ -542,17 +555,28 @@ abstract class ApiQueryBase extends ApiBase { * @return bool */ public function validateSha1Base36Hash( $hash ) { - return preg_match( '/[a-zA-Z0-9]{31}/', $hash ); + return preg_match( '/^[a-z0-9]{31}$/', $hash ); } /** * @return array */ public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), array( + $errors = parent::getPossibleErrors(); + $errors = array_merge( $errors, array( array( 'invalidtitle', 'title' ), array( 'invalidtitle', 'key' ), ) ); + $params = $this->getFinalParams(); + if ( array_key_exists( 'continue', $params ) ) { + $errors = array_merge( $errors, array( + array( + 'code' => 'badcontinue', + 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' + ), + ) ); + } + return $errors; } /** @@ -571,6 +595,11 @@ abstract class ApiQueryGeneratorBase extends ApiQueryBase { private $mIsGenerator; + /** + * @param $query ApiBase + * @param $moduleName string + * @param $paramPrefix string + */ public function __construct( $query, $moduleName, $paramPrefix = '' ) { parent::__construct( $query, $moduleName, $paramPrefix ); $this->mIsGenerator = false;