xarnoux Posted July 5, 2019 Share Posted July 5, 2019 Bonsoir, depuis aujourd'hui, j'ai ce message qui s'affiche dès que je charge une page sur le back office : Warning à la ligne 551 du fichier /homepages/24/d742654074/htdocs/classes/controller/AdminController.php [2] count(): Parameter must be an array or an object that implements Countable Je n'ai aucune idée de ce qui a pu arriver. Si quelqu'un veut bien m'éclairer. Par avance, merci. Xavier. Link to comment Share on other sites More sharing options...
doekia Posted July 5, 2019 Share Posted July 5, 2019 Informations manquantes Merci de lire ceci Link to comment Share on other sites More sharing options...
xarnoux Posted July 5, 2019 Author Share Posted July 5, 2019 (edited) Désolé, voici pus d'infos ... Version de PS : 1.6.1.17 URL du site concerné : www.les-goodies.fr Hébergement : 1&1 Version de PHP : 7.2 Version de MySQL : MySql 5.5 Edited July 5, 2019 by xarnoux (see edit history) Link to comment Share on other sites More sharing options...
Martijn++ Posted July 6, 2019 Share Posted July 6, 2019 Pour éviter le message de warning, la fonction doit être légèrement étendue : if (is_array($tabs) || count($tabs)) { Link to comment Share on other sites More sharing options...
Eolia Posted July 6, 2019 Share Posted July 6, 2019 PHP 7 ne laisse pas passer ce genre d'erreur. Vous la voyez actuellement car vous êtes passé de php5.6 à 7 /** * Set breadcrumbs array for the controller page * * @param int|null $tab_id * @param array|null $tabs */ public function initBreadcrumbs($tab_id = null, $tabs = null) { if (is_array($tabs) || count($tabs)) { $tabs = array(); } ... Link to comment Share on other sites More sharing options...
Martijn++ Posted July 6, 2019 Share Posted July 6, 2019 Désolé, je suppose qu'il était trop tôt ce matin. Il faut la modifier à ce point-ci : public function initBreadcrumbs($tab_id = null, $tabs = null) { // adapted to PHP 7.2 by eleazar //if (is_array($tabs) || count($tabs)) { if (is_array($tabs) && count($tabs)) { $tabs = array(); } Link to comment Share on other sites More sharing options...
Eolia Posted July 6, 2019 Share Posted July 6, 2019 même pas, parce que dans ce cas là, si on envoie un tableau on l'écrase à vide... Le code correct est celui-ci: /** * Set breadcrumbs array for the controller page * * @param int|null $tab_id * @param array|null $tabs */ public function initBreadcrumbs($tab_id = null, $tabs = null) { if (!$tabs || !is_array($tabs)) { $tabs = array(); } ... Link to comment Share on other sites More sharing options...
xarnoux Posted July 6, 2019 Author Share Posted July 6, 2019 il y a 23 minutes, Eolia a dit : même pas, parce que dans ce cas là, si on envoie un tableau on l'écrase à vide... Le code correct est celui-ci: /** * Set breadcrumbs array for the controller page * * @param int|null $tab_id * @param array|null $tabs */ public function initBreadcrumbs($tab_id = null, $tabs = null) { if (!$tabs || !is_array($tabs)) { $tabs = array(); } ... J'ai testé mais j'ai ce message Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting end of file in /homepages/24/d742654074/htdocs/classes/controller/AdminController.php on line 4441 si je supprime ce code j'obtiens maintenant Warning à la ligne 551 du fichier /homepages/24/d742654074/htdocs/classes/controller/AdminController.php [2] count(): Parameter must be an array or an object that implements Countable Warning à la ligne 3274 du fichier /homepages/24/d742654074/htdocs/classes/controller/AdminController.php [2] count(): Parameter must be an array or an object that implements Countable Unknown error à la ligne 198 du fichier /homepages/24/d742654074/htdocs/classes/helper/HelperList.php [8192] Function create_function() is deprecated Par contre je n'ai pas essayé la méthode de Martijn, puis je le faire sans aucun risque ?? Link to comment Share on other sites More sharing options...
Eolia Posted July 6, 2019 Share Posted July 6, 2019 (edited) Vous avez du louper une accolade alors... La fonction complète: /** * Set breadcrumbs array for the controller page * * @param int|null $tab_id * @param array|null $tabs */ public function initBreadcrumbs($tab_id = null, $tabs = null) { if (!$tabs || !is_array($tabs)) { $tabs = array(); } if (is_null($tab_id)) { $tab_id = $this->id; } $tabs = Tab::recursiveTab($tab_id, $tabs); $dummy = array('name' => '', 'href' => '', 'icon' => ''); $breadcrumbs2 = array( 'container' => $dummy, 'tab' => $dummy, 'action' => $dummy ); if (isset($tabs[0])) { $this->addMetaTitle($tabs[0]['name']); $breadcrumbs2['tab']['name'] = $tabs[0]['name']; $breadcrumbs2['tab']['href'] = __PS_BASE_URI__.basename(_PS_ADMIN_DIR_).'/'.$this->context->link->getAdminLink($tabs[0]['class_name']); if (!isset($tabs[1])) { $breadcrumbs2['tab']['icon'] = 'icon-'.$tabs[0]['class_name']; } } if (isset($tabs[1])) { $breadcrumbs2['container']['name'] = $tabs[1]['name']; $breadcrumbs2['container']['href'] = __PS_BASE_URI__.basename(_PS_ADMIN_DIR_).'/'.$this->context->link->getAdminLink($tabs[1]['class_name']); $breadcrumbs2['container']['icon'] = 'icon-'.$tabs[1]['class_name']; } /* content, edit, list, add, details, options, view */ switch ($this->display) { case 'add': $breadcrumbs2['action']['name'] = $this->l('Add', null, null, false); $breadcrumbs2['action']['icon'] = 'icon-plus'; break; case 'edit': $breadcrumbs2['action']['name'] = $this->l('Edit', null, null, false); $breadcrumbs2['action']['icon'] = 'icon-pencil'; break; case '': case 'list': $breadcrumbs2['action']['name'] = $this->l('List', null, null, false); $breadcrumbs2['action']['icon'] = 'icon-th-list'; break; case 'details': case 'view': $breadcrumbs2['action']['name'] = $this->l('View details', null, null, false); $breadcrumbs2['action']['icon'] = 'icon-zoom-in'; break; case 'options': $breadcrumbs2['action']['name'] = $this->l('Options', null, null, false); $breadcrumbs2['action']['icon'] = 'icon-cogs'; break; case 'generator': $breadcrumbs2['action']['name'] = $this->l('Generator', null, null, false); $breadcrumbs2['action']['icon'] = 'icon-flask'; break; } $this->context->smarty->assign(array( 'breadcrumbs2' => $breadcrumbs2, 'quick_access_current_link_name' => $breadcrumbs2['tab']['name'].(isset($breadcrumbs2['action']) ? ' - '.$breadcrumbs2['action']['name'] : ''), 'quick_access_current_link_icon' => $breadcrumbs2['container']['icon'] )); /* BEGIN - Backward compatibility < 1.6.0.3 */ $this->breadcrumbs[] = $tabs[0]['name']; $navigation_pipe = (Configuration::get('PS_NAVIGATION_PIPE') ? Configuration::get('PS_NAVIGATION_PIPE') : '>'); $this->context->smarty->assign('navigationPipe', $navigation_pipe); /* END - Backward compatibility < 1.6.0.3 */ } Edited July 6, 2019 by Eolia (see edit history) Link to comment Share on other sites More sharing options...
xarnoux Posted July 6, 2019 Author Share Posted July 6, 2019 c'est bon le 1er code erreur a disparu il me reste ça : Warning à la ligne 3274 du fichier /homepages/24/d742654074/htdocs/classes/controller/AdminController.php [2] count(): Parameter must be an array or an object that implements Countable Unknown error à la ligne 198 du fichier /homepages/24/d742654074/htdocs/classes/helper/HelperList.php [8192] Function create_function() is deprecated Link to comment Share on other sites More sharing options...
doekia Posted July 6, 2019 Share Posted July 6, 2019 il y a 21 minutes, xarnoux a dit : [8192] Function create_function() is deprecated Les joies de vouloir faire fonctionner un code écrit pour PHP5.6 en PHP7.2 - change ton niveau d'error_reporting pour exclure les deprecated dans ce cas https://www.php.net/manual/fr/function.error-reporting.php Link to comment Share on other sites More sharing options...
Martijn++ Posted July 6, 2019 Share Posted July 6, 2019 Create_function est obsolète, et il y a aussi d'autres changements à noter. Les correctifs mis à jour pour Prestashop 1.5 et 1.6 peuvent être trouvés ici : http://ps.multimedia-bodensee.de/index.php/prestashop-tutorials/prestashop-tricks-tipps/item/6-anpassung-prestashop-1-5-6-2-und-1-6-1x-an-php-7-2 Link to comment Share on other sites More sharing options...
Lucinda91290 Posted February 8, 2021 Share Posted February 8, 2021 On 7/6/2019 at 11:33 AM, Eolia said: même pas, parce que dans ce cas là, si on envoie un tableau on l'écrase à vide... Le code correct est celui-ci: /** * Set breadcrumbs array for the controller page * * @param int|null $tab_id * @param array|null $tabs */ public function initBreadcrumbs($tab_id = null, $tabs = null) { if (!$tabs || !is_array($tabs)) { $tabs = array(); } ... Yes ça marche ! merci beaucoup ! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now