Merge "$rootCode isn't used so no point creating it"
authorAaron Schulz <aschulz@wikimedia.org>
Sat, 7 Apr 2012 23:45:47 +0000 (23:45 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 7 Apr 2012 23:45:48 +0000 (23:45 +0000)
RELEASE-NOTES-1.20
includes/Export.php
includes/GlobalFunctions.php
includes/api/ApiEditPage.php
includes/api/ApiProtect.php
includes/filerepo/file/LocalFile.php
includes/media/IPTC.php
maintenance/backup.inc
maintenance/storage/checkStorage.php

index c6b2756..92e8367 100644 (file)
@@ -84,6 +84,7 @@ production.
 * (bug 32384) Allow descending order for list=watchlistraw.
 * (bug 31883) Limit of bkusers of list=blocks and titles of action=query is not documented in API help.
 * (bug 32492) API now allows editing using pageid
+* (bug 32497) API now allows changing of protection level using pageid
 
 === Languages updated in 1.20 ===
 
index 24daa09..48fbc47 100644 (file)
@@ -910,7 +910,7 @@ class DumpFileOutput extends DumpOutput {
  */
 class DumpPipeOutput extends DumpFileOutput {
        protected $command, $filename;
-       private $procOpenResource = false;
+       protected $procOpenResource = false;
 
        function __construct( $command, $file = null ) {
                if ( !is_null( $file ) ) {
index 517f70d..7237b53 100644 (file)
@@ -3603,7 +3603,7 @@ function wfFindFile( $title, $options = array() ) {
  * Returns a valid placeholder object if the file does not exist.
  *
  * @param $title Title|String
- * @return File|null A File, or null if passed an invalid Title
+ * @return LocalFile|null A File, or null if passed an invalid Title
  */
 function wfLocalFile( $title ) {
        return RepoGroup::singleton()->getLocalRepo()->newFile( $title );
index 608f815..796b049 100644 (file)
@@ -381,7 +381,7 @@ class ApiEditPage extends ApiBase {
                global $wgMaxArticleSize;
 
                return array_merge( parent::getPossibleErrors(),
-                       $this->getRequireOnlyOneParameterErrorMessages( 'title', 'pageid' ),
+                       $this->getRequireOnlyOneParameterErrorMessages( array( 'title', 'pageid' ) ),
                        array(
                                array( 'nosuchpageid', 'pageid' ),
                                array( 'missingtext' ),
index fb225d8..ec7b560 100644 (file)
@@ -37,9 +37,18 @@ class ApiProtect extends ApiBase {
                global $wgRestrictionLevels;
                $params = $this->extractRequestParams();
 
-               $titleObj = Title::newFromText( $params['title'] );
-               if ( !$titleObj ) {
-                       $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
+               $this->requireOnlyOneParameter( $params, 'title', 'pageid' );
+
+               if ( isset( $params['title'] ) ) {
+                       $titleObj = Title::newFromText( $params['title'] );
+                       if ( !$titleObj ) {
+                               $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
+                       }
+               } elseif ( isset( $params['pageid'] ) ) {
+                       $titleObj = Title::newFromID( $params['pageid'] );
+                       if ( !$titleObj ) {
+                               $this->dieUsageMsg( array( 'nosuchpageid', $params['pageid'] ) );
+                       }
                }
 
                $errors = $titleObj->getUserPermissionsErrors( 'protect', $this->getUser() );
@@ -138,7 +147,9 @@ class ApiProtect extends ApiBase {
                return array(
                        'title' => array(
                                ApiBase::PARAM_TYPE => 'string',
-                               ApiBase::PARAM_REQUIRED => true
+                       ),
+                       'pageid' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
                        ),
                        'token' => null,
                        'protections' => array(
@@ -169,8 +180,10 @@ class ApiProtect extends ApiBase {
        }
 
        public function getParamDescription() {
+               $p = $this->getModulePrefix();
                return array(
-                       'title' => 'Title of the page you want to (un)protect',
+                       'title' => "Title of the page you want to (un)protect. Cannot be used together with {$p}pageid",
+                       'pageid' => "ID of the page you want to (un)protect. Cannot be used together with {$p}title",
                        'token' => 'A protect token previously retrieved through prop=info',
                        'protections' => 'Pipe-separated list of protection levels, formatted action=group (e.g. edit=sysop)',
                        'expiry' => array( 'Expiry timestamps. If only one timestamp is set, it\'ll be used for all protections.',
@@ -188,16 +201,20 @@ class ApiProtect extends ApiBase {
        }
 
        public function getPossibleErrors() {
-               return array_merge( parent::getPossibleErrors(), array(
-                       array( 'invalidtitle', 'title' ),
-                       array( 'toofewexpiries', 'noofexpiries', 'noofprotections' ),
-                       array( 'create-titleexists' ),
-                       array( 'missingtitle-createonly' ),
-                       array( 'protect-invalidaction', 'action' ),
-                       array( 'protect-invalidlevel', 'level' ),
-                       array( 'invalidexpiry', 'expiry' ),
-                       array( 'pastexpiry', 'expiry' ),
-               ) );
+               return array_merge( parent::getPossibleErrors(),
+                       $this->getRequireOnlyOneParameterErrorMessages( array( 'title', 'pageid' ) ),
+                       array(
+                               array( 'invalidtitle', 'title' ),
+                               array( 'nosuchpageid', 'pageid' ),
+                               array( 'toofewexpiries', 'noofexpiries', 'noofprotections' ),
+                               array( 'create-titleexists' ),
+                               array( 'missingtitle-createonly' ),
+                               array( 'protect-invalidaction', 'action' ),
+                               array( 'protect-invalidlevel', 'level' ),
+                               array( 'invalidexpiry', 'expiry' ),
+                               array( 'pastexpiry', 'expiry' ),
+                       )
+               );
        }
 
        public function needsToken() {
index 40ee0fa..04d7a47 100644 (file)
@@ -60,6 +60,11 @@ class LocalFile extends File {
 
        /**#@-*/
 
+       /**
+        * @var LocalRepo
+        */
+       var $repo;
+
        protected $repoClass = 'LocalRepo';
 
        /**
@@ -1653,7 +1658,7 @@ class LocalFileDeleteBatch {
                                        'fa_deleted_user'      => $encUserId,
                                        'fa_deleted_timestamp' => $encTimestamp,
                                        'fa_deleted_reason'    => $encReason,
-                                       'fa_deleted'               => $this->suppress ? $bitfield : 'oi_deleted',
+                                       'fa_deleted'           => $this->suppress ? $bitfield : 'oi_deleted',
 
                                        'fa_name'         => 'oi_name',
                                        'fa_archive_name' => 'oi_archive_name',
@@ -1669,7 +1674,6 @@ class LocalFileDeleteBatch {
                                        'fa_user'         => 'oi_user',
                                        'fa_user_text'    => 'oi_user_text',
                                        'fa_timestamp'    => 'oi_timestamp',
-                                       'fa_deleted'      => $bitfield
                                ), $where, __METHOD__ );
                }
        }
index 1d19791..666ce40 100644 (file)
@@ -395,10 +395,10 @@ class IPTC {
 
        /**
        * Helper function to convert charset for iptc values.
-       * @param $data Mixed String or Array: The iptc string
+       * @param $data string|array The iptc string
        * @param $charset String: The charset
         *
-        * @return string
+        * @return string|array
        */
        private static function convIPTC ( $data, $charset ) {
                if ( is_array( $data ) ) {
index 6eccb26..04c65ba 100644 (file)
@@ -28,7 +28,7 @@
  * @ingroup Dump Maintenance
  */
 class DumpDBZip2Output extends DumpPipeOutput {
-       function DumpDBZip2Output( $file ) {
+       function __construct( $file ) {
                parent::__construct( "dbzip2", $file );
        }
 }
index af1f9ee..5887a75 100644 (file)
@@ -381,8 +381,8 @@ class CheckStorage {
                        $extDb->freeResult( $res );
 
                        // Print errors for missing blobs rows
-                       foreach ( $oldIds as $blobId => $oldIds ) {
-                               $this->error( 'restore text', "Error: missing target $cluster/$blobId for two-part ES URL", $oldIds );
+                       foreach ( $oldIds as $blobId => $oldIds2 ) {
+                               $this->error( 'restore text', "Error: missing target $cluster/$blobId for two-part ES URL", $oldIds2 );
                        }
                }
        }