Author: mike
Description:
Product Version
MediaWiki 1.16.4
PHP 5.3.6-pl0-gentoo (cgi-fcgi)
PostgreSQL 9.0.3 (but also seen with 8.4)
EXECUTING THIS API QUERY (but under PostgreSQL):
http://en.wikipedia.org/w/api.php?action=query&list=recentchanges&rcend=2010-05-06T14:31:51Z&rclimit=1&rcprop=title|timestamp&rctype=edit&format=xmlfm
RETURNS THIS ERROR VIA API:
error code="internal_api_error_DBUnexpectedError" info="Exception Caught: A database error
has occurred Query: SELECT
rc_timestamp,rc_namespace,rc_title,rc_cur_id,rc_type,rc_moved_to_ns,rc_moved_to_title FROM
recentchanges WHERE (rc_timestamp>='20100506143151') AND rc_deleted =
'0' AND rc_type = '0' ORDER BY rc_timestamp DESC LIMIT 2
Function: ApiQueryRecentChanges::execute Error: 1 ERROR: invalid input syntax for
type timestamp with time zone: "20100506143151" LINE 1: ...title FROM recentchanges
WHERE (rc_timestamp>='201005061...
WHICH IS LOGGED AS:
> /var/log/php5-cgi.log <
[14-Jun-2011 05:20:26] PHP Warning: pg_query() [<a href='function.pg-query'>function.pg-query</a>]: Query failed: ERROR: invalid input syntax for type timestamp with time zone: "20100506143151"
LINE 1: ...title FROM recentchanges WHERE (rc_timestamp>='201005061...
^ in /var/www/localhost/htdocs/mediawiki/includes/db/DatabasePostgres.php on line 584
MY FIX to includes/api/ApiBase.php:
case 'timestamp':
if ( $multi ) { ApiBase::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" ); } $value = wfTimestamp( TS_UNIX, $value ); if ( $value === 0 ) { $this->dieUsage( "Invalid value '$value' for timestamp parameter $encParamName", "badtimestamp_{$encParamName}" ); }
$value = wfTimestamp(TS_MW, $value);
// MCA. Above fails on PostgreSQL. It works if space inserted between date and time,
// thus "20100506 143151". But here is an easier fix: $value = wfTimestamp( TS_POSTGRES, $value ); break;
Version: 1.16.x
Severity: major
OS: Linux