aide prestashop PhenixSuite Help
    • Catégories
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Recherche
    • S'inscrire
    • Se connecter

    Suite mise à jour vers 1.6.2.15

    Planifier Épinglé Verrouillé Déplacé Bugs & Améliorations
    6 Messages 2 Publieurs 963 Vues 2 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • mediacom87M Hors-ligne
      mediacom87
      dernière édition par

      Salut,

      J'ai simplement fait la mise à jour de version sans le moindre souci, sauf que tout de suite après, j'ai voulu me rendre dans les modules et voici ce que j'ai eu :

      [PrestaShop] Fatal error in module file :/home6/sc2mediacom/public_html/phenixsuite/modules/commentsalert/commentsalert.php:<br />Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given in /home6/sc2mediacom/public_html/phenixsuite/modules/commentsalert/commentsalert.php:53
      Stack trace:
      #0 [internal function]: CommentsAlert->__construct()
      #1 /home6/sc2mediacom/public_html/phenixsuite/Core/Foundation/IoC/Core_Foundation_IoC_Container.php(131): ReflectionClass->newInstance()
      #2 /home6/sc2mediacom/public_html/phenixsuite/Core/Foundation/IoC/Core_Foundation_IoC_Container.php(164): Core_Foundation_IoC_Container->makeInstanceFromClassName()
      #3 /home6/sc2mediacom/public_html/phenixsuite/Core/Foundation/IoC/Core_Foundation_IoC_Container.php(177): Core_Foundation_IoC_Container->doMake()
      #4 /home6/sc2mediacom/public_html/phenixsuite/Adapter/Adapter_ServiceLocator.php(52): Core_Foundation_IoC_Container->make()
      #5 /home6/sc2mediacom/public_html/phenixsuite/classes/module/Module.php(1331): Adapter_ServiceLocator::get()
      #6 /home6/sc2mediacom/public_html/phenixsuite/classes/module/Module.php(1295): ModuleCore::coreLoadModule()
      #7 /home6/sc2mediacom/public_html/phenixsuite/classes/controller/AdminController.php(4983): ModuleCore::getInstanceByName()
      #8 /home6/sc2mediacom/public_html/phenixsuite/classes/controller/AdminController.php(4879): AdminControllerCore->displayModuleOptions()
      #9 /home6/sc2mediacom/public_html/phenixsuite/controllers/admin/AdminModulesController.php(2059): AdminControllerCore->fillModuleData()
      #10 /home6/sc2mediacom/public_html/phenixsuite/classes/controller/Controller.php(204): AdminModulesControllerCore->initContent()
      #11 /home6/sc2mediacom/public_html/phenixsuite/classes/Dispatcher.php(405): ControllerCore->run()
      #12 /home6/sc2mediacom/public_html/phenixsuite/admin-phenix/index.php(79): DispatcherCore->dispatch()
      #13 {main}
        thrown
      

      Informations sur votre serveur Linux #1 SMP Tue Aug 9 14:38:15 UTC 2022 x86_64

      Version du logiciel serveur Apache

      Version de PHP 8.1.22

      Limite de mémoire 256M

      Temps d'exécution maximal (max_execution_time) 300

      Version de MySQL 10.6.15-MariaDB

      J'ai donc modifié le module commentsalert de la sorte :

              $this->waiting_approval = ProductComment::getByValidate() ? count(ProductComment::getByValidate()) : 0;
              $this->reported = ProductComment::getReportedComments() ? count(ProductComment::getReportedComments()) : 0;
      
      

      Prestatoolbox : https://www.prestatoolbox.fr
      Mediacom87 : https://www.mediacom87.fr

      Modules compatibles PhenixSuite : https://www.prestatoolbox.fr/7-modules-prestashop-addons-thirtybees#/compatible_phenixsuite-oui

      1 réponse Dernière réponse Répondre Citer 0
      • eoliaE Hors-ligne
        eolia
        dernière édition par eolia

        Bonjour,
        Quelle version du module productcomments ?
        La fonction appellée:

            public static function getByValidate($validate = 0, $deleted = false)
            {
                return Db::getInstance()->executeS('
                    SELECT pc.`id_product_comment`, pc.`id_product`, 
                        IF(c.id_customer, CONCAT(c.`firstname`, \' \',  c.`lastname`), pc.customer_name) customer_name, 
                        pc.`title`, pc.`content`, pc.`grade`, pc.`date_add`, pl.`name`
                    FROM `'._DB_PREFIX_.'product_comment` pc
                    LEFT JOIN `'._DB_PREFIX_.'customer` c 
                        ON(c.`id_customer` = pc.`id_customer`)
                    LEFT JOIN `'._DB_PREFIX_.'product_lang` pl 
                        ON(pl.`id_product` = pc.`id_product` 
                        AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').')
                    WHERE pc.`validate` = '.(int)$validate.'
                    ORDER BY pc.`date_add` DESC
                ');
            }
        

        Dans tous les cas ça renvoie un tableau (vide ou pas) sauf si le module n'est pas installé et que les tables n'existent pas.

        Je vais donc mettre à jour le module en modifiant le code ainsi:

        <?php
                
                /**
                
                 * 2022-2023 PhenixSuite®
                
                 *
                
                 * NOTICE OF LICENSE
                
                 *
                
                 * This source file is subject to the Open Software License (OSL 3.0)
                
                 * that is bundled with this package in the file LICENSE.txt.
                
                 * It is also available through the world-wide-web at this URL:
                
                 * http://opensource.org/licenses/osl-3.0.php
                
                 * If you did not receive a copy of the license and are unable to
                
                 * obtain it through the world-wide-web, please send an email
                
                 * to license@phenixsuite.com so we can send you a copy immediately.
                
                 *
                
                 * DISCLAIMER
                
                 *
                
                 * Do not edit or add to this file if you wish to upgrade PhenixSuite to newer
                
                 * versions in the future. If you wish to customize PhenixSuite for your
                
                 * needs please refer to https://phenixsuite.com for more information.
                
                 *
                
                 *  @author    PhenixSuite <contact@phenixsuite.com>
                
                 *  @copyright 2022-2023 PhenixSuite®
                
                 *  @license   https://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
                
                 */
                
                 
                
                if(!defined('_PS_VERSION_')) {
                
                    exit;
                
                }
                
                
                
                class CommentsAlert extends Module
                
                {
                
                    private $waiting_approval = 0;
                
                    private $reported = 0;
                
                    private $associated = false;
                
                    
                
                    public function __construct()
                
                    {
                
                        $this->name = 'commentsalert';
                
                        $this->tab = 'administration';
                
                        $this->version = '1.3';
                
                        $this->author = 'Eolia';
                
                        $this->need_instance = 0;
                
                        $this->ps_versions_compliancy = array('min' => '1.6', 'max' => '1.6.99.99');
                
                        $this->dependencies = array('productcomments');
                
                
                
                        parent::__construct();
                
                
                
                        $this->displayName = $this->l('Comments Alert');
                
                        $this->description = $this->l('Backoffice visual and sound alert for unapproved and reported comments.');
                
                        $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
                
                
                
                        if(Module::isInstalled('productcomments')) {
                
                            if(file_exists(_PS_ROOT_DIR_.'/modules/productcomments/ProductComment.php')) {
                
                                require_once(_PS_ROOT_DIR_.'/modules/productcomments/ProductComment.php');
                
                            }
                
                            $this->associated = true;
                
                            $this->waiting_approval = count(ProductComment::getByValidate(0, false));
                
                            $this->reported = count(ProductComment::getReportedComments());
                
                        }
                
                    }
                
                
                
                    public function install()
                
                    {
                
                        if(parent::install() == false
                
                            || !$this->registerHook('actionAdminControllerSetMedia')
                
                            || !$this->registerHook('displayBackOfficeTop')
                
                        ) {
                
                            return false;
                
                        }
                
                        Configuration::updateValue('COMMENTS_ALERT_LAST_AWAITING', 0);
                
                        Configuration::updateValue('COMMENTS_ALERT_LAST_REPORT', 0);
                
                
                
                        return true;
                
                    }
                
                
                
                    public function uninstall()
                
                    {
                
                        if(!parent::uninstall() 
                
                            || !$this->unregisterHook('actionAdminControllerSetMedia') 
                
                            || !$this->unregisterHook('displayBackOfficeTop')
                
                        ) {
                
                            return false;
                
                        }
                
                        Configuration::deleteByName('COMMENTS_ALERT_LAST_AWAITING');
                
                        Configuration::deleteByName('COMMENTS_ALERT_LAST_REPORT');
                
                
                
                        return true;
                
                    }
                
                
                
                    public function hookActionAdminControllerSetMedia()
                
                    {
                
                        if(!$this->associated) {
                
                            return;
                
                        }
                
                        $this->context->controller->addJs($this->_path.'views/js/commentsalert.js');
                
                        $this->context->controller->addCss($this->_path.'views/css/commentsalert.css');
                
                    }
                
                
                
                    public function hookDisplayBackOfficeTop($params)
                
                    {
                
                        if(!$this->associated) {
                
                            return;
                
                        }
                
                        if(Tools::getValue('action') == 'updateCommentsInfo' 
                
                            && Tools::getValue('ajax') == 1
                
                        ) {
                
                            $this->ajaxUpdateCommentsInfo();
                
                        }
                
                        else {
                
                            $this->context->smarty->assign(array(
                
                                'link' => $this->context->link,
                
                                'waiting_approval' => min(
                
                                    Configuration::get('COMMENTS_ALERT_LAST_AWAITING'), 
                
                                    $this->waiting_approval
                
                                ),
                
                                'reported' => min(
                
                                    Configuration::get('COMMENTS_ALERT_LAST_LAST_REPORT'), 
                
                                    $this->reported
                
                                )
                
                            ));
                
                
                
                            return $this->display(__FILE__, 'commentsalert.tpl');
                
                        }
                
                    }
                
                
                
                    public function ajaxUpdateCommentsInfo()
                
                    {
                
                        Configuration::updateValue('COMMENTS_ALERT_LAST_AWAITING', $this->waiting_approval);
                
                        Configuration::updateValue('COMMENTS_ALERT_LAST_REPORT', $this->reported);
                
                        die(Tools::jsonEncode(array(
                
                            'waiting_approval' => $this->waiting_approval,
                
                            'reported' => $this->reported
                
                        )));
                
                    }
                
                }

        Créateur de PhenixSuite. Pour plus d'infos : https://eoliashop.com

        1 réponse Dernière réponse Répondre Citer 0
        • mediacom87M Hors-ligne
          mediacom87
          dernière édition par

          Le module n'était pas installé, ce qui explique l'erreur, car même si tu as mis une dépendance, on se rend compte que cela ne prend pas en compte toutes les possibilités.

          Prestatoolbox : https://www.prestatoolbox.fr
          Mediacom87 : https://www.mediacom87.fr

          Modules compatibles PhenixSuite : https://www.prestatoolbox.fr/7-modules-prestashop-addons-thirtybees#/compatible_phenixsuite-oui

          1 réponse Dernière réponse Répondre Citer 0
          • eoliaE Hors-ligne
            eolia
            dernière édition par

            Avec le nouveau code la dépendance sera réelle.
            Il faut que je regarde comment ils ont codé le dependencies...

            Créateur de PhenixSuite. Pour plus d'infos : https://eoliashop.com

            1 réponse Dernière réponse Répondre Citer 0
            • mediacom87M Hors-ligne
              mediacom87
              dernière édition par

              Le contrôle ne doit se faire que lors de l'installation à mon avis.

              Prestatoolbox : https://www.prestatoolbox.fr
              Mediacom87 : https://www.mediacom87.fr

              Modules compatibles PhenixSuite : https://www.prestatoolbox.fr/7-modules-prestashop-addons-thirtybees#/compatible_phenixsuite-oui

              1 réponse Dernière réponse Répondre Citer 0
              • eoliaE Hors-ligne
                eolia
                dernière édition par

                Oui, mais cette partie n'est pas gérée lors de l'install/upgrade du CMS.
                Je viens d'ajouter un contrôle dans le constructeur de Module.php et si la dépendance n'est pas installée, le module sera lui-même désinstallé.

                Créateur de PhenixSuite. Pour plus d'infos : https://eoliashop.com

                1 réponse Dernière réponse Répondre Citer 0
                • Premier message
                  Dernier message
                bug
                26 sujets
                1.6
                24 sujets
                front-office
                11 sujets
                1.5
                8 sujets
                1.7
                5 sujets
                système
                4 sujets
                administration
                3 sujets
                hack
                3 sujets
                module
                3 sujets
                performance
                3 sujets
                smtp
                3 sujets
                transporteurs
                3 sujets
                dashboard
                2 sujets
                https
                2 sujets
                paypal
                2 sujets
                promotions
                2 sujets