Do not delete items on read-only index

Created on 18 December 2024, 8 months ago

Issue

On `src/Plugin/search_api/backend/SearchApiSolrBackend.php` function `deleteAllIndexItems` we are not checking that the index is read-only.

In this file from `search_api` module, `search_api/src/Entity/Server.php`, we check the read-only property. See `deleteAllIndexItems`.

Solution

Add code to check the read-only property in `Drupal\search_api_solr\Plugin\search_api\backend::deleteAllIndexItems`, as in `Drupal\search_api\Entity\Server::deleteAllIndexItems`.
```
if ($index->isReadOnly()) {
$vars = [
'%index' => $index->label(),
];
$this->getLogger()->warning('Trying to delete items from index %index which is marked as read-only.', $vars);
return;
}
```

🐛 Bug report
Status

Active

Version

4.3

Component

Code

Created by

🇪🇨Ecuador betoaveiga Daule, Guayas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @betoaveiga
  • 🇪🇨Ecuador betoaveiga Daule, Guayas

    Here is a patch for 4.3.1

  • 🇪🇨Ecuador betoaveiga Daule, Guayas

    A patch for 4.x version.

  • Status changed to Needs work 3 months ago
  • 🇩🇪Germany mkalkbrenner 🇩🇪

    Thanks for the patch. But as you mentioned, the log entry is generated in the Server class which then doesn't call the method on the backend anymore. The function is not meant to be called directly.

    If we should harden the code if called directly, we need to do it for all methods, for example deleteItems().

Production build 0.71.5 2024