shannah / xataface

Framework for building data-driven web applications in PHP and MySQL
http://xataface.com
GNU General Public License v2.0
134 stars 57 forks source link

PHP Warning: count(): Parameter must be an array or an object that implements Countable in ...xataface/Dataface/SkinTool.php on line 877 #99

Open matrasas opened 6 years ago

matrasas commented 6 years ago

PHP Warning: count(): Parameter must be an array or an object that implements Countable in .../xataface/Dataface/SkinTool.php on line 877

PHP version: 7.2.2

m4745 commented 6 years ago

added is_array check for $stack variable and error is gone, dunno if there will be any consequences..

    function define_slot($params, $content,  &$smarty, &$repeat){
        if ( isset($content) ) {
            if ( $repeat) echo "We are repeating $params[name]";
            if ( @$this->app->_conf['debug'] ) $content = '<!-- Begin Slot '.$params['name'].' -->'.$content.'<!-- End Slot '.$params['name'].' -->';
            return $content;
        }

        // From this point on we can assume we're in the first iteration
        $stack =& $smarty->get_template_vars('__macro_stack__');
        if (is_array($stack)){
        $local_vars =& $stack[count($stack)-1];
        foreach ( array_reverse(array_keys($stack) ) as $macroIndex) {
            $local_vars =& $stack[$macroIndex];
            if ( isset( $local_vars['__slots__'][$params['name']]) ){
                // we found a slot to display here.
                // tell smarty not to execute the inside of this
                $repeat=false;  //
                echo $local_vars['__slots__'][$params['name']];
                //display the slot and return
                return;
            }
            unset($local_vars);
        }
    }
        if ( isset($params['table']) ) $tname = $params['table'];
        else $tname = $this->ENV['table'];

        $table =& Dataface_Table::loadTable($tname);
        $out = $table->getBlockContent($params['name']);
        if ( isset($out) ) {
            // We found a block to display here.
            $repeat = false;    // tell smarty not to execute inside of tag

            // Display the block and return
            echo $out;
            return;
        }
    }