-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not delete and recreate index on class definitions save (#135)
* add command to reindex class definitions with deployment * Apply php-cs-fixer changes * apply feedback from review * fix: qodana * Apply php-cs-fixer changes * first adaptations * use native reindex * use native reindex * fix qodana errors * Apply php-cs-fixer changes * fix errors * fix errors * fix errors * reindex command should not queue items * Apply php-cs-fixer changes * add different class definition for mapping tests * Apply php-cs-fixer changes --------- Co-authored-by: lukmzig <lukmzig@users.noreply.github.com>
- Loading branch information
Showing
21 changed files
with
491 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under following license: | ||
* - Pimcore Commercial License (PCL) | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\GenericDataIndexBundle\Command; | ||
|
||
use Exception; | ||
use Pimcore\Bundle\GenericDataIndexBundle\Exception\CommandAlreadyRunningException; | ||
use Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\ReindexServiceInterface; | ||
use Pimcore\Console\AbstractCommand; | ||
use Symfony\Component\Console\Command\LockableTrait; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class ReindexItemsCommand extends AbstractCommand | ||
{ | ||
use LockableTrait; | ||
|
||
public function __construct( | ||
private readonly ReindexServiceInterface $reindexService, | ||
string $name = null | ||
) { | ||
parent::__construct($name); | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
$this | ||
->setName('generic-data-index:reindex') | ||
->setDescription( | ||
'Triggers native reindexing of existing indices.' | ||
); | ||
} | ||
|
||
/** | ||
* @throws CommandAlreadyRunningException | ||
* | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
if (!$this->lock()) { | ||
throw new CommandAlreadyRunningException( | ||
'The command is already running in another process.' | ||
); | ||
} | ||
|
||
try { | ||
$this->reindexService->reindexAllIndices(); | ||
} catch (Exception $e) { | ||
$output->writeln('<error>' . $e->getMessage() . '</error>'); | ||
} finally { | ||
$this->release(); | ||
} | ||
|
||
return self::SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under following license: | ||
* - Pimcore Commercial License (PCL) | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\GenericDataIndexBundle\Message; | ||
|
||
use Pimcore\Model\DataObject\ClassDefinition; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final readonly class UpdateClassMappingMessage | ||
{ | ||
public function __construct( | ||
private ClassDefinition $classDefinition, | ||
private bool $dispatchQueueMessages = false | ||
) { | ||
} | ||
|
||
public function getClassDefinition(): ClassDefinition | ||
{ | ||
return $this->classDefinition; | ||
} | ||
|
||
public function isDispatchQueueMessages(): bool | ||
{ | ||
return $this->dispatchQueueMessages; | ||
} | ||
} |
Oops, something went wrong.