siliconsys.com/blog main | forums | support | host | blog 
siliconsys.com forums oscommerce siliconsys.com forums zencart siliconsys.com forums oscommerce zencart

November 26, 2007

PHP5 array_merge() Compatibility

PHP5 changed the function definition for the array_merge() function. It no longer accepts a string or array for the search parameter. Now both parameters must be arrays.

If you are experiencing issues with not being able to edit or delete products, users or orders in the PHPCatalog admin panel, this bug may be affecting you.

More information about the PHP change may be found on PHP's site.
http://us2.php.net/manual/en/function.array-merge.php

This change has been implemented in the PHPCatalog core code for over a year, but we have had some reports of issues with older versions. To update your install, make the code change below in catalog/include/stdlib.inc.

Backup before performing any code changes!

OLD

function extra_vars($remove='') {
                global $form;

                $rem_arr = array('id', 'function', 'sel_category');
                $rem_arr        = array_merge($remove, $rem_arr);

                foreach($_GET as $key => $val)  {
                        if(!in_array($key, $rem_arr))
                                $extra_vars .= $key . '=' . $val . '&';
                }

                if(isset($form['query']) && $form['query'] != '' && ! isset($_GET['query'])) $extra_vars .= 'query=' . urlencode($form['query']) . ' ';
                if($extra_vars != '')   {
                        $extra_vars = substr($extra_vars, 0, -1);
                        $extra_vars = '&' . $extra_vars;
                }

NEW PHP5

/**
         * return variables passed in get as string for inclusion in URL
         *
         * @param array $remove
         * @return string
         */

        function extra_vars($remove='') {
                global $form;

                if(! is_array($remove)) $remove = array($remove);
                $rem_arr = array('id', 'fn', 'sel_category', 'mod', 'act', 'submit', 'sort', 'cat_id');
                $rem_arr = array_merge($remove, $rem_arr);

                foreach($_GET as $key => $val)  {
                        if(is_array($val))      {
                                foreach($val as $key1 => $val1) {
                                        if(!in_array($key1, $rem_arr))
                                                $extra_vars .= $key . '['.$key1 . ']=' . $val1 . '&';
                                }
                        }       else   {
                                if(!in_array($key, $rem_arr))
                                        $extra_vars .= $key . '=' . $val . '&';
                        }
                }

                if(isset($form['query']) && $form['query'] != '') $extra_vars .= 'query=' . urlencode($form['query']) . ' ';
                if($extra_vars != '')   {
                        $extra_vars = substr($extra_vars, 0, -1);
                        $extra_vars = '&' . $extra_vars;
                }
                return $extra_vars;
        }

Filed under: PHPCatalog, Bugs — dev @ 8:53 am

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress