1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Possible Bug in XenForo_Option_NodeChooser

Discussion in 'Resolved Bug Reports' started by ragtek, Jun 21, 2011.

  1. ragtek

    ragtek Guest

    Check pls the method getNodeOptions

    i'm trying to create a nodeselected checkbox
    if i use this code
    PHP:
            $forumOptions XenForo_Option_NodeChooser::getNodeOptions(
                
    $value['node_id'],
                
    sprintf('(%s)', new XenForo_Phrase('unspecified')),
                
    'Forum'
            
    );
    i'm getting this error.
    PHP:

    [SIZE=3][B]Template Errorsragtek_fw_option_nodemultiselect[/B][/SIZE]

    [LIST=
    1]
    [*][
    I]Invalid argument supplied for foreach()[/Iin C:\xampp\htdocs\xenforo\library\XenForo\Template\Helper\Admin.phpline 1121
    [*][I]Invalid argument supplied for foreach()[/Iin C:\xampp\htdocs\xenforo\library\XenForo\Template\Helper\Admin.phpline 1121
    [*][I]Invalid argument supplied for foreach()[/Iin C:\xampp\htdocs\xenforo\library\XenForo\Template\Helper\Admin.phpline 1121
    [*][I]Invalid argument supplied for foreach()[/Iin C:\xampp\htdocs\xenforo\library\XenForo\Template\Helper\Admin.phpline 1121
    [*][I]Invalid argument supplied for foreach()[/Iin C:\xampp\htdocs\xenforo\library\XenForo\Template\Helper\Admin.phpline 1121
    [*][I]Invalid argument supplied for foreach()[/Iin C:\xampp\htdocs\xenforo\library\XenForo\Template\Helper\Admin.phpline 1121
    [*][I]Invalid argument supplied for foreach()[/Iin C:\xampp\htdocs\xenforo\library\XenForo\Template\Helper\Admin.phpline 1121
    [*][I]Invalid argument supplied for foreach()[/Iin C:\xampp\htdocs\xenforo\library\XenForo\Template\Helper\Admin.phpline 1121
    [*][I]Invalid argument supplied for foreach()[/Iin C:\xampp\htdocs\xenforo\library\XenForo\Template\Helper\Admin.phpline 1121
    [*][I]Invalid argument supplied for foreach()[/Iin C:\xampp\htdocs\xenforo\library\XenForo\Template\Helper\Admin.phpline 1121
    [/LIST]
    problem is, that this check can't be run,
    PHP:
        if (!empty($option['node_type_id']) && $option['node_type_id'] != $filter)
    if includeroot is set to true in nodemodel getNodeOptionsArray

    as you see here,
    PHP:
        public function getNodeOptionsArray(array $nodes$selectedNodeId 0$includeRoot false)
        {
            
    $options = array();

            if (
    $includeRoot !== false)
            {
                
    $root $this->getRootNode();

                
    $options[0] = array(
                    
    'value' => 0,
                    
    'label' => (is_string($includeRoot) === true $includeRoot $root['title']),
                    
    'selected' => (strval($selectedNodeId) === '0'),
                    
    'depth' => 0,
                );
            }
    the first element doesn't have a node_type_id and that's why the check is making troubles
     
  2. ragtek

    ragtek Guest

    ok this wasn't the problem

    The problem was this admin template helper:
    PHP:
        protected static function _getDisablerHtml(array $optionInfo$optionId)
        {
            
            if ( !empty(
    $optionInfo['disabled']))
            {
                
    $disablerHtml "\n<ul id=\"{$optionId}_Disabler\">";
                foreach (
    $optionInfo['disabled'] AS  $disabled)
                {
                    
    $disablerHtml .= "\n<li>$disabled</li>";
                }
                
    $disablerHtml .= "\n</ul>\n";
            }

            return 
    $disablerHtml;
        }
    it checks only, if $optionInfo['disabled'] is set, but not if it's an array (which is requested for the foreach)
    This solved the problem:
    PHP:
        protected static function _getDisablerHtml(array $optionInfo$optionId)
        {
            
    $disablerHtml '';
            if ( !empty(
    $optionInfo['disabled']) AND is_array($optionInfo['disabled']))
            {
                
    $disablerHtml "\n<ul id=\"{$optionId}_Disabler\">";
                foreach (
    $optionInfo['disabled'] AS  $disabled)
                {
                    
    $disablerHtml .= "\n<li>$disabled</li>";
                }
                
    $disablerHtml .= "\n</ul>\n";
            }

            return 
    $disablerHtml;
        }
    Don't know if it's a xenforo bug
     
    Alluidh likes this.
  3. Kier

    Kier XenForo Developer Staff Member

    Can't hurt to have the check in place.
     
    Vincent likes this.

Share This Page