Skip to content

Commit

Permalink
Skip indexing if a page has not changed (see contao#2250)
Browse files Browse the repository at this point in the history
Description
-----------

| Q                | A
| -----------------| ---
| Fixed issues     | Fixes contao#2235
| Docs PR or issue | -

Same as contao#2249 but for Contao 4.10.

Commits
-------

b669725 Skip indexing if page has not changed
200a704 Fix SQL
c07379c CS
e3310bb Do not cast do boolean
8f00bfb Merge branch '4.10' into fix/search-early-return
  • Loading branch information
ausi authored and Alexej Kossmann committed Apr 6, 2021
1 parent dc5a397 commit 8d23806
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core-bundle/src/Resources/contao/library/Contao/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ public static function indexPage($arrData)
// Calculate the checksum
$arrSet['checksum'] = md5($arrSet['text']);

$blnIndexExists = $objDatabase
->prepare("SELECT EXISTS(SELECT id FROM tl_search WHERE checksum=? AND pid=? AND url=?) as indexExists")
->execute($arrSet['checksum'], $arrSet['pid'], $arrSet['url'])
->indexExists;

// The page has already been indexed and has not changed (see #2235)
if ($blnIndexExists)
{
return false;
}

// Prevent deadlocks
$objDatabase->query("LOCK TABLES tl_search WRITE, tl_search_index WRITE, tl_search_term WRITE");

Expand Down

0 comments on commit 8d23806

Please sign in to comment.