Remove files deleted in 2.1.0 during the module upgrade - #342
Merged
TLabutis merged 1 commit intoJul 29, 2026
Merged
Conversation
A ZIP upgrade overwrites files but never removes the ones a new version dropped, so all 46 files deleted in 2.1.0 stayed on disk and stayed reachable: the leftover admin controller was re-registered as a tab on the next module reset, and the leftover iframe front controllers kept answering, one of them still reaching the checkout processor with the payment method taken from the request. The upgrade script now unlinks an explicit list of those 46 paths, removes the directories that become empty, drops the obsolete SAFERPAY_HOSTED_FIELDS_TEMPLATE setting and clears the Smarty cache. The list is explicit rather than directory based because views/js/front/hosted-templates/ still holds the live hosted_fields.js.
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A PrestaShop ZIP upgrade overwrites files but never removes the ones a new version dropped. 2.1.0 deletes 46 files, so on every upgraded shop all 46 stay on disk and stay reachable, while a freshly installed shop does not have them.
Two consequences, both observed on a shop that genuinely came through the 2.0.3 -> 2.1.0 ZIP upgrade:
controllers/admin/AdminSaferPayOfficialFieldsController.phpsurvives, and PrestaShop'sModuleTabRegister::addUndeclaredTabs()registers a tab for any*Controller.phpincontrollers/admin/. Pressing Reset on the module brings the obsolete Saferpay Fields tab back. Opening it is a fatal, because the controller readsSaferPayConfig::HOSTED_FIELDS_TEMPLATE, a constant removed in 2.1.0:iframe.php,hostedIframe.php,successIFrame.php,failIFrame.php). Module front controllers dispatch on file presence, not on a DB row, so all four stay routable.hostedIframe.phpandsuccessIFrame.phpfatal on removed constants.iframe.phpis the real problem: it still reachesCheckoutProcessorwith the payment method taken from a request parameter, an entry point that exists only on upgraded shops and is no longer part of any tested flow.Only an upgrade script can fix this, since a ZIP cannot delete.
Change
upgrade_module_2_1_0()gains three steps next to the existing tab cleanup:SAFERPAY_HOSTED_FIELDS_TEMPLATEsetting, which nothing in 2.1.0 reads.tplis servedThe list is explicit rather than directory based on purpose.
views/js/front/hosted-templates/still holdshosted_fields.js, which live 2.1.0 code loads fromsrc/Presentation/Loader/PaymentFormAssetLoader.php:146, and four of its siblings in that directory are among the removed files. Same situation inviews/css/front/andviews/img/. A directory level delete would break the payment form on every upgraded shop.Testing
On the upgraded shop (PS 9.1.4 / PHP 8.5, 7 existing Saferpay orders, one captured and refunded in three parts). Captured a render baseline, deleted the 46 files, cleared caches, re-ran the same probe. Before and after are identical:
At HTTP level only the intended endpoints change:
On the script itself. Reproduced the ZIP upgrade on disk (2.0.3 tree with the 2.1.0 ZIP copied over it, 1403 files), then ran
upgrade_module_2_1_0()against it:An upgraded shop ends up structurally indistinguishable from a fresh install. Idempotent, verified by running it twice more with no warnings or notices under
E_ALL.hosted_fields.jsand the module root are untouched.php -landphp-cs-fixer --dry-runclean. phpstan does not scanupgrade/.Notes for the reviewer
PaymentType::HOSTED_IFRAME,PaymentTypeProviderandcontrollers/front/return.php:115all still ship in 2.1.0. Only the entry point files are gone, not the handling of the stored value.@unlink, so a file the web user cannot delete is skipped and the upgrade still succeeds. Failing the upgrade over a leftover file would roll the version back, which is worse. The tradeoff is that on a shop with locked down file permissions the orphans survive and this fix silently does nothing.