mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-21 21:36:11 +01:00
TASK: Prevent issue When hook is called with non uid
If some issues occur outside of our extension, we might not get a valid uid inside of our hooks. We will therefore add additional checks and prevent any further execution. Resolves: #112
This commit is contained in:
parent
ad7befb911
commit
203b5d7adf
2 changed files with 47 additions and 1 deletions
|
@ -72,7 +72,7 @@ class DataHandler implements Singleton
|
|||
/**
|
||||
* Called by CoreDataHandler on deletion of records.
|
||||
*/
|
||||
public function processCmdmap_deleteAction(string $table, int $uid) : bool
|
||||
public function processCmdmap_deleteAction(string $table, string $uid) : bool
|
||||
{
|
||||
if (! $this->shouldProcessHookForTable($table)) {
|
||||
$this->logger->debug('Delete not processed.', [$table, $uid]);
|
||||
|
@ -95,6 +95,10 @@ class DataHandler implements Singleton
|
|||
$uid = $dataHandler->substNEWwithIDs[$uid];
|
||||
}
|
||||
|
||||
if (!is_numeric($uid) || $uid <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->processRecord($table, $uid);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,4 +91,46 @@ class DataHandlerToProcessorTest extends AbstractUnitTestCase
|
|||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function indexingIsNotCalledForCacheClearIfDataIsInvalid()
|
||||
{
|
||||
$coreDataHandlerMock = $this->getMockBuilder(CoreDataHandler::class)->getMock();
|
||||
$ownDataHandlerMock = $this->getMockBuilder(OwnDataHandler::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$subject = new DataHandler($ownDataHandlerMock);
|
||||
|
||||
$ownDataHandlerMock->expects($this->never())->method('update');
|
||||
|
||||
$subject->clearCachePostProc([
|
||||
'cacheCmd' => 'NEW343',
|
||||
], $coreDataHandlerMock);
|
||||
}
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function indexingIsNotCalledForProcesIfDataIsInvalid()
|
||||
{
|
||||
$coreDataHandlerMock = $this->getMockBuilder(CoreDataHandler::class)->getMock();
|
||||
$coreDataHandlerMock->datamap = [
|
||||
'tt_content' => [
|
||||
'NEW343' => [],
|
||||
],
|
||||
];
|
||||
$coreDataHandlerMock->substNEWwithIDs = [];
|
||||
|
||||
$ownDataHandlerMock = $this->getMockBuilder(OwnDataHandler::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$subject = new DataHandler($ownDataHandlerMock);
|
||||
|
||||
$ownDataHandlerMock->expects($this->never())->method('update');
|
||||
|
||||
$subject->processDatamap_afterAllOperations($coreDataHandlerMock);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue