Last modified: 2012-09-08 00:35:26 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 32822 - Upload image, delete and upload it again causes database error with postgresql
Upload image, delete and upload it again causes database error with postgresql
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Database (Other open bugs)
1.18.x
All Linux
: High normal (vote)
: 1.19.0 release
Assigned To: Brion Vibber
: patch, patch-reviewed
Depends on:
Blocks: postgres
  Show dependency treegraph
 
Reported: 2011-12-06 01:56 UTC by Simon Dwyer
Modified: 2012-09-08 00:35 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
PHP Debug (17.88 KB, text/x-log)
2011-12-06 01:56 UTC, Simon Dwyer
Details
7/12/11 (18.21 KB, text/x-log)
2011-12-07 01:58 UTC, Simon Dwyer
Details
Possible fix - patch to includes/upload/UploadStash.php (455 bytes, patch)
2012-01-09 22:33 UTC, Brion Vibber
Details

Description Simon Dwyer 2011-12-06 01:56:59 UTC
Created attachment 9620 [details]
PHP Debug

Fresh install. 

Uploaded a png.

Deleted the png.

Upload the png again.

Get attached error with phpdebug.

This is a fresh install of mediawiki on centos

[root@networkmanager wiki]# php -v
PHP 5.3.3 (cli) (built: Oct 24 2011 08:35:41)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies


[root@networkmanager wiki]# postgres -V
postgres (PostgreSQL) 8.4.9
Comment 1 Simon Dwyer 2011-12-06 02:05:08 UTC
running php cleanupUploadStash also causes an error.

[root@networkmanager maintenance]# php cleanupUploadStash.php 
Getting list of files to clean up...
PHP Warning:  pg_query(): Query failed: ERROR:  syntax error at or near "20"
LINE 1: ...OM "uploadstash"  WHERE us_timestamp < 2011-12-05 20:05:47 G...
                                                             ^ in /var/www/wiki/includes/db/DatabasePostgres.php on line 253

Warning: pg_query(): Query failed: ERROR:  syntax error at or near "20"
LINE 1: ...OM "uploadstash"  WHERE us_timestamp < 2011-12-05 20:05:47 G...
                                                             ^ in /var/www/wiki/includes/db/DatabasePostgres.php on line 253
A database error has occurred.  Did you forget to run maintenance/update.php after upgrading?  See: http://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script
Query: SELECT  us_key  FROM "uploadstash"  WHERE us_timestamp < 2011-12-05 20:05:47 GMT  
Function: UploadStashCleanup::execute
Error: 1 ERROR:  syntax error at or near "20"
LINE 1: ...OM "uploadstash"  WHERE us_timestamp < 2011-12-05 20:05:47 G...
Comment 2 Brion Vibber 2011-12-06 18:09:15 UTC
Looks like something's missing quotes -- eek!
Comment 3 Brion Vibber 2011-12-06 18:13:46 UTC
r92081 introduced use of $db->timestamp here without the quotes (previously it was wfTimestamp(TS_MW) which at least produced a number that worked without quotes, though it would have been wrong presumably for some db types such as PG)
Comment 4 Brion Vibber 2011-12-06 18:15:52 UTC
r105322 should fix that part on trunk. Looking for the other bit...
Comment 5 Brion Vibber 2011-12-06 18:18:37 UTC
Not sure what's up with the initial problem; can you confirm if the 'uploadstash' table is actually present? Maybe the updaters didn't work or didn't get run?
Comment 6 Simon Dwyer 2011-12-06 20:13:39 UTC
I didnt need to run the updater as this was a fresh install. 

so r105322 should fix my inital problem?  i only added this uploadhash one because i thought they might be related. do i need to make a second bug report?

Thanks for the help
Comment 7 Simon Dwyer 2011-12-06 20:16:16 UTC
ahh r105322 fixes the maintenance uploadstash.  so initial problem is still being looked at.
Comment 8 Brion Vibber 2011-12-06 20:17:27 UTC
No, r105322 will fix the second problem (cleanupUploadStash.php)

