Skip to content

Commit

Permalink
Remove a page's search index entries when its alias is changed (see #472
Browse files Browse the repository at this point in the history
)

Description
-----------

**How to reproduce the issue:**

* Create a page with the alias `foo`.

* Once you call `example.test/foo.html`, the page gets an entry in `tl_search`.

* Now change the alias to `bar`.

Currently, the entry with the now-outdated URL remains in `tl_search`, which means it shows up in the search results. It only gets removed once you call the outdated URL and get a 404, e. g. by visiting the outdated search result listing.

Also note that if you change only the alias, the page with the new URL does not get added once you visit it. If you change the alias and, e. g., the title, the new URL does get added, but the old one still remains.

**Suggested solution:**

A page's search index entries already get removed when the page is deleted[1]. We should do the same when the alias changes.

---
[1] ba075d0

Commits
-------

7274f39 Remove a page's search index entries when its alias is changed
507c26c Purge search index on alias change: Check for new page by VERSION_NUMBER
f4429a1 Remove page version check altogether
  • Loading branch information
gmpf authored and leofeyer committed Jul 12, 2019
1 parent fc0ddec commit 4abfdb8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core-bundle/src/Resources/contao/dca/tl_page.php
Expand Up @@ -1154,6 +1154,11 @@ public function generateAlias($varValue, DataContainer $dc)
}
}

if ($varValue != $dc->activeRecord->alias)
{
$this->purgeSearchIndex($dc);
}

return $varValue;
}

Expand Down

0 comments on commit 4abfdb8

Please sign in to comment.