Jump to content

Recommended Posts

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.

 

Share this post


Link to post
Share on other sites

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 by xarnoux (see edit history)

Share this post


Link to post
Share on other sites

Pour éviter le message de warning, la fonction doit être légèrement étendue :

if (is_array($tabs) || count($tabs)) {

Share this post


Link to post
Share on other sites

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();
        }
...

 

Share this post


Link to post
Share on other sites

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();
    }

 

 

Share this post


Link to post
Share on other sites

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();
        }
...

 

Share this post


Link to post
Share on other sites
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 ??

Share this post


Link to post
Share on other sites

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 by Eolia (see edit history)

Share this post


Link to post
Share on other sites

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

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

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More