Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-10711

SQL error DUPLICATE for KEY in FORUMS_TRACK_TABLE

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.10
    • Fix Version/s: 3.1.6-RC1
    • Component/s: Viewing forums
    • Labels:
      None

      Description

      Hello,

      I have found certain situations where marking forums read (viewforum.php?f=xx&mark=forums) would generate an SQL error DUPLICATE ERROR for KEY 'PRIMARY' in the forums_track table. In my case, this has happened when nesting multiple forums within other forums.

      The stack trace shows that this is happening in the [i]markread()[/i] function within [b]includes/functions.php[/b].

      And I have isolated the problem to cases where the [i]$forum_id[/i] variable holds an array with duplicate entries, that creates an issue when finally inserting through the call to [i]sql_multi_insert(FORUMS_TRACK_TABLE, $sql_ary)[/i]

      So, I have applied a change to eliminate these duplicates, seems to work, but would like to know if someone sees any issue with this fix.

      What I have done is the following:
      find:
      [code] if (!is_array($forum_id))

      { $forum_id = array($forum_id); }

      [/code]
      add after:
      [code] else

      { $forum_id = array_unique($forum_id); }

      [/code]
      Any reason why this should not be applied? Would this be something that should be applied to the base phpbb code as a bug fix?
      Thanks,
      -javiexin

        Activity

        Hide
        bantu Andreas Fischer added a comment -

        Can you provide the exact SQL error message?

        Show
        bantu Andreas Fischer added a comment - Can you provide the exact SQL error message?
        Hide
        javiexin javiexin added a comment -

        Not any longer, sorry. The details I have are those explained in the issue. As I fixed it locally in my forum, it never reproduced itself. And it requires a big forum, with a lot of nested forums, to reproduce.

        Show
        javiexin javiexin added a comment - Not any longer, sorry. The details I have are those explained in the issue. As I fixed it locally in my forum, it never reproduced itself. And it requires a big forum, with a lot of nested forums, to reproduce.

          People

          • Assignee:
            bantu Andreas Fischer
            Reporter:
            javiexin javiexin
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development