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

SQL error DUPLICATE for KEY in FORUMS_TRACK_TABLE

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.1.6-RC1
    • 3.0.10
    • Viewing forums
    • None

      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

            bantu Andreas Fischer [X] (Inactive)
            javiexin javiexin [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: