Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-9569

General Error in board-wide feed with PostgreSQL (+patch)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • 3.0.7
    • None
    • None
    • PHP 5.2.6, PostgreSQL 8.3.10

      I get the following error when accessing the board-wide feed (myboard.example/feed.php).

      General Error
      SQL ERROR [ postgres ]
       
      ERROR: invalid reference to FROM-clause entry for table "p" LINE 1: ...users u LEFT JOIN phpbb_forums f
      ON (f.forum_id = p.forum_id... ^ HINT: There is an entry for table "p", but it cannot be referenced from
      this part of the query. []
       
      SQL
       
      SELECT f.forum_id, f.forum_name, p.post_id, p.topic_id, p.post_time, p.post_subject, p.post_text,
      p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, u.username,
      u.user_id FROM phpbb_posts p, phpbb_users u LEFT JOIN phpbb_forums f ON (f.forum_id = p.forum_id)
      WHERE p.topic_id = 1 AND (p.post_approved = 1 OR p.forum_id IN (1, 2)) AND p.post_time >= 1272112460
      AND u.user_id = p.poster_id ORDER BY p.post_time DESC LIMIT 15 OFFSET 0
       
      BACKTRACE
       
      FILE: includes/db/postgres.php
      LINE: 177
      CALL: dbal->sql_error()
       
      FILE: includes/db/postgres.php
      LINE: 232
      CALL: dbal_postgres->sql_query()
       
      FILE: includes/db/dbal.php
      LINE: 170
      CALL: dbal_postgres->_sql_query_limit()
       
      FILE: feed.php
      LINE: 621
      CALL: dbal->sql_query_limit()
       
      FILE: feed.php
      LINE: 78
      CALL: phpbb_feed_base->get_item()
      

      I tested release 3.0.7 and the current trunk, both with MySQL and PostgreSQL. The bug appears only with PostgreSQL, but that is probably only because MySQL's relaxed restrictions on SQL queries. I have examined the query that causes the error and I think that the order of tables in the FROM clause is wrong (see e.g. http://archives.postgresql.org/pgsql-general/2006-09/msg01041.php).

      To fix the bug, it is enough to change the order of tables (patch against the current trunk is attached).

            Unassigned Unassigned
            ze.phyr.us ze.phyr.us
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: