[Tickets #14581] Array operation on non-array throws warnings - fix available

noreply at bugs.horde.org noreply at bugs.horde.org
Thu Feb 16 16:46:54 UTC 2017


BITTE NICHT AUF DIESE NACHRICHT ANTWORTEN. NACHRICHTEN AN DIESE  
E-MAIL-ADRESSE WERDEN NICHT GELESEN.

Ticket-URL: https://bugs.horde.org/ticket/14581
------------------------------------------------------------------------------
  Ticket           | 14581
  Erstellt Von     | torben at dannhauer.info
  Zusammenfassung  | Array operation on non-array throws warnings - fix
                   | available
  Warteschlange    | Horde Base
  Version          | Git master
  Typ              | Bug
  Status           | Unconfirmed
  Priorität        | 1. Low
  Milestone        |
  Patch            | 1
  Zuständige       |
------------------------------------------------------------------------------


torben at dannhauer.info (2017-02-16 16:46) hat geschrieben:

The function addArray($item) in  
/home/torben/horde/framework/Core/lib/Horde/Menu.php : line 71

performs array operations on (potential non-arrays). This throws  
warnings caused in multiple lines of the functions and pollutes the  
error log.

The suggest solution is to convert $item to an array before working  
with array operations on it.

The function should be like this:
-----

     /**
      * Add an item to the menu array.
      *
      * @param array $item  The item to add.  Valid keys:
      * <pre>
      * 'class' - (string) CSS classname.
      * 'icon' - (string) Filename of the image icon.
      * 'icon_path' - (string) Non-default directory path for icon.
      * 'onclick' - (string) Onclick javascript.
      * 'target' - (string) HREF target parameter.
      * 'text' - (string) Label.
      * 'url' - (string) Hyperlink.
      * </pre>
      *
      * @return integer  The id (NOT guaranteed to be an array index) of the
      *                  item just added to the menu.
      */
     public function addArray($item)
     {
         $item = array($item);
         if (!isset($item['url'])) {
             $item['url'] = new Horde_Url();
         } elseif (!($item['url'] instanceof Horde_Url)) {
             $item['url'] = new Horde_Url($item['url']);
         }

         $this->_menu[] = array_merge(array(
             'class' => null,
             'icon' => '',
             'icon_path' => null,
             'onclick' => null,
             'target' => '',
             'text' => ''
         ), $item);
     }








More information about the bugs mailing list