Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

movieseals

Issue with a third party module

Recommended Posts

I have a module that sometimes works well and sometimes crashes with a 500 error - it appears to be smarty related issues related to caches specific to some modules such as @datakick revvs module and a few others.  Manually clearing the cache, ie going into the cache folder and flusing everything in both cache and compile folders sometimes brings it back to life, sometimes not.  I am using PHP 7.3.  As usual, any help or insight is appreciated.

Here is an example of the error I get, in this case caused by a file in the cache from the crossselling module - the lines causing the issues are highlited in red:

Decoded exception

SplFileInfo::getSize(): stat failed for /home/zbookstore/public_html/cache/smarty/cache/crossselling/productfooter/28825

in file modules/securitybooster/securitybooster.php at line 1676

Source file: modules/securitybooster/securitybooster.php

1657:        }
1658:        if ((file_exists($pathTemplate)) && (file_exists($indexTemplate))) {
1659:            return round(($bytestotal - filesize($indexTemplate)) / 1000, 0);
1660:        } elseif ((file_exists($pathTemplate)) && (!file_exists($indexTemplate))) {
1661:            return round($bytestotal / 1000, 0);
1662:        } else {
1663:            return $this->l('Folder is not found');
1664:        }
1665:    }
1666:    
1667:    protected function dirSizeSmartyCache($path)
1668:    {
1669:        $bytestotal = 0;
1670:        $path       = realpath(_PS_ROOT_DIR_ . '/cache/smarty');
1671:        $index      = _PS_ROOT_DIR_ . '/cache/smarty/index.php';
1672:        $index2     = _PS_ROOT_DIR_ . '/cache/smarty/compile/index.php';
1673:        $index3     = _PS_ROOT_DIR_ . '/cache/smarty/cache/index.php';
1674:        if ($path !== false) {
1675:            foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)) as $object) {
1676:                $bytestotal += $object->getSize();
1677:            }
1678:        }
1679:        return round(($bytestotal - filesize($index) - filesize($index2) - filesize($index3)) / 1000, 0);
1680:    }
1681:    
1682:    protected function dirSizeCacheFs($path)
1683:    {
1684:        $bytestotal   = 0;
1685:        $path         = realpath(_PS_ROOT_DIR_ . '/cache/cachefs');
1686:        $indexCacheFs = _PS_ROOT_DIR_ . '/cache/cachefs/index.php';

Stack trace

1. modules/securitybooster/securitybooster.php:1676 source SplFileInfo->getSize()
1657:        }
1658:        if ((file_exists($pathTemplate)) && (file_exists($indexTemplate))) {
1659:            return round(($bytestotal - filesize($indexTemplate)) / 1000, 0);
1660:        } elseif ((file_exists($pathTemplate)) && (!file_exists($indexTemplate))) {
1661:            return round($bytestotal / 1000, 0);
1662:        } else {
1663:            return $this->l('Folder is not found');
1664:        }
1665:    }
1666:    
1667:    protected function dirSizeSmartyCache($path)
1668:    {
1669:        $bytestotal = 0;
1670:        $path       = realpath(_PS_ROOT_DIR_ . '/cache/smarty');
1671:        $index      = _PS_ROOT_DIR_ . '/cache/smarty/index.php';
1672:        $index2     = _PS_ROOT_DIR_ . '/cache/smarty/compile/index.php';
1673:        $index3     = _PS_ROOT_DIR_ . '/cache/smarty/cache/index.php';
1674:        if ($path !== false) {
1675:            foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)) as $object) {
1676:                $bytestotal += $object->getSize();
1677:            }
1678:        }
1679:        return round(($bytestotal - filesize($index) - filesize($index2) - filesize($index3)) / 1000, 0);
1680:    }
1681:    
1682:    protected function dirSizeCacheFs($path)
1683:    {
1684:        $bytestotal   = 0;
1685:        $path         = realpath(_PS_ROOT_DIR_ . '/cache/cachefs');
1686:        $indexCacheFs = _PS_ROOT_DIR_ . '/cache/cachefs/index.php';
2. modules/securitybooster/securitybooster.php:286 source securityBooster->dirSizeSmartyCache(arguments)
267:            } else
268:                $conf = $this->l('Nothing that need to be cleaned');
269:            $output .= $this->displayConfirmation($conf);
270:            $this->getDataBaseSize();
271:        }
272:        if (((bool) Tools::isSubmit('submitCleanFullDb')) == true) {
273:            self::cleanConections('connections');
274:            $this->cleanDataBase1();
275:            $this->getDataBaseSize();
276:            $output .= $this->displayConfirmation($this->l('Data base has been fully cleaned.'));
277:        }
278:        if (((bool) Tools::isSubmit('submitFixPermisions')) == true) {
279:            $this->directoryPermisions();
280:            $output .= $this->displayConfirmation($this->l('755 permisions have been assigned to Prestashop directory.'));
281:        }
282:        
283:        $this->context->smarty->assign('module_dir', $this->_path);
284:        $this->context->smarty->assign('dirSizeTMP', $this->dirSizeTmp($path));
285:        $this->context->smarty->assign('dirSizeThemeCache', $this->dirSizeThemeCache($path));
286:        $this->context->smarty->assign('dirSizeSmartyCache', $this->dirSizeSmartyCache($path));
287:        $this->context->smarty->assign('dirSizeCacheFs', $this->dirSizeCacheFs($path));
288:        $this->context->smarty->assign('dirSizeTemplateCache', $this->dirSizeTemplateCache($path));
289:        $this->context->smarty->assign('pathTemplate', $pathTemplate);
290:        $this->context->smarty->assign('dataBaseSize', Configuration::get('SECURITYBOOSTER_DATABASE_SIZE'));
291:        $this->context->smarty->assign('php_info', $this->getPhpInfo());
292:        $this->context->smarty->assign('checkAbandonedCarts', $this->checkAbandonedCarts());
293:        $this->context->smarty->assign('checkConnection', $this->checkConnection());
294:        $this->context->smarty->assign('checkIntegrityDataBase', $this->checkIntegrityDataBase());
295:        $this->context->smarty->assign('folderTotalSize', (($this->dirSizeCacheFs($path) + $this->dirSizeSmartyCache($path) + $this->dirSizeTemplateCache($path) + $this->dirSizeThemeCache($path) + $this->dirSizeTmp($path)) / 1000));
296:        $this->context->smarty->assign('checkDataBase', Configuration::get('SECURITYBOOSTER_DATABASE_STATUS'));
3. controllers/admin/AdminModulesController.php:1653 source securityBooster->getContent()
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<contact@pliciweb.com>
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: 2020-02-04 09:43:33
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. smtgitb9e0nbr7r0/index.php:63 source DispatcherCore->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();
Edited by movieseals

