MantisBT - Piwigo
View Issue Details
0001739Piwigophotospublic2010.06.23 00:142010.06.30 00:03
madman 
nikrou 
normalminoralways
closedfixed 
PostgresqlCentOS 5.4Postgresql 8.4.2
2.1.1 
2.1.2 
Mozilla
Postgresql 8.4.2
5.3.2
Apache 2.2.3
0001739: [PostgreSQL] Recent pictures page returns database error
Because there are no images in the database, the recent pictures page fails. The query in admin/element_set.php on line 196 return a single row with no value, because there are no images in the database.

I suggest the following rewrite:

  $query = 'SELECT MAX(date_available) AS date
  FROM '.IMAGES_TABLE;
  if ($row = pwg_db_fetch_assoc( pwg_query($query) ) )
  {
    if (isset($row['date']))
    {
      $query = 'SELECT id
  FROM '.IMAGES_TABLE.'
  WHERE date_available BETWEEN '.pwg_db_get_recent_period_expression(1, $row['date']).' AND \''.$row['date'].'\'';
      $page['cat_elements_id'] = array_from_query($query, 'id');
    }
  }
New installation -> Administration -> Photos -> Recent pictures
Warning: pg_query() [function.pg-query]: Query failed: ERROR: invalid input syntax for type date: "" LINE 3: WHERE date_available BETWEEN (''::date - '1 DAY'::interval... ^ in /var/www/sites/fotos.aarjan.nl/piwigo/piwigo_svn/include/dblayer/functions_pgsql.inc.php on line 122
SELECT id FROM piwigo_images WHERE date_available BETWEEN (''::date - '1 DAY'::interval)::date AND ''
ERROR: invalid input syntax for type date: "" LINE 3: WHERE date_available BETWEEN (''::date - '1 DAY'::interval... ^
No tags attached.
Issue History
2010.06.23 00:14madmanNew Issue
2010.06.23 00:14madmanbrowser => Mozilla
2010.06.23 00:14madmanDatabase engine and version => Postgresql 8.4.2
2010.06.23 00:14madmanPHP version => 5.3.2
2010.06.23 00:14madmanWeb server => Apache 2.2.3
2010.06.23 20:18nikrouStatusnew => assigned
2010.06.23 20:18nikrouAssigned To => nikrou
2010.06.24 20:48svnCheckin
2010.06.24 20:48svnNote Added: 0004002
2010.06.24 20:49svnCheckin
2010.06.24 20:49svnNote Added: 0004003
2010.06.24 20:50nikrouStatusassigned => closed
2010.06.24 20:50nikrouResolutionopen => fixed
2010.06.24 20:50nikrouFixed in Version => 2.1.2
2010.06.30 00:03plgSummaryRecent pictures page returns database error => [PostgreSQL] Recent pictures page returns database error

Notes
(0004002)
svn   
2010.06.24 20:48   
[Subversion] r6599 by nikrou on trunk

-----[Subversion commit log]----------------------------------------------------
Bug 1739 fixed : Recent pictures page returns database error
If there's no image in database, don't select thems !
(0004003)
svn   
2010.06.24 20:49   
[Subversion] r6600 by nikrou on branch 2.1

-----[Subversion commit log]----------------------------------------------------
Bug 1739 fixed : Recent pictures page returns database error
merge from trunk