Last modified: 2013-09-04 11:49:48 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T33007, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 31007 - rebuildrecentchanges.php fails for Postgresql with strings for integers
rebuildrecentchanges.php fails for Postgresql with strings for integers
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Maintenance scripts (Other open bugs)
1.17.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
: 31648 32861 36179 (view as bug list)
Depends on:
Blocks: postgres
  Show dependency treegraph
 
Reported: 2011-09-19 19:47 UTC by John Andrea
Modified: 2013-09-04 11:49 UTC (History)
7 users (show)

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


Attachments
Patch to fix rebuildrecentchanges PostgreSQL bug. (671 bytes, patch)
2011-12-29 01:01 UTC, Tim Landscheidt
Details

Description John Andrea 2011-09-19 19:47:44 UTC
After importing XML dump from a MySQL into empty Postgresql 8.4.8 backend
using rebuildrecentchanges.php fails with:

php maintenance/rebuildrecentchanges.php
Loading from page and revision tables...
$wgRCMaxAge=7862400 (91 days)
Updating links and size differences...
Warning: pg_query(): Query failed: ERROR:  invalid input syntax for integer: "NULL"
LINE 1: ...did = '0',rc_new = '1',rc_type = '1',rc_old_len = 'NULL',rc_...
                                                             ^ in /data/services/wiki/mediawiki-1.17.0/includes/db/DatabasePostgres.php on line 237
A database query syntax error has occurred.
The last attempted database query was:
"UPDATE  recentchanges SET rc_last_oldid = '0',rc_new = '1',rc_type = '1',rc_old_len = 'NULL',rc_new_len = '7008' WHERE rc_cur_id = '5' AND rc_this_oldid = '6'"
from within function "RebuildRecentchanges::rebuildRecentChangesTablePass2".
Database returned error "1: ERROR:  invalid input syntax for integer: "NULL"
LINE 1: ...did = '0',rc_new = '1',rc_type = '1',rc_old_len = 'NULL',rc_...
Comment 1 John Andrea 2011-09-19 19:51:17 UTC
Bug appears similar to
https://bugzilla.wikimedia.org/show_bug.cgi?id=13453
which is marked as fixed.

The value for an integer can be NULL, but obviously not the string "NULL".
Comment 2 Brion Vibber 2011-09-19 19:52:35 UTC
Looks like a regression in r77778 -- this line:

				$size = !is_null( $size ) ? intval( $size ) : 'NULL';

was meant for generating raw SQL. When passing to the query builder functions, it should pass the NULL value through directly.
Comment 3 Brion Vibber 2011-09-19 20:03:38 UTC
Should be fixed in r97544 on trunk.

Merged as r97545 on REL1_18 and r97546 on REL1_17. Shouldn't be needed on 1.17wmf1 as we don't use that script in production much.

You can work around it in your local instance by removing the line listed above in maintenance/rebuildrecentchanges.php.
Comment 4 Chad H. 2011-10-13 21:38:33 UTC
*** Bug 31648 has been marked as a duplicate of this bug. ***
Comment 5 Max 2011-11-22 15:15:54 UTC
I have some remarks on this fix:

1) The fix in r97544 won't solve the problem entirely, because the field rc_old_len will take the value of $lastSize which in some cases can be the string 'NULL'. I just unquoted the 'NULL' values and it seemed to work.

2) Removing this line

   $size = !is_null( $size ) ? intval( $size ) : 'NULL';

As far as I can tell "DatabaseBase::selectField() returns: the value from the field, or false on failure.". Not 100% sure what happens after that, but I think that line should be something like this, instead of being deleted:

   $size = ( $size !== false ) ? intval( $size ) : NULL;

Unfortunately I'm not that wiki-expert to know all the implications of all this changes, so maybe someone with more experience can have a look at my observations.
Comment 6 Brion Vibber 2011-12-08 19:38:52 UTC
*** Bug 32861 has been marked as a duplicate of this bug. ***
Comment 7 Tim Landscheidt 2011-12-29 01:00:22 UTC
(In reply to comment #5)
> [...]
> Unfortunately I'm not that wiki-expert to know all the implications of all this
> changes, so maybe someone with more experience can have a look at my
> observations.
Not being one either, I looked at the code path, and Database::makeList seems to behave like you expected (though it isn't documented).  I tested the patch I'll upload in a bit, and it worked fine.  Could someone commit it please?
Comment 8 Tim Landscheidt 2011-12-29 01:01:36 UTC
Created attachment 9778 [details]
Patch to fix rebuildrecentchanges PostgreSQL bug.
Comment 9 Mark A. Hershberger 2012-01-03 23:42:52 UTC
r107964
Comment 10 Tim Landscheidt 2012-09-19 14:49:36 UTC
*** Bug 36179 has been marked as a duplicate of this bug. ***

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


Navigation
Links