Skip to content

Add fallback to curl when allow_url_open is disabled; error if curl not available.#1608

Open
instancezero wants to merge 10 commits intoPrestaShop:devfrom
instancezero:dev
Open

Add fallback to curl when allow_url_open is disabled; error if curl not available.#1608
instancezero wants to merge 10 commits intoPrestaShop:devfrom
instancezero:dev

Conversation

@instancezero
Copy link

Questions Answers
Description? Fallback to curl when retrieving update list; detect when curl is also missing.
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes #1562
Sponsor company Abivia Inc. @abivia
How to test? Run update assistant when allow_url_fopen is off, verify update list is retrieved (I have tested this on a live system but haven't rebuilt a PHP with no curl, just handling the edge case here.)

@Quetzacoalt91
Copy link
Member

Thanks @instancezero, would it be possible to export this code in a dedicated method?
There is at least two occurrences from where we could enjoy the change: https://github.com/PrestaShop/autoupgrade/pull/1602/changes

The change could be in classes/Services/DownloadService.php next to the existing download() method.

@instancezero
Copy link
Author

Thanks @instancezero, would it be possible to export this code in a dedicated method? There is at least two occurrences from where we could enjoy the change: https://github.com/PrestaShop/autoupgrade/pull/1602/changes

The change could be in classes/Services/DownloadService.php next to the existing download() method.

It is possible. Can you suggest a method name?

Another option would be to make the $destinationPath argument nullable, change the return type to ?string (and then string|void when minimum PHP is raised to 8.3) and have the download() method return the string when no destination is provided.

…l not allowed; have DistributionApiService::getApiEndpoint use this method. Resolves issue PrestaShop#1608.
@Quetzacoalt91
Copy link
Member

It is possible. Can you suggest a method name?

Another option would be to make the $destinationPath argument nullable, change the return type to ?string (and then string|void when minimum PHP is raised to 8.3) and have the download() method return the string when no destination is provided.

We can use something like "fetchContents" or "getContents" to distinguish them from the method download() that stores on the filesystem.
I wouldn't modify the existing method, because it handle file contents as streams, alowing us to download the module to download huge amount of data without using too much memory and in consequence not reaching the memory limit exception.

@instancezero
Copy link
Author

I thought about this some more and came to the same conclusion about modifying download().

I also neglected to mention that the latest commit implements fetch() as a static method. Instantiating the class would require passing a Translator and a Logger, and the translator requires a base path, all of which seems like unnecessary overhead to me.

…date DistributionApiService::getApiEndpoint() to catch the exception and throw a DistributionApiException. Add tests. Re issue PrestaShop#1608.
…date DistributionApiService::getApiEndpoint() to catch the exception and throw a DistributionApiException. Add tests. Re issue PrestaShop#1608.
…date DistributionApiService::getApiEndpoint() to catch the exception and throw a DistributionApiException. Add tests. Re issue PrestaShop#1608.
@Quetzacoalt91
Copy link
Member

Excellent, if you can rebase your branch to solve the conflict, we should be good to go

@instancezero
Copy link
Author

That should do it...

Quetzacoalt91
Quetzacoalt91 previously approved these changes Jan 30, 2026
Copy link
Member

@Quetzacoalt91 Quetzacoalt91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much.

@github-project-automation github-project-automation bot moved this to Ready for review in PR Dashboard Jan 30, 2026
@AureRita
Copy link
Contributor

AureRita commented Feb 3, 2026

Hi @instancezero

Thank you for your PR, unfortunately, this one is still in conflict. Even without this conflict, I was able to test the PR and we get a 500 error even when we have allow_url_fopen = On, as you can see :

Capture.video.du.2026-02-03.12-11-54.mp4

You can see that all CI is red because of this issue

Waiting for feedback

@instancezero
Copy link
Author

I'll take a look. The issue is the change to the constructor, which is breaking other parts of the code.

Quetzacoalt91
Quetzacoalt91 previously approved these changes Feb 10, 2026
@AureRita AureRita self-assigned this Feb 10, 2026
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

HTTP 500 on update Assistant when allow_url_fopen is off

4 participants