Author: dnessett
Description:
Clicking on the Toolbox link "RSS" on the "My watchlist" page throws a fatal error. The traceback is:
1: 2: Warning: pg_query(): Query failed: ERROR: invalid input syntax for type timestamp with time zone: "20110314172654" at character 327 in /czdata/dbg/phase3/includes/db/DatabasePostgres.php on line 584 3: 4: Call Stack: 5: 0.0002 673696 1. {main}() /czdata/dbg/phase3/api.php:0 6: 0.0734 16784344 2. ApiMain->execute() /czdata/dbg/phase3/api.php:116 7: 0.0734 16784392 3. ApiMain->executeActionWithErrorHandling() /czdata/dbg/phase3/includes/api/ApiMain.php:322 8: 0.0734 16825512 4. ApiMain->executeAction() /czdata/dbg/phase3/includes/api/ApiMain.php:338 9: 0.0760 17293168 5. ApiFeedWatchlist->execute() /czdata/dbg/phase3/includes/api/ApiMain.php:595
10: 0.0762 17312384 6. ApiMain->execute() /czdata/dbg/phase3/includes/api/ApiFeedWatchlist.php:95
11: 0.0762 17312432 7. ApiMain->executeAction() /czdata/dbg/phase3/includes/api/ApiMain.php:320
12: 0.0778 17568576 8. ApiQuery->execute() /czdata/dbg/phase3/includes/api/ApiMain.php:595
13: 0.0819 18536048 9. ApiQueryWatchlist->execute() /czdata/dbg/phase3/includes/api/ApiQuery.php:233
14: 0.0819 18536048 10. ApiQueryWatchlist->run() /czdata/dbg/phase3/includes/api/ApiQueryWatchlist.php:44
15: 0.0860 18612800 11. ApiQueryBase->select() /czdata/dbg/phase3/includes/api/ApiQueryWatchlist.php:188
16: 0.0860 18612848 12. DatabaseBase->select() /czdata/dbg/phase3/includes/api/ApiQueryBase.php:244
17: 0.0861 18613256 13. DatabaseBase->query() /czdata/dbg/phase3/includes/db/Database.php:874
18: 0.0861 18614056 14. DatabasePostgres->doQuery() /czdata/dbg/phase3/includes/db/Database.php:517
19: 0.0862 18614648 15. pg_query() /czdata/dbg/phase3/includes/db/DatabasePostgres.php:584
20:
21: <?xml version="1.0"?>
22: <?xml-stylesheet type="text/css" href="http://localhost/skins/common/feed.css?270"?>
23: <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
24: <channel>
The problem occurs for the following reason. The timestamp provided to the pg_qurey statement is in TS_UNIX format, not TS_POSTGRES format. It appears there is a serious flaw with the logic visited as the result of the piQueryWatchlist->execute() call. In particular, at line 644 of ApiBase->getParameterFromSettingsm, thje case statement for 'timestamp' takes the TS_POSTGRES formatted timestamp and converts it first to TS_UNIX and then to TS_MW. This value is then supplied to the pg_query. A bit of thought reveals why this problem does not occur for MySQL databases. Timestamps in TS_UNIX format are valid for MySQL, so the fatal error doesn't occur.
The stack trace for the timestamp format conversion is:
org.netbeans.modules.viewmodel.TreeModelNode@24740a93[Name=, displayName=includes/api/ApiBase.php.ApiBase->getParameterFromSettings:652]
org.netbeans.modules.viewmodel.TreeModelNode@3e624b97[Name=, displayName=includes/api/ApiBase.php.ApiBase->extractRequestParams:484]
org.netbeans.modules.viewmodel.TreeModelNode@2750c680[Name=, displayName=includes/api/ApiQuery.php.ApiQuery->execute:229]
org.netbeans.modules.viewmodel.TreeModelNode@281811aa[Name=, displayName=includes/api/ApiMain.php.ApiMain->executeAction:595]
org.netbeans.modules.viewmodel.TreeModelNode@442fc476[Name=, displayName=includes/api/ApiMain.php.ApiMain->execute:320]
org.netbeans.modules.viewmodel.TreeModelNode@1c0b41f3[Name=, displayName=includes/api/ApiFeedWatchlist.php.ApiFeedWatchlist->execute:95]
org.netbeans.modules.viewmodel.TreeModelNode@2716c6e7[Name=, displayName=includes/api/ApiMain.php.ApiMain->executeAction:595]
org.netbeans.modules.viewmodel.TreeModelNode@485c7bbd[Name=, displayName=includes/api/ApiMain.php.ApiMain->executeActionWithErrorHandling:338]
Value before conversion (TS_POSTGRES format) is:
2011-03-14 21:32:17 GMT
Value after conversion (TS_MW format) is:
20110314213217
The logic causing this problem is intricate and I cannot suggest a fix. However, somehow the TS_POSTGRES formatted time should be supplied to the pg_query, not the TS_MW formatted time. How to effect this change and still maintain other valid uses of ApiQuery isn't clear (at least it isn't clear to me).
Version: 1.16.x
Severity: critical