mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 20:56:12 +01:00
BUGFIX: Handle missing configuration in hook
* Don't break if no configuration exists, instead improve logging.
This commit is contained in:
parent
24deb93b4f
commit
1878209b51
2 changed files with 33 additions and 8 deletions
|
@ -40,6 +40,7 @@ class ConfigurationContainer implements ConfigurationContainerInterface
|
||||||
* Inject settings via ConfigurationManager.
|
* Inject settings via ConfigurationManager.
|
||||||
*
|
*
|
||||||
* @param ConfigurationManagerInterface $configurationManager
|
* @param ConfigurationManagerInterface $configurationManager
|
||||||
|
* @throws NoConfigurationException
|
||||||
*/
|
*/
|
||||||
public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
|
public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
|
||||||
{
|
{
|
||||||
|
@ -49,7 +50,7 @@ class ConfigurationContainer implements ConfigurationContainerInterface
|
||||||
'search'
|
'search'
|
||||||
);
|
);
|
||||||
if ($this->settings === null) {
|
if ($this->settings === null) {
|
||||||
$this->settings = [];
|
throw new NoConfigurationException('Could not fetch configuration.', 1484226842);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ namespace Leonmrni\SearchCore\Hook;
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Leonmrni\SearchCore\Configuration\NoConfigurationException;
|
||||||
|
use Leonmrni\SearchCore\Domain\Service\DataHandler as OwnDataHandler;
|
||||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||||
use TYPO3\CMS\Core\DataHandling\DataHandler as CoreDataHandler;
|
use TYPO3\CMS\Core\DataHandling\DataHandler as CoreDataHandler;
|
||||||
use TYPO3\CMS\Core\Log\LogManager;
|
use TYPO3\CMS\Core\Log\LogManager;
|
||||||
|
@ -27,7 +29,6 @@ use TYPO3\CMS\Core\Log\Logger;
|
||||||
use TYPO3\CMS\Core\SingletonInterface as Singleton;
|
use TYPO3\CMS\Core\SingletonInterface as Singleton;
|
||||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||||
use Leonmrni\SearchCore\Domain\Service\DataHandler as OwnDataHandler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for TYPO3 Hooks to internal API.
|
* Wrapper for TYPO3 Hooks to internal API.
|
||||||
|
@ -55,8 +56,13 @@ class DataHandler implements Singleton
|
||||||
{
|
{
|
||||||
$this->dataHandler = $dataHandler;
|
$this->dataHandler = $dataHandler;
|
||||||
if ($this->dataHandler === null) {
|
if ($this->dataHandler === null) {
|
||||||
|
try {
|
||||||
$this->dataHandler = GeneralUtility::makeInstance(ObjectManager::class)
|
$this->dataHandler = GeneralUtility::makeInstance(ObjectManager::class)
|
||||||
->get(OwnDataHandler::class);
|
->get(OwnDataHandler::class);
|
||||||
|
} catch (NoConfigurationException $e) {
|
||||||
|
// We have no configuration. That's fine, hooks will not be
|
||||||
|
// executed due to check for existing DataHandler.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
@ -76,8 +82,8 @@ class DataHandler implements Singleton
|
||||||
*/
|
*/
|
||||||
public function processCmdmap_deleteAction($table, $uid)
|
public function processCmdmap_deleteAction($table, $uid)
|
||||||
{
|
{
|
||||||
if (! $this->shouldProcessTable($table)) {
|
if (! $this->shouldProcessHookForTable($table)) {
|
||||||
$this->logger->debug('Delete not processed, cause table is not allowed.', [$table]);
|
$this->logger->debug('Delete not processed.', [$table, $uid]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,8 +104,8 @@ class DataHandler implements Singleton
|
||||||
*/
|
*/
|
||||||
public function processDatamap_afterDatabaseOperations($status, $table, $uid, array $fieldArray, CoreDataHandler $dataHandler)
|
public function processDatamap_afterDatabaseOperations($status, $table, $uid, array $fieldArray, CoreDataHandler $dataHandler)
|
||||||
{
|
{
|
||||||
if (! $this->shouldProcessTable($table)) {
|
if (! $this->shouldProcessHookForTable($table)) {
|
||||||
$this->logger->debug('Database update not processed, cause table is not allowed.', [$table]);
|
$this->logger->debug('Database update not processed.', [$table, $uid]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +130,24 @@ class DataHandler implements Singleton
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $table
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function shouldProcessHookForTable($table)
|
||||||
|
{
|
||||||
|
if ($this->dataHandler === null) {
|
||||||
|
$this->logger->debug('Datahandler could not be setup.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (! $this->shouldProcessTable($table)) {
|
||||||
|
$this->logger->debug('Table is not allowed.', [$table]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $table
|
* @param string $table
|
||||||
* @return bool
|
* @return bool
|
||||||
|
|
Loading…
Reference in a new issue