Jump to content
thirty bees forum
  • 0

Having issue with a module that used to work under 1.6.1


Question

Posted

Hello all.  I am having an issue with a module that used to work under 1.6.1.  When I install the module, it gives a 500 error.  The details of the error is below.  It seems to cascade through quite a bit.  Not sure if it is fixable or not.  Any advice would be appreciated.  Developper does not want to do anything because it is TB.  What the module does is help manage tags and unify them across languages.

Here is the initial error that cause the 500 error call - if you go back, though, the module is installed and seems to work but it no longer imports the existing tags in the main language.

Decoded exception

Too few arguments to function Tagm::insertTagM(), 0 passed in /home/zbookstore/public_html/modules/patagsmanagement/classes/Tagm.php on line 384 and exactly 1 expected

in file modules/patagsmanagement/classes/Tagm.php at line 476
 
If you open up all the stack traces, this is what we get:
 

Source file: modules/patagsmanagement/classes/Tagm.php

457:
458:        if (Db::getInstance()->execute($q)) {
459:            //elimino los names de tags
460:            $q = "DELETE FROM `"._DB_PREFIX_."tag` WHERE name in('".$strTagsComplete."')";
461:            Db::getInstance()->execute($q);
462:            $q = "DELETE FROM `"._DB_PREFIX_."tagm` WHERE id_tagm = ".(int)$idtagm;
463:            Db::getInstance()->execute($q);
464:            //elimino de las relaciones de agrupacion
465:            return true;
466:        }
467:        return false;
468:    }
469:
470:    public static function updateTagM($idtagm, $public)
471:    {
472:        $q = 'UPDATE `'._DB_PREFIX_.'tagm` set public = '.(int)$public.' WHERE id_tagm ='.(int)$idtagm;
473:        Db::getInstance()->execute($q);
474:    }
475:
476:    public static function insertTagM($public)
477:    {
478:        $q = 'INSERT INTO `'._DB_PREFIX_.'tagm` (fecha,public) VALUES (now(),'.(int)$public.')';
479:
480:        if (Db::getInstance()->execute($q)) {
481:            return Db::getInstance()->Insert_ID();
482:        }
483:
484:        return null;
485:    }
486:}

Stack trace

