Closed dylan-ramos closed 4 weeks ago
This was resolved on latest version by clearing cache on every module action. Sadly, nothing that you can do in 1.7.8.
If you want, you can wipe cache when upgrading the module.
Good evening, thank you for your response. Indeed, using the services:
This seems to solve the problem by adding the new services to the container. So I think I will add these few lines in the update files to avoid any unpleasant surprises 😊
<?php
declare(strict_types=1);
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* @param $module
*
* @return bool
*/
function upgrade_module_2_0_0($module): bool
{
$r = true;
try {
/** @var \PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerChain $cacheClearerChain */
$cacheClearerChain = $module->get('prestashop.core.cache.clearer.cache_clearer_chain');
$cacheClearerChain->clear();
/** @var \PrestaShop\PrestaShop\Adapter\Cache\Clearer\SymfonyCacheClearer $symfonyClearerChain */
$symfonyClearerChain = $module->get('prestashop.adapter.cache.clearer.symfony_cache_clearer');
$symfonyClearerChain->clear();
} catch (Throwable $e) {
$r = false;
PrestaShopLogger::addLog('mymodule - upgrade 2.0.0 - ' . __LINE__ . ' - Throwable #' . $e->getCode() . ' - ' . $e->getMessage() . '.', 3);
}
return (bool)$r;
}
/** @var \PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerChain $cacheClearerChain */
$cacheClearerChain = $module->get('prestashop.core.cache.clearer.cache_clearer_chain');
$cacheClearerChain->clear();
// OR
/** @var \PrestaShop\PrestaShop\Adapter\Cache\Clearer\SymfonyCacheClearer $symfonyClearerChain */
$symfonyClearerChain = $module->get('prestashop.adapter.cache.clearer.symfony_cache_clearer');
$symfonyClearerChain->clear();
Thank you again for your response.
Prerequisites
Describe the bug and add attachments
Hello, I am encountering an issue with the declaration of services in modules for PrestaShop v1.7.8. When I add a service to an already installed module, I have to uninstall and then reinstall (reset) the module for the new services to be recognized. Is there a way to force the update of the list of services recognized by PrestaShop (directly in the module code or via CLI), or is this a bug?
Bonjour, Je rencontre un problème dans la déclaration des services dans les modules pour PrestaShop v1.7.8. Lorsque je rajoute un service dans un module déjà installé, je suis obligé de désinstaller puis réinstaller (reset) le module afin que les nouveaux services soient pris en comptes. Y a-t-il la possibilité de forcer l’actualisation de la liste des service pris en compte par PrestaShop (directement dans le code du module ou en cli) ou est-ce un bug ?
Expected behavior
I would like to know if there is a way to refresh the list of services for an existing module without having to reset it (I also feel that the command "cache:clear --env=dev|prod" does not always solve the problem). Thank you.
J’aurais voulu savoir s’il y a une manière d’actualiser la liste des services pour un modules déjà existant sans avoir à le reset (j’ai l’impression aussi que la commande « cache:clear –env=dev|prod » ne règle pas toujours le problème. En vous remerciant
Steps to reproduce
For example: Version 1 of the module
mymodule/config/services.yml
If I want to update the module as follows:
mymodule/config/services.yml
While creating an upgrade file, for example:
mymodule/upgrade/upgrade-2.0.0.php
Then the new services will not be recognized by PrestaShop (services suffixed with "new").
PrestaShop version(s) where the bug happened
1.7.8.11
PHP version(s) where the bug happened
7.2.34
If your bug is related to a module, specify its name and its version
No response
Your company or customer's name goes here (if applicable).
No response