It looks like your first problem is because the postgresql tables.sql in 1.18.0 didn't get updated to include the uploadstash table!
Comment 9 Brion Vibber 2011-12-06 20:19:23 UTC
r100640 added the table to postgres's tables.sql, but didn't make it into 1.18.0. Looks like it may also be missing an updater...
Comment 10 Simon Dwyer 2011-12-06 20:27:41 UTC
Thanks for looking into this.  So i will have to wait for the next point release to create my site with postgresql?  or will r100640 get merged into trunk and i can pull off the svn/git?
Comment 11 Brion Vibber 2011-12-06 20:51:28 UTC
r105349 on REL1_18 should fix it on the branch for the next point release.


You should be able to pull the files out of SVN on trunk or on the branch -- if you want you can probably just grab this and run it into your db:

https://svn.wikimedia.org/viewvc/mediawiki/branches/REL1_18/phase3/maintenance/postgres/archives/patch-uploadstash.sql?view=markup
Comment 12 Simon Dwyer 2011-12-07 00:10:31 UTC
No luck there.  Added that to the database and still get the same error.  Its ok i will keep going without images untill next release.
Comment 13 Simon Dwyer 2011-12-07 01:58:01 UTC
Have pulled down the latest svn

svn checkout http://svn.wikimedia.org/svnroot/mediawiki/branches/REL1_18/phase3

and installed from scratch with new database.

Same issue as before as i can see.  uploading new php.log
Comment 14 Simon Dwyer 2011-12-07 01:58:36 UTC
Created attachment 9628 [details]
7/12/11
Comment 15 avtargill 2012-01-06 05:47:08 UTC
Debian 6.0
PostgreSQL 8.4
PHP 5.3

I can confirm that uploading any attachments (not just images) is not possible with the svn branch mentioned in comment #13.  Running the maintenance/update.php script creates the missing table:

mediawiki          | uploadstash             | table | test_wiki_user

But if I upload a file, delete it, and then try uploading it again this error appears:

Warning: Invalid argument supplied for foreach() in /var/www/test-wiki/includes/db/Database.php on line 2253
Warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near ")" LINE 1: ...Stash::stashFile Jon Doe */ FROM "uploadstash" WHERE ) ^ in /var/www/test-wiki/includes/db/DatabasePostgres.php on line 253

I'm not sure if I need to attach any more logs since there already is one here but here are links if required:

With $wgShowExceptionDetails set to true: http://pastebin.com/raw.php?i=myPhBM31
Excerpt from Postgres' log: http://pastebin.com/raw.php?i=TYbncnBm

Making these changes manually doesn't help   https://svn.wikimedia.org/viewvc/mediawiki/branches/REL1_18/phase3/maintenance/postgres/archives/patch-uploadstash.sql?revision=105349&view=co
Comment 16 avtargill 2012-01-09 16:51:49 UTC
Uploads seem to work if "Ignore any warnings" is checked.
Comment 17 Brion Vibber 2012-01-09 22:33:42 UTC
Created attachment 9828 [details]
Possible fix - patch to includes/upload/UploadStash.php

Could you try this one-line patch to includes/upload/UploadStash.php?

The unique indexes parameter on Database::replace() is labeled as taking an array; on MySQL it'll be falling through to the native REPLACE behavior which probably doesn't need it to be an array so it got through sloppily.

(Note that this code doesn't appear to be in 1.19 where this func has changed a lot, so it may not happen on 1.19 at all.)
Comment 18 Krinkle 2012-03-02 21:19:58 UTC
Moving to 1.19.0 as 1.18 is released.
Comment 19 Andre Klapper 2012-05-08 09:14:25 UTC
Can somebody please review the patch in comment 17 and afterwards replace the "patch-need-review" keyword by "patch-reviewed"?
Comment 20 Karun 2012-09-08 00:27:42 UTC
(In reply to comment #19)
> Can somebody please review the patch in comment 17 and afterwards replace the
> "patch-need-review" keyword by "patch-reviewed"?

Hi, the reviews are now down using Gerrit. I am going to test it, and then submit it to Gerrit.
Comment 21 Karun 2012-09-08 00:35:26 UTC
(In reply to comment #19)
> Can somebody please review the patch in comment 17 and afterwards replace the
> "patch-need-review" keyword by "patch-reviewed"?

A patch has already been submitted previously that fixes this bug. Ive tested it and I do not receive any errors.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links