Skip to content

Commit 8d37dc1

Browse files
[BUGFIX] Fix assignment of storagePid and streamline initializeRepositories in BaseCommand (#1219)
Co-authored-by: Sebastian Meyer <[email protected]>
1 parent 86c0697 commit 8d37dc1

File tree

5 files changed

+11
-20
lines changed

5 files changed

+11
-20
lines changed

Classes/Command/BaseCommand.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,25 +124,16 @@ public function __construct(
124124
*
125125
* @param int $storagePid The storage pid
126126
*
127-
* @return bool
127+
* @return void
128128
*/
129-
protected function initializeRepositories(int $storagePid): bool
129+
protected function initializeRepositories(int $storagePid): void
130130
{
131-
if (MathUtility::canBeInterpretedAsInteger($storagePid)) {
132-
$frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
133-
134-
$frameworkConfiguration['persistence']['storagePid'] = MathUtility::forceIntegerInRange((int) $storagePid, 0);
135-
$this->configurationManager->setConfiguration($frameworkConfiguration);
136-
137-
// Get extension configuration.
138-
$this->extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('dlf');
139-
} else {
140-
return false;
141-
}
142-
$this->storagePid = MathUtility::forceIntegerInRange((int) $storagePid, 0);
131+
$frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
132+
$frameworkConfiguration['persistence']['storagePid'] = MathUtility::forceIntegerInRange($storagePid, 0);
133+
$this->configurationManager->setConfiguration($frameworkConfiguration);
134+
$this->extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('dlf');
135+
$this->storagePid = MathUtility::forceIntegerInRange($storagePid, 0);
143136
$this->persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class);
144-
145-
return true;
146137
}
147138

148139
/**

Classes/Command/DeleteCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8181
$io = new SymfonyStyle($input, $output);
8282
$io->title($this->getDescription());
8383

84-
$this->initializeRepositories($input->getOption('pid'));
84+
$this->initializeRepositories((int) $input->getOption('pid'));
8585

8686
if ($this->storagePid == 0) {
8787
$io->error('ERROR: No valid PID (' . $this->storagePid . ') given.');

Classes/Command/HarvestCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
108108
$io = new SymfonyStyle($input, $output);
109109
$io->title($this->getDescription());
110110

111-
$this->initializeRepositories($input->getOption('pid'));
111+
$this->initializeRepositories((int) $input->getOption('pid'));
112112

113113
if ($this->storagePid == 0) {
114114
$io->error('ERROR: No valid PID (' . $this->storagePid . ') given.');

Classes/Command/IndexCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9595
$io = new SymfonyStyle($input, $output);
9696
$io->title($this->getDescription());
9797

98-
$this->initializeRepositories($input->getOption('pid'));
98+
$this->initializeRepositories((int) $input->getOption('pid'));
9999

100100
if ($this->storagePid == 0) {
101101
$io->error('ERROR: No valid PID (' . $this->storagePid . ') given.');

Classes/Command/ReindexCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
111111
$io = new SymfonyStyle($input, $output);
112112
$io->title($this->getDescription());
113113

114-
$this->initializeRepositories($input->getOption('pid'));
114+
$this->initializeRepositories((int) $input->getOption('pid'));
115115

116116
if ($this->storagePid == 0) {
117117
$io->error('ERROR: No valid PID (' . $this->storagePid . ') given.');

0 commit comments

Comments
 (0)