* @ingroup FileAbstraction
*/
class OldLocalFile extends LocalFile {
- /** @var string Timestamp */
+ /** @var string|int Timestamp */
protected $requestedTime;
/** @var string Archive name */
/**
* @param Title $title
* @param FileRepo $repo
- * @param null|int $time Timestamp or null
- * @return OldLocalFile
+ * @param string|int $time
+ * @return self
* @throws MWException
*/
static function newFromTitle( $title, $repo, $time = null ) {
* @param Title $title
* @param FileRepo $repo
* @param string $archiveName
- * @return OldLocalFile
+ * @return self
*/
static function newFromArchiveName( $title, $repo, $archiveName ) {
return new self( $title, $repo, null, $archiveName );
/**
* @param stdClass $row
* @param FileRepo $repo
- * @return OldLocalFile
+ * @return self
*/
static function newFromRow( $row, $repo ) {
$title = Title::makeTitle( NS_FILE, $row->oi_name );
/**
* Fields in the oldimage table
* @deprecated since 1.31, use self::getQueryInfo() instead.
- * @return array
+ * @return string[]
*/
static function selectFields() {
+ global $wgActorTableSchemaMigrationStage;
+
wfDeprecated( __METHOD__, '1.31' );
+ if ( $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
+ // If code is using this instead of self::getQueryInfo(), there's a
+ // decent chance it's going to try to directly access
+ // $row->oi_user or $row->oi_user_text and we can't give it
+ // useful values here once those aren't being written anymore.
+ throw new BadMethodCallException(
+ 'Cannot use ' . __METHOD__ . ' when $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH'
+ );
+ }
+
return [
'oi_name',
'oi_archive_name',
'oi_minor_mime',
'oi_user',
'oi_user_text',
+ 'oi_actor' => $wgActorTableSchemaMigrationStage > MIGRATION_OLD ? 'oi_actor' : null,
'oi_timestamp',
'oi_deleted',
'oi_sha1',
* @since 1.31
* @param string[] $options
* - omit-lazy: Omit fields that are lazily cached.
- * @return array With three keys:
+ * @return array[] With three keys:
* - tables: (string[]) to include in the `$table` to `IDatabase->select()`
* - fields: (string[]) to include in the `$vars` to `IDatabase->select()`
* - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
*/
public static function getQueryInfo( array $options = [] ) {
$commentQuery = CommentStore::getStore()->getJoin( 'oi_description' );
+ $actorQuery = ActorMigration::newMigration()->getJoin( 'oi_user' );
$ret = [
- 'tables' => [ 'oldimage' ] + $commentQuery['tables'],
+ 'tables' => [ 'oldimage' ] + $commentQuery['tables'] + $actorQuery['tables'],
'fields' => [
'oi_name',
'oi_archive_name',
'oi_media_type',
'oi_major_mime',
'oi_minor_mime',
- 'oi_user',
- 'oi_user_text',
'oi_timestamp',
'oi_deleted',
'oi_sha1',
- ] + $commentQuery['fields'],
- 'joins' => $commentQuery['joins'],
+ ] + $commentQuery['fields'] + $actorQuery['fields'],
+ 'joins' => $commentQuery['joins'] + $actorQuery['joins'],
];
if ( in_array( 'omit-nonlazy', $options, true ) ) {
/**
* @param Title $title
* @param FileRepo $repo
- * @param string $time Timestamp or null to load by archive name
- * @param string $archiveName Archive name or null to load by timestamp
+ * @param string|int|null $time Timestamp or null to load by archive name
+ * @param string|null $archiveName Archive name or null to load by timestamp
* @throws MWException
*/
function __construct( $title, $repo, $time, $archiveName ) {
}
$commentFields = CommentStore::getStore()->insert( $dbw, 'oi_description', $comment );
+ $actorFields = ActorMigration::newMigration()->getInsertValues( $dbw, 'oi_user', $user );
$dbw->insert( 'oldimage',
[
'oi_name' => $this->getName(),
'oi_height' => intval( $props['height'] ),
'oi_bits' => $props['bits'],
'oi_timestamp' => $dbw->timestamp( $timestamp ),
- 'oi_user' => $user->getId(),
- 'oi_user_text' => $user->getName(),
'oi_metadata' => $props['metadata'],
'oi_media_type' => $props['media_type'],
'oi_major_mime' => $props['major_mime'],
'oi_minor_mime' => $props['minor_mime'],
'oi_sha1' => $props['sha1'],
- ] + $commentFields, __METHOD__
+ ] + $commentFields + $actorFields, __METHOD__
);
return true;