Skip to content

Commit

Permalink
[BUGFIX] Ensure that correct typo3 binary is returned in non-composer…
Browse files Browse the repository at this point in the history
… installations (#1126)

Resolves #1125
  • Loading branch information
tomasnorre authored Feb 5, 2025
1 parent f4b5c8a commit 8eff816
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Changed

### Fixed
* Ensure that correct typo3 binary is returned in non-composer installations

### Deprecated
#### Classes
Expand Down
1 change: 0 additions & 1 deletion Classes/Command/BuildQueueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$configurationKeys
);


// Consider a swith/match statement here, and extract the code in between.
if ($mode === 'url') {
$output->writeln('<info>' . implode(PHP_EOL, $crawlerController->downloadUrls) . PHP_EOL . '</info>');
Expand Down
4 changes: 4 additions & 0 deletions Classes/Service/ProcessService.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ public function getCrawlerCliPath(): string

private function getComposerBinPath(): ?string
{
if (!getenv('TYPO3_PATH_COMPOSER_ROOT')) {
return sprintf('%s/%s/', getenv('TYPO3_PATH_APP'), 'vendor/typo3/cms-cli');
}

// copied and modified from @see
// https://github.com/TYPO3/typo3/blob/8a9c80b9d85ef986f5f369f1744fc26a6b607dda/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php#L402
$composerJsonFile = getenv('TYPO3_PATH_COMPOSER_ROOT') . '/composer.json';
Expand Down
19 changes: 15 additions & 4 deletions Tests/Functional/Service/ProcessServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
*/

use AOE\Crawler\Service\ProcessService;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

/**
* @package AOE\Crawler\Tests\Unit\Domain\Model
*/
class ProcessServiceTest extends FunctionalTestCase
{
protected array $testExtensionsToLoad = ['typo3conf/ext/crawler'];
Expand All @@ -42,7 +40,7 @@ protected function setUp(): void
$this->subject = GeneralUtility::makeInstance(ProcessService::class);
}

#[\PHPUnit\Framework\Attributes\Test]
#[Test]
public function getCrawlerCliPathReturnsString(): void
{
// Check with phpPath set
Expand All @@ -62,4 +60,17 @@ public function getCrawlerCliPathReturnsString(): void
];
self::assertStringContainsString('php', $this->subject->getCrawlerCliPath());
}

#[Test]
public function getCrawlerCliPathContainsTYPO3BinaryRespectivelyWithOutComposer(): void
{
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['crawler'] = [
'phpBinary' => 'php',

];

// Unassign TYPO3_PATH_COMPOSER_ROOT
putenv('TYPO3_PATH_COMPOSER_ROOT');
self::assertStringContainsString('vendor/typo3/cms-cli/typo3', $this->subject->getCrawlerCliPath());
}
}

0 comments on commit 8eff816

Please sign in to comment.