Skip to content

Commit

Permalink
Merge pull request #755 from PrestaShopCorp/fix/parse_str
Browse files Browse the repository at this point in the history
🐛 Try to fix parse_str warning
  • Loading branch information
intraordinaire authored Apr 25, 2024
2 parents 4ee5aea + 1d206fe commit 10bc283
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/Api/Service/ModuleTransitionExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,8 @@ private function generateTokenizedModuleActionUrl($url): string
$composedUrl .= $baseUrl;

$queryParams = [];
if (isset($components['query'])) {
$query = $components['query'];

parse_str($query, $queryParams);
if (is_array($components) && isset($components['query']) && is_string($components['query'])) {
parse_str($components['query'], $queryParams);
}

if (!isset($queryParams['_token'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Module/SourceRetriever/AddonsUrlSourceRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private function assertSourceHasBeenChecked($source): void
private function computeAuthentication(string $source): array
{
$url_parts = parse_url($source);
if (isset($url_parts['query'])) {
if (is_array($url_parts) && isset($url_parts['query']) && is_string($url_parts['query'])) {
parse_str($url_parts['query'], $params);
} else {
$params = [];
Expand Down
8 changes: 7 additions & 1 deletion src/Traits/Hooks/UseActionListModules.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function hookActionListModules(): array
}
} catch (Exception $exception) {
ErrorHelper::reportError($exception);

return [];
}
$filters = $filtersFactory->create();
Expand All @@ -85,7 +86,11 @@ public function hookActionListModules(): array

$catalogUrl = $router->generate('admin_mbo_catalog_module', []);
$catalogUrlParts = parse_url($catalogUrl);
parse_str($catalogUrlParts['query'], $catalogUrlParams);
$catalogUrlParams = [];

if (is_array($catalogUrlParts) && isset($catalogUrlParts['query']) && is_string($catalogUrlParts['query'])) {
parse_str($catalogUrlParts['query'], $catalogUrlParams);
}

/**
* @var ModuleInterface $module
Expand Down Expand Up @@ -137,6 +142,7 @@ private function getAdditionalDescription(string $moduleUrl, string $moduleName)
}
} catch (Exception $exception) {
ErrorHelper::reportError($exception);

return '';
}

Expand Down

0 comments on commit 10bc283

Please sign in to comment.