Skip to content

Commit 8a760dd

Browse files
authored
Cast contentId and locationId command arguments to integer (#2582)
* 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
1 parent 02f68a1 commit 8a760dd

17 files changed

+21
-21
lines changed

code_samples/api/public_php_api/src/Command/AddLocationToContentCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4545
$user = $this->userService->loadUserByLogin('admin');
4646
$this->permissionResolver->setCurrentUserReference($user);
4747

48-
$parentLocationId = $input->getArgument('parentLocationId');
49-
$contentId = $input->getArgument('contentId');
48+
$parentLocationId = (int) $input->getArgument('parentLocationId');
49+
$contentId = (int) $input->getArgument('contentId');
5050

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

code_samples/api/public_php_api/src/Command/BookmarkCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function configure(): void
3434

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

4040
$this->bookmarkService->createBookmark($location);

code_samples/api/public_php_api/src/Command/BrowseLocationsCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private function browseLocation(Location $location, OutputInterface $output, int
4040

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

4545
$location = $this->locationService->loadLocation($locationId);
4646
$this->browseLocation($location, $output);

code_samples/api/public_php_api/src/Command/CreateContentCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5151
$user = $this->userService->loadUserByLogin('admin');
5252
$this->permissionResolver->setCurrentUserReference($user);
5353

54-
$parentLocationId = $input->getArgument('parentLocationId');
54+
$parentLocationId = (int) $input->getArgument('parentLocationId');
5555
$contentTypeIdentifier = $input->getArgument('contentType');
5656
$name = $input->getArgument('name');
5757

code_samples/api/public_php_api/src/Command/DeleteContentCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
3838
$user = $this->userService->loadUserByLogin('admin');
3939
$this->permissionResolver->setCurrentUserReference($user);
4040

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

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

code_samples/api/public_php_api/src/Command/FindComplexCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected function configure(): void
3838

3939
protected function execute(InputInterface $input, OutputInterface $output)
4040
{
41-
$locationId = $input->getArgument('locationId');
41+
$locationId = (int) $input->getArgument('locationId');
4242
$contentTypeIdentifier = $input->getArgument('contentTypeIdentifier');
4343
$text = $input->getArgument('text');
4444

code_samples/api/public_php_api/src/Command/FindInTrashCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function configure(): void
3030

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

3535
$query = new Query();
3636

code_samples/api/public_php_api/src/Command/HideLocationCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4040
$user = $this->userService->loadUserByLogin('admin');
4141
$this->permissionResolver->setCurrentUserReference($user);
4242

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

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

code_samples/api/public_php_api/src/Command/MoveContentCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4141
$user = $this->userService->loadUserByLogin('admin');
4242
$this->permissionResolver->setCurrentUserReference($user);
4343

44-
$locationId = $input->getArgument('locationId');
45-
$targetLocationId = $input->getArgument('targetLocationId');
44+
$locationId = (int) $input->getArgument('locationId');
45+
$targetLocationId = (int) $input->getArgument('targetLocationId');
4646

4747
$sourceLocation = $this->locationService->loadLocation($locationId);
4848
$targetLocation = $this->locationService->loadLocation($targetLocationId);

code_samples/api/public_php_api/src/Command/ObjectStateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7373
}
7474

7575
if ($input->getArgument('contentID')) {
76-
$contentId = $input->getArgument('contentID');
76+
$contentId = (int) $input->getArgument('contentID');
7777
$objectStateToAssign = $objectStateIdentifierList[0];
7878
$contentInfo = $this->contentService->loadContentInfo($contentId);
7979
$objectStateGroup = $this->objectStateService->loadObjectStateGroupByIdentifier($objectStateGroupIdentifier);

code_samples/api/public_php_api/src/Command/SectionCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5454

5555
$sectionName = $input->getArgument('sectionName');
5656
$sectionIdentifier = $input->getArgument('sectionIdentifier');
57-
$contentId = $input->getArgument('contentId');
57+
$contentId = (int) $input->getArgument('contentId');
5858

5959
$sectionCreateStruct = $this->sectionService->newSectionCreateStruct();
6060
$sectionCreateStruct->name = $sectionName;

code_samples/api/public_php_api/src/Command/SetMainLocationCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4141
$user = $this->userService->loadUserByLogin('admin');
4242
$this->permissionResolver->setCurrentUserReference($user);
4343

44-
$contentId = $input->getArgument('contentId');
45-
$locationId = $input->getArgument('locationId');
44+
$contentId = (int) $input->getArgument('contentId');
45+
$locationId = (int) $input->getArgument('locationId');
4646

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

code_samples/api/public_php_api/src/Command/TranslateContentCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4343
$user = $this->userService->loadUserByLogin('admin');
4444
$this->permissionResolver->setCurrentUserReference($user);
4545

46-
$contentId = $input->getArgument('contentId');
46+
$contentId = (int) $input->getArgument('contentId');
4747
$language = $input->getArgument('language');
4848
$newName = $input->getArgument('nameInNewLanguage');
4949
$secondaryLanguage = $input->getArgument('secondaryLanguage');

code_samples/api/public_php_api/src/Command/TrashContentCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4545
$user = $this->userService->loadUserByLogin('admin');
4646
$this->permissionResolver->setCurrentUserReference($user);
4747

48-
$locationId = $input->getArgument('locationId');
48+
$locationId = (int) $input->getArgument('locationId');
4949
if ($input->getArgument('newParentId')) {
50-
$newParentId = $input->getArgument('newParentId');
50+
$newParentId = (int) $input->getArgument('newParentId');
5151
}
5252

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

code_samples/api/public_php_api/src/Command/UpdateContentCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4141
$user = $this->userService->loadUserByLogin('admin');
4242
$this->permissionResolver->setCurrentUserReference($user);
4343

44-
$contentId = $input->getArgument('contentId');
44+
$contentId = (int) $input->getArgument('contentId');
4545
$newName = $input->getArgument('newName');
4646

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

code_samples/api/public_php_api/src/Command/ViewContentCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected function configure(): void
3737

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

4242
$content = $this->contentService->loadContent($contentId);
4343
$contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);

code_samples/api/public_php_api/src/Command/WorkflowCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected function configure(): void
3939

4040
protected function execute(InputInterface $input, OutputInterface $output): int
4141
{
42-
$contentId = $input->getArgument('contentId');
42+
$contentId = (int) $input->getArgument('contentId');
4343
$workflowName = $input->getArgument('workflowName');
4444
$transitionName = $input->getArgument('transitionName');
4545

0 commit comments

Comments
 (0)