-
-
Notifications
You must be signed in to change notification settings - Fork 213
Delete old search entry if new URL is more canonical #8647
Delete old search entry if new URL is more canonical #8647
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of deleting and adding a new record, how about updating the URL so the existing entry is re-used?
A new record is not always created, this depends on the |
|
That's not entirely true. We could run: $db
->prepare('UPDATE tl_search SET url=? WHERE id=?')
->execute($arrSet['url'], $objIndex->id)
;Then the query in line 201 would find the existing record. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we really want to delete the existing record, we must also remove the child records from tl_search_index.
I don’t think so. This would result in a |
Addressed in fb40870 |
You are right, of course. |
|
Why would that result in a duplicate index issue when we update the URL?
|
|
Because an entry with the new URL might already exist and the URL column has an unique index. I tried it out and got the |
|
I don't understand that.
|
|
@aschempp see codefog/contao-cookiebar#21 (comment) for an example. The same page could be present multiple times in the |
|
I do understand that, but how can this be an issue if we add a new database record with exactly that URL and checksum just a few code lines later?
|
A few lines later there is a check if an entry with that URL already exists. Only if it doesn’t exist a new record is created, otherwise the existing record gets updated. And this record doesn’t have the same URL as the record we have deleted. |
Fixes #8498, #8460