Do not allow a user to delete a page they can't edit
[lhc/web/wiklou.git] / includes / api / ApiQueryBase.php
index 8e014df..6680316 100644 (file)
@@ -75,8 +75,8 @@ abstract class ApiQueryBase extends ApiBase {
 
        /**
         * Add a set of tables to the internal array
-        * @param mixed $tables Table name or array of table names
-        * @param mixed $alias Table alias, or null for no alias. Cannot be
+        * @param string|string[] $tables Table name or array of table names
+        * @param string|null $alias Table alias, or null for no alias. Cannot be
         *  used with multiple tables
         */
        protected function addTables( $tables, $alias = null ) {
@@ -398,15 +398,10 @@ abstract class ApiQueryBase extends ApiBase {
        /**
         * Set a query-continue value
         * @param string $paramName Parameter name
-        * @param string $paramValue Parameter value
+        * @param string|array $paramValue Parameter value
         */
        protected function setContinueEnumParameter( $paramName, $paramValue ) {
-               $paramName = $this->encodeParamName( $paramName );
-               $msg = array( $paramName => $paramValue );
-               $result = $this->getResult();
-               $result->disableSizeCheck();
-               $result->addValue( 'query-continue', $this->getModuleName(), $msg, ApiResult::ADD_ON_TOP );
-               $result->enableSizeCheck();
+               $this->getResult()->setContinueParam( $this, $paramName, $paramValue );
        }
 
        /**
@@ -596,26 +591,18 @@ abstract class ApiQueryBase extends ApiBase {
                return preg_match( '/^[a-z0-9]{31}$/', $hash );
        }
 
-       /**
-        * @return array
-        */
-       public function getPossibleErrors() {
-               $errors = parent::getPossibleErrors();
-               $errors = array_merge( $errors, array(
-                       array( 'invalidtitle', 'title' ),
-                       array( 'invalidtitle', 'key' ),
-               ) );
-
-               return $errors;
-       }
-
        /**
         * Check whether the current user has permission to view revision-deleted
         * fields.
         * @return bool
         */
        public function userCanSeeRevDel() {
-               return $this->getUser()->isAllowedAny( 'deletedhistory', 'deletedtext', 'suppressrevision' );
+               return $this->getUser()->isAllowedAny(
+                       'deletedhistory',
+                       'deletedtext',
+                       'suppressrevision',
+                       'viewsuppressed'
+               );
        }
 }
 
@@ -667,16 +654,14 @@ abstract class ApiQueryGeneratorBase extends ApiQueryBase {
        }
 
        /**
-        * Overrides base in case of generator & smart continue to
-        * notify ApiQueryMain instead of adding them to the result right away.
+        * Overridden to set the generator param if in generator mode
         * @param string $paramName Parameter name
-        * @param string $paramValue Parameter value
+        * @param string|array $paramValue Parameter value
         */
        protected function setContinueEnumParameter( $paramName, $paramValue ) {
-               // If this is a generator and query->setGeneratorContinue() returns false, treat as before
-               if ( $this->mGeneratorPageSet === null
-                       || !$this->getQuery()->setGeneratorContinue( $this, $paramName, $paramValue )
-               ) {
+               if ( $this->mGeneratorPageSet !== null ) {
+                       $this->getResult()->setGeneratorContinueParam( $this, $paramName, $paramValue );
+               } else {
                        parent::setContinueEnumParameter( $paramName, $paramValue );
                }
        }