Merge "File: remove deprecated methods"
This commit is contained in:
commit
ffb80447cf
5 changed files with 5 additions and 117 deletions
|
|
@ -198,6 +198,8 @@ because of Phabricator reports.
|
|||
from an object to a function. In addition, the `unbind` function has been
|
||||
removed. A deprecation process was assumed unnecessary as there were no known
|
||||
usages.
|
||||
* File::getUser, ::getImageSize, ArchivedFile::getRawDescription, ::getUser,
|
||||
::getRawUser and ::getRawDescription, deprecated since 1.37, has been removed.
|
||||
* …
|
||||
|
||||
=== Deprecations in 1.38 ===
|
||||
|
|
|
|||
|
|
@ -512,33 +512,6 @@ class ArchivedFile {
|
|||
return $this->sha1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns ID or name of user who uploaded the file
|
||||
*
|
||||
* @note Prior to MediaWiki 1.23, this method always
|
||||
* returned the user id, and was inconsistent with
|
||||
* the rest of the file classes.
|
||||
* @deprecated since 1.37. Use ::getUploader instead.
|
||||
* @param string $type 'text', 'id', or 'object'
|
||||
* @return int|string|User|null
|
||||
* @throws MWException
|
||||
* @since 1.31 added 'object'
|
||||
*/
|
||||
public function getUser( $type = 'text' ) {
|
||||
wfDeprecated( __METHOD__, '1.37' );
|
||||
$this->load();
|
||||
|
||||
if ( $type === 'object' ) {
|
||||
return $this->user ? User::newFromIdentity( $this->user ) : null;
|
||||
} elseif ( $type === 'text' ) {
|
||||
return $this->user ? $this->user->getName() : '';
|
||||
} elseif ( $type === 'id' ) {
|
||||
return $this->user ? $this->user->getId() : 0;
|
||||
}
|
||||
|
||||
throw new MWException( "Unknown type '$type'." );
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.37
|
||||
* @stable to override
|
||||
|
|
@ -584,40 +557,6 @@ class ArchivedFile {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the user ID of the uploader.
|
||||
*
|
||||
* @deprecated since 1.37. Use ::getUploader with self::RAW audience.
|
||||
* @return int
|
||||
*/
|
||||
public function getRawUser() {
|
||||
wfDeprecated( __METHOD__, '1.37' );
|
||||
return $this->getUser( 'id' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the user name of the uploader.
|
||||
*
|
||||
* @deprecated since 1.37. Use ::getUploader with self::RAW audience.
|
||||
* @return string
|
||||
*/
|
||||
public function getRawUserText() {
|
||||
wfDeprecated( __METHOD__, '1.37' );
|
||||
return $this->getUser( 'text' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return upload description.
|
||||
*
|
||||
* @deprecated since 1.37. Use ::getDescription with self::RAW audience.
|
||||
* @return string
|
||||
*/
|
||||
public function getRawDescription() {
|
||||
wfDeprecated( __METHOD__, '1.37' );
|
||||
$this->load();
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the deletion bitfield
|
||||
* @return int
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
*
|
||||
* Represents files in a repository.
|
||||
*/
|
||||
|
||||
use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
|
||||
use MediaWiki\Linker\LinkTarget;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
|
@ -603,27 +604,6 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
|
|||
return [ $width, $height ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns ID or name of user who uploaded the file
|
||||
* STUB
|
||||
*
|
||||
* @deprecated since 1.37. Use and override ::getUploader instead.
|
||||
* @param string $type 'text' or 'id'
|
||||
* @return string|int
|
||||
*/
|
||||
public function getUser( $type = 'text' ) {
|
||||
wfDeprecated( __METHOD__, '1.37' );
|
||||
$user = $this->getUploader( self::RAW ) ?? User::newFromName( 'Unknown user' );
|
||||
if ( $type === 'object' ) {
|
||||
return User::newFromIdentity( $user );
|
||||
} elseif ( $type === 'text' ) {
|
||||
return $user->getName();
|
||||
} elseif ( $type === 'id' ) {
|
||||
return $user->getId();
|
||||
}
|
||||
throw new MWException( "Unknown type '$type'." );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the duration of a media file in seconds
|
||||
*
|
||||
|
|
@ -2184,27 +2164,6 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an image size array like that returned by getImageSize(), or false if it
|
||||
* can't be determined. Loads the image size directly from the file ignoring caches.
|
||||
*
|
||||
* @note Use getWidth()/getHeight() instead of this method unless you have a
|
||||
* a good reason. This method skips all caches.
|
||||
*
|
||||
* @deprecated since 1.37
|
||||
*
|
||||
* @param string $filePath The path to the file (e.g. From getLocalRefPath() )
|
||||
* @return array|false The width, followed by height, with optionally more things after
|
||||
*/
|
||||
protected function getImageSize( $filePath ) {
|
||||
wfDeprecated( __METHOD__, '1.37' );
|
||||
if ( !$this->getHandler() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getHandler()->getImageSize( $this, $filePath );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL of the image description page. May return false if it is
|
||||
* unknown or not applicable.
|
||||
|
|
@ -2360,7 +2319,7 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
|
|||
* STUB
|
||||
* @stable to override
|
||||
* @param int $field
|
||||
* @param Authority $performer User object to check
|
||||
* @param Authority $performer user object to check
|
||||
* @return bool
|
||||
*/
|
||||
public function userCan( $field, Authority $performer ) {
|
||||
|
|
|
|||
|
|
@ -298,15 +298,6 @@ class LocalFileTest extends MediaWikiIntegrationTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers File::getUser
|
||||
*/
|
||||
public function testGetUserForNonExistingFile() {
|
||||
$this->hideDeprecated( 'File::getUser' );
|
||||
$file = ( new LocalRepo( self::getDefaultInfo() ) )->newFile( 'test!' );
|
||||
$this->assertSame( 'Unknown user', $file->getUser() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers LocalFile::getUploader
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -58,16 +58,13 @@ trait MediaTestTrait {
|
|||
/** @var MockObject|LocalFile $file */
|
||||
$file = $this->createNoOpMock(
|
||||
LocalFile::class,
|
||||
[ 'getTitle', 'getDescriptionUrl', 'exists', 'userCan', 'getUser', 'getUploader', 'getTimestamp',
|
||||
[ 'getTitle', 'getDescriptionUrl', 'exists', 'userCan', 'getUploader', 'getTimestamp',
|
||||
'getMediaType', 'getSize', 'getHeight', 'getWidth', 'getDisplayWidthHeight',
|
||||
'getLength', 'getUrl', 'allowInlineDisplay', 'transform', 'getSha1', 'load', 'getMimeType' ]
|
||||
);
|
||||
$file->method( 'getTitle' )->willReturn( $title );
|
||||
$file->method( 'exists' )->willReturn( true );
|
||||
$file->method( 'userCan' )->willReturn( true );
|
||||
$file->method( 'getUser' )->willReturnCallback( static function ( $type ) {
|
||||
return $type === 'id' ? 7 : 'Alice';
|
||||
} );
|
||||
$file->method( 'getUploader' )
|
||||
->willReturn( UserIdentityValue::newRegistered( 7, 'Alice' ) );
|
||||
$file->method( 'getTimestamp' )->willReturn( '20200102030405' );
|
||||
|
|
|
|||
Loading…
Reference in a new issue