6.0.0-beta1
7/19/25

[#14581] Array operation on non-array throws warnings - fix available
Summary Array operation on non-array throws warnings - fix available
Queue Horde Base
Queue Version Git master
Type Bug
State Resolved
Priority 1. Low
Owners mrubinsk (at) horde (dot) org
Requester torben (at) dannhauer (dot) info
Created 02/16/2017 (3075 days ago)
Due
Updated 02/25/2017 (3066 days ago)
Assigned 02/25/2017 (3066 days ago)
Resolved 02/25/2017 (3066 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch Yes

History
02/25/2017 05:11:33 PM Michael Rubinsky Comment #12
State ⇒ Resolved
Reply to this comment
There was a slight sort-of BC break in the way the customized menu 
items are rendered. I've added the ability back to specify a specific 
"container" for custom items and have updated the instructions on the 
menu.php.dist files to reflect this. Note that these currently only 
work in traditional view, not dynamic view.
02/25/2017 05:12:02 AM Michael Rubinsky Comment #11
State ⇒ Assigned
Reply to this comment
Yeah, it looks like the code that adds the separator was lost during 
some Horde 5 refactoring...
02/24/2017 07:04:27 PM torben (at) dannhauer (dot) info Comment #10 Reply to this comment

[Show Quoted Text - 12 lines]
Thanks!

The menu items are displayed, but the separator is not displayed.
02/24/2017 05:31:40 PM Michael Rubinsky State ⇒ Resolved
 
02/24/2017 05:31:15 PM Git Commit Comment #9 Reply to this comment
Changes have been made in Git (master):

commit a3f3b09028a91e2cb6e98196497eb3c1b01f6462
Author: Michael J Rubinsky <mrubinsk@horde.org>
Date:   Fri Feb 24 12:28:50 2017 -0500

     Bug: 14581 Allow a string containing 'separator' to be passed as well.

  framework/Core/lib/Horde/Menu.php | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)

http://github.com/horde/horde/commit/a3f3b09028a91e2cb6e98196497eb3c1b01f6462
02/22/2017 01:53:19 PM Michael Rubinsky Comment #8 Reply to this comment

[Show Quoted Text - 66 lines]
The latter is exactly what I said in my above reply :)  I will change 
the method in question to accept either an array or a string 
containing the value "separator".
What is your recommended solution?

Thanks,
Torben
02/22/2017 07:25:26 AM torben (at) dannhauer (dot) info Comment #7 Reply to this comment

[Show Quoted Text - 62 lines]
Hm, if the seperator string is the culprit, we need either change the 
way seperators are defined, or we allow arrays and strings and need to 
adapt the code down the road to accept it.

What is your recommended solution?

Thanks,
Torben

02/21/2017 11:30:25 PM Michael Rubinsky Comment #6
State ⇒ Assigned
Assigned to Michael Rubinsky
Reply to this comment

[Show Quoted Text - 53 lines]
Perfect. This is the culprit. This file instructs to add a string, yet 
the phpdoc of the method that is called to add the menu entry requires 
a string. I guess it makes the most sense to allow an array or a 
string containing 'separator' seeing how these instructions are out in 
the wild...


02/21/2017 10:28:17 PM torben (at) dannhauer (dot) info Comment #5 Reply to this comment
Do you have any custom {app}/config/menu.php files?
Yes for wicked. But currently it does not work, the links are not displayed.
I'm on the road, will post the content later.

Thanks,
Torben
This is my horde/wicked/config/menu.php :


<?php
/*
  * This file lets you extend Wicked's menu with your own items.
  *
  * To add a new menu item, simply add a new entry to the $_menu array.
  * Valid attributes for a new menu item are:
  *
  *  'url'       The URL value for the menu item.
  *  'text'      The text to accompany the menu item.
  *
  * These attributes are optional:
  *
  *  'icon'      The filename of an icon to use for the menu item.
  *  'icon_path' The path to the icon if it doesn't exist in the graphics/
  *              directory.
  *  'target'    The "target" of the link (e.g. '_top', '_blank').
  *  'onclick'   Any JavaScript to execute on the "onclick" event.
  *
  * Here's an example entry:
  *
  *  $_menu[] = array(
  *      'url' =>        'http://www.example.com/',
  *      'text' =>       'Example, Inc.',
  *      'icon' =>       'example.gif',
  *      'icon_path' =>  'http://www.example.com/images/',
  *      'target' =>     '_blank',
  *      'onclick' =>    ''
  *  );
  *
  * You can also add a "separator" (a spacer) between menu items.  To add a
  * separator, simply add a new string to the $_menu array set to the text
  * 'separator'.  It should look like this:
  *
  *  $_menu[] = 'separator';
  */

$_menu = array();

/* Add your custom entries below this line. */

$_menu[] = 'separator';

$_menu[] = array(
         'url' =>        '<URL1>',
         'text' =>       'Desc 1',
         'icon' =>       '',
         'icon_path' =>  '',
         'target' =>     '',
         'onclick' =>    ''
         );

$_menu[] = array(
         'url' =>        '<URL 2>',
         'text' =>       'Desc 2',
         'icon' =>       '',
         'icon_path' =>  '',
         'target' =>     '',
         'onclick' =>    ''
         );

$_menu[] = array(
         'url' =>        '<URL 3>',
         'text' =>       'Desc 3',
         'icon' =>       '',
         'icon_path' =>  '',
         'target' =>     '',
         'onclick' =>    ''
         );


02/21/2017 02:47:48 PM torben (at) dannhauer (dot) info Comment #4 Reply to this comment
Do you have any custom {app}/config/menu.php files?
Yes for wicked. But currently it does not work, the links are not displayed.
I'm on the road, will post the content later.

Thanks,
Torben

02/21/2017 01:49:22 PM Michael Rubinsky Comment #3 Reply to this comment
Do you have any custom {app}/config/menu.php files?
02/17/2017 04:02:02 PM Michael Rubinsky Comment #2
State ⇒ Feedback
Reply to this comment

Considering the phpdoc for the method indicates that $item IS an 
array, we need to find out where this is being called from with an 
invalid parameter and fix it there.

02/16/2017 04:46:54 PM torben (at) dannhauer (dot) info Comment #1
Priority ⇒ 1. Low
State ⇒ Unconfirmed
Patch ⇒ Yes
Milestone ⇒
Summary ⇒ Array operation on non-array throws warnings - fix available
Type ⇒ Bug
Queue ⇒ Horde Base
Reply to this comment
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);
     }



Saved Queries