Merge "(bug 47070) check content model namespace on import."
[lhc/web/wiklou.git] / includes / filerepo / file / ArchivedFile.php
index 0d86c70..26699c4 100644 (file)
@@ -451,25 +451,36 @@ class ArchivedFile {
        }
 
        /**
-        * Return the user ID of the uploader.
+        * Returns ID or name of user who uploaded the file
         *
-        * @return int
+        * @note Prior to MediaWiki 1.23, this method always
+        *   returned the user id, and was inconsistent with
+        *   the rest of the file classes.
+        * @param string $type 'text' or 'id'
+        * @return int|string
+        * @throws MWException
         */
-       public function getUser() {
+       public function getUser( $type = 'text' ) {
                $this->load();
-               if ( $this->isDeleted( File::DELETED_USER ) ) {
-                       return 0;
-               } else {
+
+               if ( $type == 'text' ) {
+                       return $this->user_text;
+               } elseif ( $type == 'id' ) {
                        return $this->user;
                }
+
+               throw new MWException( "Unknown type '$type'." );
+
        }
 
        /**
         * Return the user name of the uploader.
         *
+        * @deprecated 1.23 Use getUser( 'text' ) instead.
         * @return string
         */
        public function getUserText() {
+               wfDeprecated( __METHOD__, '1.23' );
                $this->load();
                if ( $this->isDeleted( File::DELETED_USER ) ) {
                        return 0;