1. modules/patagsmanagement/classes/Tagm.php:384 source Tagm::insertTagM()
365:
366:        return $saveOk;
367:    }
368:
369:    public static function createTagForLang()
370:    {
371:        $sql = 'SELECT id_lang , count(*) as cant from '._DB_PREFIX_
372:            .'tag GROUP BY id_lang ORDER BY cant DESC LIMIT 0,1';
373:        $tagsConteo = Db::getInstance()->executeS($sql);
374:
375:        if (isset($tagsConteo) && $tagsConteo[0]) {
376:            $lang_id_tags = $tagsConteo[0]['id_lang'];
377:
378:            if ($tagsConteo[0]['cant']>0) {
379:                //creo todos los tags para ese idioma
380:                $sql = 'SELECT * from '._DB_PREFIX_.'tag WHERE id_lang = '.(int)$lang_id_tags;
381:                $tagsAdd = Db::getInstance()->executeS($sql);
382:
383:                foreach ($tagsAdd as $t) {
384:                    $id_tagm = Tagm::insertTagM();
385:
386:                    $dataTagmTag = array();
387:                    $dataTagmTag['id_tagm'] = $id_tagm;
388:                    $dataTagmTag['id_tag'] = $t['name'];
389:                    $dataTagmTag['id_lang'] = $t['id_lang'];
390:
391:                    Tagm::insertTagmTag($dataTagmTag);
392:                }
393:            }
394:        }
2. modules/patagsmanagement/patagsmanagement.php:69 source Tagm::createTagForLang()
50:        }
51:
52:        // Execute module install SQL statements
53:        $sql_file = dirname(__FILE__).'/install/install.sql';
54:        if (!$this->loadSQLFile($sql_file)) {
55:            return false;
56:        }
57:
58:        // Install admin tab
59:        $langnames = array();
60:        $langnames['es'] = 'Gestión avanzada de etiquetas';
61:        $langnames['fr'] = 'Gestion avancée et affichage';
62:        $langnames['en'] = 'Advanced Tags Management';
63:
64:        if (!$this->installTab('AdminCatalog', 'AdminPATagsManagement', 'Advanced Tags Management', $langnames)) {
65:            return false;
66:        }
67:
68:        //tomo los tags existentes en el idioma que mas tenga
69:        Tagm::createTagForLang();
70:
71:        // Register hooks
72:        if (!$this->registerHook('displayRightColumnProduct')
73:        ) {
74:            return false;
75:        }
76:
77:        //Create the folder for imgs
78:        $dir = _PS_ROOT_DIR_.'/img/tagm';
79:        mkdir($dir, 0777, true);
3. controllers/admin/AdminModulesController.php:1653 source PATagsManagement->install()
1634:                            }
1635:                        }
1636:                        //retrocompatibility
1637:                        if (Tools::getValue('controller') != '') {
1638:                            $_POST['tab'] = Tools::safeOutput(Tools::getValue('controller'));
1639:                        }
1640:                        $echo = '';
1641:                        if ($key != 'update' && $key != 'updateAll' && $key != 'checkAndUpdate' && $key != 'delete') {
1642:                            // We check if method of module exists
1643:                            if (!method_exists($module, $method)) {
1644:                                throw new PrestaShopException(sprintf('Method %s of module cannot be found', $method));
1645:                            }
1646:                            if ($key == 'uninstall' && !Module::getPermissionStatic($module->id, 'uninstall')) {
1647:                                $this->errors[] = Tools::displayError('You do not have permission to uninstall this module.');
1648:                            }
1649:                            if (count($this->errors)) {
1650:                                continue;
1651:                            }
1652:                            // Get the return value of current method
1653:                            $echo = $module->{$method}();
1654:                            // After a successful install of a single module that has a configuration method, to the configuration page
1655:                            if ($key == 'install' && $echo === true && strpos(Tools::getValue('install'), '|') === false && method_exists($module, 'getContent')) {
1656:                                Tools::redirectAdmin(static::$currentIndex.'&token='.$this->token.'&configure='.$module->name.'&conf=12');
1657:                            }
1658:                        }
1659:                        // If the method called is "configure" (getContent method), we show the html code of configure page
1660:                        if ($key == 'configure' && Module::isInstalled($module->name)) {
1661:                            $this->bootstrap = (isset($module->bootstrap) && $module->bootstrap);
1662:                            if (isset($module->multishop_context)) {
1663:                                $this->multishop_context = $module->multishop_context;
4. controllers/admin/AdminModulesController.php:1516 source AdminModulesControllerCore->postProcessCallback()
1497:        if (Tools::getValue('redirect') == 'config' && Tools::getValue('module_name') != '' && Module::isInstalled(pSQL(Tools::getValue('module_name')))) {
1498:            Tools::redirectAdmin('index.php?controller=adminmodules&configure='.Tools::getValue('module_name').'&token='.Tools::getValue('token').'&module_name='.Tools::getValue('module_name'));
1499:        }
1500:
1501:        // Execute filter or callback methods
1502:        $filterMethods = ['filterModules', 'resetFilterModules', 'filterCategory', 'unfilterCategory'];
1503:        $callbackMethods = ['reset', 'download', 'enable', 'delete', 'enable_device', 'disable_device'];
1504:        $postProcessMethodsList = array_merge((array) $filterMethods, (array) $callbackMethods);
1505:        foreach ($postProcessMethodsList as $ppm) {
1506:            if (Tools::isSubmit($ppm)) {
1507:                $ppm = 'postProcess'.ucfirst($ppm);
1508:                if (method_exists($this, $ppm)) {
1509:                    $ppmReturn = $this->$ppm();
1510:                }
1511:            }
1512:        }
1513:
1514:        // Call appropriate module callback
1515:        if (!isset($ppmReturn)) {
1516:            $this->postProcessCallback();
1517:        }
1518:
1519:        if ($back = Tools::getValue('back')) {
1520:            Tools::redirectAdmin($back);
1521:        }
1522:    }
1523:
1524:    /**
1525:     * @return void
1526:     *
5. override/controllers/admin/AdminModulesController.php:22 source AdminModulesControllerCore->postProcess()
3: * Ce module permet de raccourcir les urls catégorie et page cms et catégorie de produit et produit
4: *
5: * @author    Pliciweb Solutions<[email protected]>
6: * @copyright 2007-2015 PrestaShop SA
7: * @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
8: */
9:class AdminModulesController extends AdminModulesControllerCore
10:{
11:    /**
12:     * permet de lancer un build a la page du module
13:     * pour recréer la chaine
14:     */
15:    /*
16:    * module: plicimultioverride
17:    * date: 2019-08-09 14:02:59
18:    * version: 1.0.7
19:    */
20:    public function postProcess()
21:    {
22:        $return = parent::postProcess();
23:        $module = Module::getInstanceByName('plicimultioverride');
24:        $module->multiOvrBuildAll();
25:        return $return;
26:    }
27:}
6. classes/controller/Controller.php:197 source AdminModulesController->postProcess()
178:        } else {
179:            $this->$property = $value;
180:        }
181:    }
182:
183:    /**
184:     * Starts the controller process
185:     *
186:     * @since   1.0.0
187:     * @version 1.0.0 Initial version
188:     */
189:    public function run()
190:    {
191:        $this->init();
192:        if ($this->checkAccess()) {
193:            if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) {
194:                $this->setMedia();
195:            }
196:
197:            $this->postProcess();
198:
199:            if (!empty($this->redirect_after)) {
200:                $this->redirect();
201:            }
202:
203:            if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) {
204:                $this->initHeader();
205:            }
206:
207:            if ($this->viewAccess()) {
7. classes/Dispatcher.php:852 source ControllerCore->run()
833:                    return;
834:                }
835:                break;
836:
837:            default:
838:                throw new PrestaShopException('Bad front controller chosen');
839:        }
840:
841:        // Instantiate controller
842:        try {
843:            // Loading controller
844:            $controller = Controller::getController($controllerClass);
845:
846:            // Execute hook dispatcher
847:            if (isset($paramsHookActionDispatcher)) {
848:                Hook::exec('actionDispatcher', $paramsHookActionDispatcher);
849:            }
850:
851:            // Running controller
852:            $controller->run();
853:        } catch (PrestaShopException $e) {
854:            $e->displayMessage();
855:        }
856:    }
857:
858:    /**
859:     * Retrieve the controller from url or request uri if routes are activated
860:     *
861:     * @param int|null $idShop
862:     *
8. override/classes/Dispatcher.php:36 source DispatcherCore->dispatch()
17: *  @author ETS-Soft <[email protected]>
18: *  @copyright  2007-2019 ETS-Soft
19: *  @license    Valid for 1 website (or project) for each purchase of license
20: *  International Registered Trademark & Property of ETS-Soft
21: */
22:class Dispatcher extends DispatcherCore
23:{
24:    /*
25:    * module: ets_superspeed
26:    * date: 2019-11-26 19:36:05
27:    * version: 1.0.8
28:    */
29:    public function dispatch() {
30:        require_once(dirname(__FILE__).'/../../modules/ets_superspeed/ets_superspeed.php');
31:        if($cache = Ets_superspeed::displayContentCache(true))
32:        {
33:            echo $cache;
34:            return true;
35:        }
36:        parent::dispatch();
37:    }
38:}
9. smtgitb9e0nbr7r0/index.php:63 source Dispatcher->dispatch()
44://small test to clear cache after upgrade
45:if (Configuration::get('PS_UPGRADE_CLEAR_CACHE')) {
46:    header('Cache-Control: max-age=0, must-revalidate');
47:    header('Expires: Mon, 06 Jun 1985 06:06:00 GMT+1');
48:    Configuration::updateValue('PS_UPGRADE_CLEAR_CACHE', 0);
49:}
50:
51:// For retrocompatibility with "tab" parameter
52:if (!isset($_GET['controller']) && isset($_GET['tab'])) {
53:    $_GET['controller'] = strtolower($_GET['tab']);
54:}
55:if (!isset($_POST['controller']) && isset($_POST['tab'])) {
56:    $_POST['controller'] = strtolower($_POST['tab']);
57:}
58:if (!isset($_REQUEST['controller']) && isset($_REQUEST['tab'])) {
59:    $_REQUEST['controller'] = strtolower($_REQUEST['tab']);
60:}
61:
62:// Prepare and trigger admin dispatcher
63:Dispatcher::getInstance()->dispatch();

If it can be fixed by myself, I am open to any and all suggestions. If it is a more complicated matter, I am willing to pay someone to help me fix it.

 

2 answers to this question

Recommended Posts

  • 0
Posted

This is a bug in the module that was always there. It would reproduce on prestashop 1.6 as well if you run it on php7. You should ask the developer to fix it -- make it php7.2 compliant.

You can also fix it yourself by changing the signature of the method to 

public static function insertTagM($public=false)

 

  • Like 1
  • 0
Posted
9 minutes ago, datakick said:

This is a bug in the module that was always there. It would reproduce on prestashop 1.6 as well if you run it on php7. You should ask the developer to fix it -- make it php7.2 compliant.

You can also fix it yourself by changing the signature of the method to 


public static function insertTagM($public=false)

 

It's true that I was running PS under 5.6 at the time...  Thanks for the pointer.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...