title: Can't find what I should change from "Undefined offset: 1" PHP notice
body: <p>I've got this error : </p>
  
  <blockquote>
    <p>PHP Notice:  Undefined offset: 1 in /var/www/joomla/Joomla_3/modules/mod_menu/helper.php on line 59</p>
  </blockquote>
  
  <p>I found after searching that it might be due to the first parameter of an array that is not defined. But I tried many things and I can't find what I should change to make this work without the notice.</p>
  
  <p>Here is the helper.php :</p>
  
  <pre><code>&lt;?php
  /**
   * @package     Joomla.Site
   * @subpackage  mod_menu
   *
   * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   */
  
  defined('_JEXEC') or die;
  
  /**
   * Helper for mod_menu
   *
   * @package     Joomla.Site
   * @subpackage  mod_menu
   * @since       1.5
   */
  class ModMenuHelper
  {
      /**
       * Get a list of the menu items.
       *
       * @param  JRegistry   $params  The module options.
       *
       * @return  array
       *
       * @since   1.5
       */
      public static function getList(&amp;$params)
      {
          $app = JFactory::getApplication();
          $menu = $app-&gt;getMenu();
  
          // Get active menu item
          $base = self::getBase($params);
          $user = JFactory::getUser();
          $levels = $user-&gt;getAuthorisedViewLevels();
          asort($levels);
          $key = 'menu_items' . $params . implode(',', $levels) . '.' . $base-&gt;id;
          $cache = JFactory::getCache('mod_menu', '');
          if (!($items = $cache-&gt;get($key)))
          {
              $path    = $base-&gt;tree;
              $start   = (int) $params-&gt;get('startLevel');
              $end     = (int) $params-&gt;get('endLevel');
              $showAll = $params-&gt;get('showAllChildren');
              $items   = $menu-&gt;getItems('menutype', $params-&gt;get('menutype'));
  
              $lastitem = 0;
  
              if ($items)
              {
                  foreach ($items as $i =&gt; $item)
                  {
                      if (($start &amp;&amp; $start &gt; $item-&gt;level)
                          || ($end &amp;&amp; $item-&gt;level &gt; $end)
                          || (!$showAll &amp;&amp; $item-&gt;level &gt; 1 &amp;&amp; !in_array($item-&gt;parent_id, $path))
  //THIS IS LINE 59       || ($start &gt; 1 &amp;&amp; !in_array($item-&gt;tree[$start - 2], $path)))
                      {
                          unset($items[$i]);
                          continue;
                      }
  
                      $item-&gt;deeper     = false;
                      $item-&gt;shallower  = false;
                      $item-&gt;level_diff = 0;
  
                      if (isset($items[$lastitem]))
                      {
                          $items[$lastitem]-&gt;deeper     = ($item-&gt;level &gt; $items[$lastitem]-&gt;level);
                          $items[$lastitem]-&gt;shallower  = ($item-&gt;level &lt; $items[$lastitem]-&gt;level);
                          $items[$lastitem]-&gt;level_diff = ($items[$lastitem]-&gt;level - $item-&gt;level);
                      }
  
                      $item-&gt;parent = (boolean) $menu-&gt;getItems('parent_id', (int) $item-&gt;id, true);
  
                      $lastitem     = $i;
                      $item-&gt;active = false;
                      $item-&gt;flink  = $item-&gt;link;
  
                      // Reverted back for CMS version 2.5.6
                      switch ($item-&gt;type)
                      {
                          case 'separator':
                          case 'heading':
                              // No further action needed.
                              continue;
  
                          case 'url':
                              if ((strpos($item-&gt;link, 'index.php?') === 0) &amp;&amp; (strpos($item-&gt;link, 'Itemid=') === false))
                              {
                                  // If this is an internal Joomla link, ensure the Itemid is set.
                                  $item-&gt;flink = $item-&gt;link . '&amp;Itemid=' . $item-&gt;id;
                              }
                              break;
  
                          case 'alias':
                              // If this is an alias use the item id stored in the parameters to make the link.
                              $item-&gt;flink = 'index.php?Itemid=' . $item-&gt;params-&gt;get('aliasoptions');
                              break;
  
                          default:
                              $router = JSite::getRouter();
                              if ($router-&gt;getMode() == JROUTER_MODE_SEF)
                              {
                                  $item-&gt;flink = 'index.php?Itemid=' . $item-&gt;id;
                              }
                              else
                              {
                                  $item-&gt;flink .= '&amp;Itemid=' . $item-&gt;id;
                              }
                              break;
                      }
  
                      if (strcasecmp(substr($item-&gt;flink, 0, 4), 'http') &amp;&amp; (strpos($item-&gt;flink, 'index.php?') !== false))
                      {
                          $item-&gt;flink = JRoute::_($item-&gt;flink, true, $item-&gt;params-&gt;get('secure'));
                      }
                      else
                      {
                          $item-&gt;flink = JRoute::_($item-&gt;flink);
                      }
  
                      // We prevent the double encoding because for some reason the $item is shared for menu modules and we get double encoding
                      // when the cause of that is found the argument should be removed
                      $item-&gt;title        = htmlspecialchars($item-&gt;title, ENT_COMPAT, 'UTF-8', false);
                      $item-&gt;anchor_css   = htmlspecialchars($item-&gt;params-&gt;get('menu-anchor_css', ''), ENT_COMPAT, 'UTF-8', false);
                      $item-&gt;anchor_title = htmlspecialchars($item-&gt;params-&gt;get('menu-anchor_title', ''), ENT_COMPAT, 'UTF-8', false);
                      $item-&gt;menu_image   = $item-&gt;params-&gt;get('menu_image', '') ? htmlspecialchars($item-&gt;params-&gt;get('menu_image', ''), ENT_COMPAT, 'UTF-8', false) : '';
                  }
  
                  if (isset($items[$lastitem]))
                  {
                      $items[$lastitem]-&gt;deeper     = (($start?$start:1) &gt; $items[$lastitem]-&gt;level);
                      $items[$lastitem]-&gt;shallower  = (($start?$start:1) &lt; $items[$lastitem]-&gt;level);
                      $items[$lastitem]-&gt;level_diff = ($items[$lastitem]-&gt;level - ($start?$start:1));
                  }
              }
  
              $cache-&gt;store($items, $key);
          }
          return $items;
      }
  
      /**
       * Get base menu item.
       *
       * @param   JRegistry  $params  The module options.
       *
       * @return   object
       *
       * @since   3.0.2
       */
      public static function getBase(&amp;$params)
      {
  
          // Get base menu item from parameters
          if ($params-&gt;get('base'))
          {
              $base = JFactory::getApplication()-&gt;getMenu()-&gt;getItem($params-&gt;get('base'));
          }
          else
          {
              $base = false;
          }
  
          // Use active menu item if no base found
          if (!$base)
          {
              $base = self::getActive($params);
          }
  
          return $base;
      }
  
      /**
       * Get active menu item.
       *
       * @param   JRegistry  $params  The module options.
       *
       * @return  object
       *
       * @since   3.0.2
       */
      public static function getActive(&amp;$params)
      {
          $menu = JFactory::getApplication()-&gt;getMenu();
  
          return $menu-&gt;getActive() ? $menu-&gt;getActive() : $menu-&gt;getDefault();
      }
  
  }
  </code></pre>