Jump to content

Undefined offset: 1 in classes/controller/AdminController.php on line 1528


mario.schillermann

Recommended Posts

Prestashop Version: 1.6.16

PHP Version: PHP 7.0.18-0ubuntu0.16.04.1

 

When I call the product list or a product comes following error message:

Undefined offset: 1 in classes/controller/AdminController.php on line 1528

 

Here is the prosses overview with comments.

public function initToolbarTitle()
{
    // $this->breadcrumbs == array(0 => 'Produkte', 1 => 'Produkte')
    $this->toolbar_title = is_array($this->breadcrumbs) ? array_unique($this->breadcrumbs) : array($this->breadcrumbs);
    // The array index now is on 2
    // $this->toolbar_title == array(0 => 'Produkte')

    switch ($this->display) {
            case 'edit':
                $this->toolbar_title[] = $this->l('Edit', null, null, false);
                // Now there is a gap in the array elements
                // $this->breadcrumbs == array(0 => 'Produkte', 2 => 'Bearbeiten')
                
                $this->addMetaTitle($this->l('Edit', null, null, false));
                break;
    }
}

public function initPageHeaderToolbar()
{
    case 'edit':
        // Here we jump into the hole of the lost array element
        $this->addMetaTitle($this->toolbar_title[count($this->toolbar_title) - 1]);
}

The same effect do you have with this example code

$toolbar_title = array_unique(array(0 => 'Produkte', 1 => 'Produkte'));
$toolbar_title[] = 'Bearbeiten';

//array(0 => 'Produkte', 2 => 'Bearbeiten')
var_dump($toolbar_title);

That is not a feature, but a Bug.

Edited by mario.schillermann (see edit history)
  • Haha 1
Link to comment
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...