My-Little-Forum / mylittleforum

A simple PHP and MySQL based internet forum that displays the messages in classical threaded view (tree structure)
GNU General Public License v3.0
124 stars 48 forks source link

Rework of the database table mlf2_banlists #726

Closed auge8472 closed 3 months ago

auge8472 commented 3 months ago

The table was defined without a primary key. This can cause the multiple presence of the rows under special circumstances (in example after a reimport of the data into the table). This in turn can mean that not all existing values can be managed and utilised.

With the change the old table will be renamed, a new table with a PK will be created and the existing data will be imported into the new table. With the use of one INSERT with GROUP_CONCAT() of the data it is ensured, that the content of the column list of every row with the specified value for the column name gets part of only one row with the specified name value. The last step is to drop the old table from the database.

Known issue: when entries are part of multiple rows in the old table, they will be there multiple times in one row of the new table.

Example:

old table:
==========

name  | list
------------
words | foo
      | bar
      | baz
------------
words | foo
      | baz

new table:
==========

name  | list
------------
words | foo
      | foo
      | bar
      | baz
      | baz

Ths does not affect the feature in itself because a check for a banned value will find the value anyway. It is therefore not immediately necessary to de-duplicate the values. It can be done with another pull request.

This fixes #710.