Share this post


Link to post
Share on other sites

The problem seems to be not in the cross-selling module that works fine.. but from your module called :

securitybooster

this one, in order to work properly should not be cached, just try to not use the page cache at all.. I don't think you'll find it less fast than before, and don't be confused I am not talking about smarty cache, this one should still be engaged.

  • Like 1

Share this post


Link to post
Share on other sites

@movieseals are you using this module for speed optimization? I can only say this: thirtybees is quite fast without any external modules. You also don't need this "Full Page Cache" as @zen correctly pointed out. If your website is slow: check your hoster or the external modules.

When I have performance issues in 95% the reason is due to a shitty external module.

Share this post


Link to post
Share on other sites
On 2/19/2020 at 5:47 AM, zen said:

The problem seems to be not in the cross-selling module that works fine.. but from your module called :

securitybooster

this one, in order to work properly should not be cached, just try to not use the page cache at all.. I don't think you'll find it less fast than before, and don't be confused I am not talking about smarty cache, this one should still be engaged.

You oriented me towards a solution.  Thank you very much!

Share this post


Link to post
Share on other sites
On 2/19/2020 at 9:09 AM, wakabayashi said:

@movieseals are you using this module for speed optimization? I can only say this: thirtybees is quite fast without any external modules. You also don't need this "Full Page Cache" as @zen correctly pointed out. If your website is slow: check your hoster or the external modules.

When I have performance issues in 95% the reason is due to a shitty external module.

Hi!  Not it is not meant to speed up the site - I do have another module to do a full page cache and I have found that used in conjunction with the quite fast native TB help improve the speed of loading a little.  There is an option to punch holes in the full page caches for modules, so I did that and it fixed the issue!  Thank you so much.

Share this post


Link to post
Share on other sites

Errors in Smarty compiled code doesn't mean Smarty is at fault. It means that code embedded in a template compiled by Smarty is buggy. The template needs fixing.

Share this post


Link to post
Share on other sites

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...