MantisBT - Piwigo
View Issue Details
0001762Piwigodatabasepublic2010.07.04 19:242010.07.05 22:55
madman 
nikrou 
normalminoralways
closedfixed 
PostgresqlCentOS 5.4Postgresql 8.4.2
2.1.2 
2.1.3 
Mozilla
Postgresql 8.4.2
5.3.2
Apache 2.2.3
0001762: Compleet RSS Feed returns notice
When the compleet RSS Feed is openend for the first time, it returns a PHP Notice This is due to an different date/time format returned by the now() function of PostgreSQL. Note that there is no Notice when the page is refreshed.

This date/time is queried on line 104 of feed.php and notice appears in mysqldt_to_ts() function.

I would suggest to create a pwg_db_date_to_ts() function, which should be implemented for all databases.

The PostgreSQL implementation could be like this:

function pwg_db_date_to_ts($date_string)
{
  $date = explode_db_date($date_string)

  return mktime($date['hour'], $date['minute'], $date['second'],
                $date['month'], $date['day'], $date['year']);
}

function explode_db_date($date_string)
{
  $date = array();
  list($date['year'],
       $date['month'],
       $date['day'],
       $date['hour'],
       $date['minute'],
       $date['second'],
       $date['milisecond'])
    = preg_split('/[-: .+]/', $date_string);

  return $date;
}

Note that the timezone parameter is dropped. This is because the last_check field of the USER_FEED_TABLE is 'timestamp without time zone'. This means that the date format in this table differs from the now() function. To prevent a notice that the preg_split function is returning less elements than the array, the timezone should be dropped or the database should be changed.
[root@www piwigo_svn]# psql piwigo
psql (8.4.2)
Type "help" for help.

piwigo=# SELECT NOW();
              now
-------------------------------
 2010-07-04 18:34:01.861436+02
(1 row)

piwigo=# select * from piwigo_user_feed;
                         id | user_id | last_check
----------------------------------------------------+---------+----------------------------
 90uZmU3BDwfct709JQv721g4o23fvc7v8L4xv9xhUyF5H1k0t8 | 1 | 2010-07-04 19:16:30.445963
 Q4Xk524KNhGFI1Q85bLJuo995l1y186986N236QZ7RgB99SnNm | 1 | 2010-07-04 19:17:16.234485
(2 rows)

piwigo=# \d piwigo_user_feed;
                          Table "public.piwigo_user_feed"
   Column | Type | Modifiers
------------+-----------------------------+----------------------------------------
 id | character varying(50) | not null default ''::character varying
 user_id | integer | not null default 0
 last_check | timestamp without time zone |
Indexes:
    "piwigo_user_feed_pkey" PRIMARY KEY, btree (id)

piwigo=# \q
No tags attached.
Issue History
2010.07.04 19:24madmanNew Issue
2010.07.04 19:24madmanbrowser => Mozilla
2010.07.04 19:24madmanDatabase engine and version => Postgresql 8.4.2
2010.07.04 19:24madmanPHP version => 5.3.2
2010.07.04 19:24madmanWeb server => Apache 2.2.3
2010.07.05 09:56nikrouStatusnew => assigned
2010.07.05 09:56nikrouAssigned To => nikrou
2010.07.05 22:46svnCheckin
2010.07.05 22:46svnNote Added: 0004028
2010.07.05 22:54svnCheckin
2010.07.05 22:54svnNote Added: 0004029
2010.07.05 22:55nikrouStatusassigned => closed
2010.07.05 22:55nikrouResolutionopen => fixed
2010.07.05 22:55nikrouFixed in Version => 2.1.3

Notes
(0004028)
svn   
2010.07.05 22:46   
[Subversion] r6662 by nikrou on trunk

-----[Subversion commit log]----------------------------------------------------
Bug 1762 fixed : Compleet RSS Feed returns notice
Remove mysql specific function
(0004029)
svn   
2010.07.05 22:54   
[Subversion] r6663 by nikrou on branch 2.1

-----[Subversion commit log]----------------------------------------------------
Bug 1762 fixed : Compleet RSS Feed returns notice
Remove mysql specific function
Merge from trunk