Skip to content

Commit

Permalink
Cast contentId and locationId command arguments to integer (#2582)
Browse files Browse the repository at this point in the history
* BrowseLocationsCommand.php: Cast locationId arg to int

PHP Fatal error:  Uncaught TypeError: Ibexa\Core\Repository\SiteAccessAware\LocationService::loadLocation(): Argument #1 ($locationId) must be of type int, string given, called in /var/www/html/src/Command/BrowseLocationsCommand.php on line 45 and defined in /var/www/html/vendor/ibexa/core/src/lib/Repository/SiteAccessAware/LocationService.php:53

* code_samples/: cast location and content ID arguments to int

(cherry picked from commit 8a760dd)
  • Loading branch information
adriendupuis committed Dec 17, 2024
1 parent 4051144 commit 6596669
Show file tree
Hide file tree
Showing 17 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$user = $this->userService->loadUserByLogin('admin');
$this->permissionResolver->setCurrentUserReference($user);

$parentLocationId = $input->getArgument('parentLocationId');
$contentId = $input->getArgument('contentId');
$parentLocationId = (int) $input->getArgument('parentLocationId');
$contentId = (int) $input->getArgument('contentId');

$locationCreateStruct = $this->locationService->newLocationCreateStruct($parentLocationId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$locationId = $input->getArgument('locationId');
$locationId = (int) $input->getArgument('locationId');
$location = $this->locationService->loadLocation($locationId);

$this->bookmarkService->createBookmark($location);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private function browseLocation(Location $location, OutputInterface $output, int

protected function execute(InputInterface $input, OutputInterface $output): int
{
$locationId = $input->getArgument('locationId');
$locationId = (int) $input->getArgument('locationId');

$location = $this->locationService->loadLocation($locationId);
$this->browseLocation($location, $output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$user = $this->userService->loadUserByLogin('admin');
$this->permissionResolver->setCurrentUserReference($user);

$parentLocationId = $input->getArgument('parentLocationId');
$parentLocationId = (int) $input->getArgument('parentLocationId');
$contentTypeIdentifier = $input->getArgument('contentType');
$name = $input->getArgument('name');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$user = $this->userService->loadUserByLogin('admin');
$this->permissionResolver->setCurrentUserReference($user);

$locationId = $input->getArgument('locationId');
$locationId = (int) $input->getArgument('locationId');

$location = $this->locationService->loadLocation($locationId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output)
{
$locationId = $input->getArgument('locationId');
$locationId = (int) $input->getArgument('locationId');
$contentTypeIdentifier = $input->getArgument('contentTypeIdentifier');
$text = $input->getArgument('text');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$contentTypeId = $input->getArgument('contentTypeId');
$contentTypeId = (int) $input->getArgument('contentTypeId');

$query = new Query();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$user = $this->userService->loadUserByLogin('admin');
$this->permissionResolver->setCurrentUserReference($user);

$locationId = $input->getArgument('location_id');
$locationId = (int) $input->getArgument('location_id');

$location = $this->locationService->loadLocation($locationId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$user = $this->userService->loadUserByLogin('admin');
$this->permissionResolver->setCurrentUserReference($user);

$locationId = $input->getArgument('locationId');
$targetLocationId = $input->getArgument('targetLocationId');
$locationId = (int) $input->getArgument('locationId');
$targetLocationId = (int) $input->getArgument('targetLocationId');

$sourceLocation = $this->locationService->loadLocation($locationId);
$targetLocation = $this->locationService->loadLocation($targetLocationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

if ($input->getArgument('contentID')) {
$contentId = $input->getArgument('contentID');
$contentId = (int) $input->getArgument('contentID');
$objectStateToAssign = $objectStateIdentifierList[0];
$contentInfo = $this->contentService->loadContentInfo($contentId);
$objectStateGroup = $this->objectStateService->loadObjectStateGroupByIdentifier($objectStateGroupIdentifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$sectionName = $input->getArgument('sectionName');
$sectionIdentifier = $input->getArgument('sectionIdentifier');
$contentId = $input->getArgument('contentId');
$contentId = (int) $input->getArgument('contentId');

$sectionCreateStruct = $this->sectionService->newSectionCreateStruct();
$sectionCreateStruct->name = $sectionName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$user = $this->userService->loadUserByLogin('admin');
$this->permissionResolver->setCurrentUserReference($user);

$contentId = $input->getArgument('contentId');
$locationId = $input->getArgument('locationId');
$contentId = (int) $input->getArgument('contentId');
$locationId = (int) $input->getArgument('locationId');

$contentInfo = $this->contentService->loadContentInfo($contentId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$user = $this->userService->loadUserByLogin('admin');
$this->permissionResolver->setCurrentUserReference($user);

$contentId = $input->getArgument('contentId');
$contentId = (int) $input->getArgument('contentId');
$language = $input->getArgument('language');
$newName = $input->getArgument('nameInNewLanguage');
$secondaryLanguage = $input->getArgument('secondaryLanguage');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$user = $this->userService->loadUserByLogin('admin');
$this->permissionResolver->setCurrentUserReference($user);

$locationId = $input->getArgument('locationId');
$locationId = (int) $input->getArgument('locationId');
if ($input->getArgument('newParentId')) {
$newParentId = $input->getArgument('newParentId');
$newParentId = (int) $input->getArgument('newParentId');
}

$location = $this->locationService->loadLocation($locationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$user = $this->userService->loadUserByLogin('admin');
$this->permissionResolver->setCurrentUserReference($user);

$contentId = $input->getArgument('contentId');
$contentId = (int) $input->getArgument('contentId');
$newName = $input->getArgument('newName');

$contentInfo = $this->contentService->loadContentInfo($contentId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$contentId = $input->getArgument('contentId');
$contentId = (int) $input->getArgument('contentId');

$content = $this->contentService->loadContent($contentId);
$contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$contentId = $input->getArgument('contentId');
$contentId = (int) $input->getArgument('contentId');
$workflowName = $input->getArgument('workflowName');
$transitionName = $input->getArgument('transitionName');

Expand Down

0 comments on commit 6596669

Please sign in to comment.