A TYPO3 extension that integrates the Apache Solr search server with TYPO3 CMS. dkd Internet Service GmbH is developing the extension. Community contributions are welcome. See CONTRIBUTING.md for details.
GNU General Public License v3.0
137
stars
252
forks
source link
[BUG] "Clear Index Queue" TypeError Site is null #4095
Describe the bug
When I click the "Clear Index Queue" button in the Index Queue backend module I get an error response from Typo3:
(1/1) TypeError
ApacheSolrForTypo3\Solr\IndexQueue\Queue::deleteItemsBySite(): Argument #1 ($site) must be of type ApacheSolrForTypo3\Solr\Domain\Site\Site, null given, called in /var/www/html/vendor/apache-solr-for-typo3/solr/Classes/Controller/Backend/Search/AbstractModuleController.php on line 231
To Reproduce
Steps to reproduce the behavior:
Have multiple sites
Go to Index Queue backend module
Click on 'Clear Index Queue'
Confirm the popup
See error
Expected behavior
A clean index queue
Used versions (please complete the following information):
TYPO3 Version: 12.4.6
EXT:solr Version: latest dev-release-12.0.x
This probably also applies to master/13 as the relevant code is the same.
Additional context
There is a fallback in AbstractModuleController->initializeAction called "autoSelectFirstSiteAndRootPageWhenOnlyOneSiteIsAvailable" which probably "hides" this bug if you only have one site.
As far as I could debug it:
AbstractModuleController->clearIndexQueueAction() tries using $this->selectedSite which is null.
The AbstractModuleController->initializeAction is responsible for setting the site but the id set in the frontend is not received in the backend. i.e. this condition is always false
if ($this->request->hasArgument('id')) {
$this->selectedPageUID = (int)$this->request->getArgument('id');
}
The id is set in the frontend, but the variable pageUID is null in IndexQueueModule/Index.html
<f:form action="clearIndexQueue" additionalParams="{id: '{pageUID}'}">
That fluid variable is beeing correctly set in AbstractModuleController->initializeView() but does not reach the Index.html
I narrowed it down to the initializeAction beeing called twice:
initializeAction is called automatically by Typo3 -> creates new View
initializeView is called automatically by Typo3
initializeAction is called manually in IndexQueueModuleController->indexAction -> creates new View w/o variables from step 2
Describe the bug When I click the "Clear Index Queue" button in the Index Queue backend module I get an error response from Typo3:
(1/1) TypeError ApacheSolrForTypo3\Solr\IndexQueue\Queue::deleteItemsBySite(): Argument #1 ($site) must be of type ApacheSolrForTypo3\Solr\Domain\Site\Site, null given, called in /var/www/html/vendor/apache-solr-for-typo3/solr/Classes/Controller/Backend/Search/AbstractModuleController.php on line 231
To Reproduce Steps to reproduce the behavior:
Expected behavior A clean index queue
Used versions (please complete the following information):
Additional context There is a fallback in AbstractModuleController->initializeAction called "autoSelectFirstSiteAndRootPageWhenOnlyOneSiteIsAvailable" which probably "hides" this bug if you only have one site.
As far as I could debug it:
<f:form action="clearIndexQueue" additionalParams="{id: '{pageUID}'}">
I narrowed it down to the initializeAction beeing called twice:
IMO the manual call should be deleted https://github.com/TYPO3-Solr/ext-solr/blob/4c13753ce11810e9bbf71745b3a0ca5872191d78/Classes/Controller/Backend/Search/IndexQueueModuleController.php#L68