Page MenuHomePhabricator

Reverting Images broken
Closed, ResolvedPublic

Description

Author: overlordq

Description:
YATB (Yet Another Timestamp Bug).

Trying to revert an image results in this error:

A database error has occurred Query: SELECT oi_size,oi_width,oi_height,oi_bits,oi_media_type,oi_major_mime,oi_minor_mime,oi_metadata,oi_timestamp,oi_sha1,oi_user,oi_user_text,oi_description,oi_archive_name,oi_deleted FROM oldimage WHERE oi_name = 'Smiley.svg' AND (oi_timestamp <= '20080327074730!Smiley.svg') ORDER BY oi_timestamp DESC LIMIT 1 Function: OldLocalFile::loadFromDB Error: 1 ERROR: invalid input syntax for type timestamp with time zone: "20080327074730!Smiley.svg"

Backtrace:

#0 /home/wiki/includes/Database.php(799): DatabasePostgres->reportQueryError('ERROR: invalid...', 1, 'SELECT oi_size...', 'OldLocalFile::l...', false)
#1 /home/wiki/includes/Database.php(1244): Database->query('SELECT oi_size...', 'OldLocalFile::l...')
#2 /home/wiki/includes/Database.php(1263): Database->select('oldimage', Array, Array, 'OldLocalFile::l...', Array)
#3 /home/wiki/includes/filerepo/OldLocalFile.php(174): Database->selectRow('oldimage', Array, Array, 'OldLocalFile::l...', Array)
#4 /home/wiki/includes/filerepo/LocalFile.php(248): OldLocalFile->loadFromDB()
#5 /home/wiki/includes/filerepo/LocalFile.php(450): LocalFile->load()
#6 /home/wiki/includes/filerepo/FileRepo.php(91): LocalFile->exists()
#7 /home/wiki/includes/filerepo/RepoGroup.php(66): FileRepo->findFile(Object(Title), '20080327074730!...')
#8 /home/wiki/includes/GlobalFunctions.php(2346): RepoGroup->findFile(Object(Title), '20080327074730!...')
#9 /home/wiki/includes/FileRevertForm.php(137): wfFindFile(Object(Title), '20080327074730!...')
#10 /home/wiki/includes/FileRevertForm.php(58): FileRevertForm->haveOldVersion()
#11 /home/wiki/includes/ImagePage.php(502): FileRevertForm->execute()
#12 /home/wiki/includes/Wiki.php(447): ImagePage->revert()
#13 /home/wiki/includes/Wiki.php(59): MediaWiki->performAction(Object(OutputPage), Object(ImagePage), Object(Title), Object(User), Object(WebRequest))
#14 /home/wiki/index.php(92): MediaWiki->initialize(Object(Title), Object(ImagePage), Object(OutputPage), Object(User), Object(WebRequest))

#15 {main}

20080327074730!Smiley.svg (oi_archive_name) is most definitely not a valid timestamp.


Version: 1.13.x
Severity: major

Details

Reference
bz13532

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.
StatusSubtypeAssignedTask
InvalidNone
ResolvedNone

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:06 PM
bzimport set Reference to bz13532.
bzimport added a subscriber: Unknown Object (MLST).

Thanks, should be fixed in r32526.

overlordq wrote:

The error isn't there but now when reverting all you get is:

There is no previous local version of this file with the provided timestamp.

That's hard to debug. Can you check the link on the page it came from and compare to the info in the database?

overlordq wrote:

Just to make it easier I uploaded a small test image and replaced it once with a similar image.

http://www.thedarkcitadel.com/wiki/Image:Test.png

The first revert link is:
http://www.thedarkcitadel.com/w/index.php?title=Image:Test.png&action=revert&oldimage=20080401073840%21Test.png&wpEditToken=baleeted

DB:

SELECT * FROM mediawiki.image WHERE img_name = 'Test.png';
img_name | img_size | img_width | img_height | img_metadata | img_bits | img_media_type | img_major_mime | img_minor_mime | img_description | img_user | img_user_text | img_timestamp | img_sha1
----------+----------+-----------+------------+--------------+----------+----------------+----------------+----------------+-----------------+----------+---------------+------------------------+---------------------------------
Test.png | 1136 | 85 | 62 | 0 | 8 | BITMAP | image | png | test2 | 1 | OverlordQ | 2008-04-01 02:38:40-05 | p67o12rr7u25qrqw835mb0ym0v6cynd


SELECT * FROM mediawiki.oldimage WHERE oi_name = 'Test.png';
oi_name | oi_archive_name | oi_size | oi_width | oi_height | oi_bits | oi_description | oi_user | oi_user_text | oi_timestamp | oi_metadata | oi_media_type | oi_major_mime | oi_minor_mime | oi_deleted | oi_sha1
----------+-------------------------+---------+----------+-----------+---------+----------------+---------+--------------+------------------------+-------------+---------------+---------------+---------------+------------+---------------------------------
Test.png | 20080401073840!Test.png | 1152 | 85 | 62 | 8 | test | 1 | OverlordQ | 2008-04-01 02:37:19-05 | 0 | BITMAP | image | png | 0 | k4iyxkor2h2mhjq73i2wckvp8hgdty5

The bug wasn't PostgreSQL-specific, it was just slightly noisier in PostgreSQL than in MySQL. Fixed in r13532.

Jdforrester-WMF subscribed.

Migrating from the old tracking task to a tag for PostgreSQL-related tasks.