dokuwiki-plugin-struct
dokuwiki-plugin-struct copied to clipboard
Row IDs in lookup schemas are recycled, potentially leading to wrong data
It seems that when deleting rows and adding new ones to a lookup schema, IDs will be reused. So any existing page that points at an ID that gets deleted will later on contain whatever new data is entered into the lookup schema.
To illustrate, let's make a lookup schema called verdicts
and one field, verdict
, then populate it with the following data:
rowid | verdict |
---|---|
1 | guilty |
2 | not guilty |
Let's say this is used in a wiki that documents court decisions with one page per decision:
page | verdict |
---|---|
charles_manson | guilty |
joerg_kachelmann | not guilty |
Now we delete the verdict "not guilty" from the lookup schema and insert "execution" before adding "not guilty" again, resulting in this:
rowid | verdict |
---|---|
1 | guilty |
2 | execution |
3 | not guilty |
Which will make the pages show the following data:
page | verdict |
---|---|
charles_manson | guilty |
joerg_kachelmann | execution |
:scream:
I think it would cause fewer problems if the rowid were an auto-increment without recycling IDs, so that in the situation above, this would have happened instead:
rowid | verdict |
---|---|
1 | guilty |
3 | execution |
4 | not guilty |
Records pointing to rowid 2 would simply point to nothing, but that is better than pointing at wrong data, isn't it?