Need some help diagnosing functions_general,php errors
I am getting nowhere fast posting in the contributions and addons section with regard to this mod so apologies for posting in general questions, however, I am hoping that I may get more views from the gurus out there that may be able to spot the problem.
I am using the dynamic filter sidebox addon. everything is working great apart from getting some PHP warnings in the log directory building up.
I have seen similar posts and have tried some of the suggestions, however none seem to be fixing hte pronlem that I have.
the only file that appeared to be out of date is the function_general.php when installing so I did a merge on the file which maybe thats why I am having issues..
the warning I get is:
PHP Warning: strlen() expects parameter 1 to be string, array given in /home/site/public_html/newsite/includes/functions/functions_general.php on line 158
now the code that is causing the warnings and that I merged was like this:
PHP Code:
function zen_get_all_get_params($exclude_array = '', $search_engine_safe = true) {
if (!is_array($exclude_array)) $exclude_array = array();
$exclude_array = array_merge($exclude_array, array(zen_session_name(), 'main_page', 'error', 'x', 'y'));
$get_url = '';
if (is_array($_GET) && (sizeof($_GET) > 0)) {
reset($_GET);
while (list($key, $value) = each($_GET)) {
//removed below for merging dynamic filter
// if (is_array($value) || in_array($key, $exclude_array)) continue;
// if (strlen($value) > 0) {
// $get_url .= zen_sanitize_string($key) . '=' . rawurlencode(stripslashes($value)) . '&';
// bof dynamic filter 1 of 3
if ( (!in_array($key, $exclude_array)) && (strlen($value) > 0 || is_array($value) && array_filter($value) ) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) {
// eof dynamic filter 1 of 3
if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
// die ('here');
$get_url .= $key . '/' . rawurlencode(stripslashes($value)) . '/';
} else {
// bof dynamic filter 2 of 3
if (is_array($value)) {
foreach($value as $arr){
$get_url .= zen_sanitize_string($key) . '[]=' . rawurlencode(stripslashes($arr)) . '&';
}
} else {
// eof dynamic filter 2 of 3
$get_url .= zen_sanitize_string($key) . '=' . rawurlencode(stripslashes($value)) . '&';
// bof dynamic filter 3 of 3
}
// eof dynamic filter 3 of 3
}
}
}
}
while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);
while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);
return $get_url;
}
I found that the errors stopped if I removed one of the lines I commented out like this:
PHP Code:
function zen_get_all_get_params($exclude_array = '', $search_engine_safe = true) {
if (!is_array($exclude_array)) $exclude_array = array();
$exclude_array = array_merge($exclude_array, array(zen_session_name(), 'main_page', 'error', 'x', 'y'));
$get_url = '';
if (is_array($_GET) && (sizeof($_GET) > 0)) {
reset($_GET);
while (list($key, $value) = each($_GET)) {
//removed below for merging dynamic filter
if (is_array($value) || in_array($key, $exclude_array)) continue;
// if (strlen($value) > 0) {
// $get_url .= zen_sanitize_string($key) . '=' . rawurlencode(stripslashes($value)) . '&';
// bof dynamic filter 1 of 3
if ( (!in_array($key, $exclude_array)) && (strlen($value) > 0 || is_array($value) && array_filter($value) ) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) {
// eof dynamic filter 1 of 3
if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
// die ('here');
$get_url .= $key . '/' . rawurlencode(stripslashes($value)) . '/';
} else {
// bof dynamic filter 2 of 3
if (is_array($value)) {
foreach($value as $arr){
$get_url .= zen_sanitize_string($key) . '[]=' . rawurlencode(stripslashes($arr)) . '&';
}
} else {
// eof dynamic filter 2 of 3
$get_url .= zen_sanitize_string($key) . '=' . rawurlencode(stripslashes($value)) . '&';
// bof dynamic filter 3 of 3
}
// eof dynamic filter 3 of 3
}
}
}
}
while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);
while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);
return $get_url;
}
however, when the errors stopped, I noticed that the filter is lost when navigating to page 2 of the results (so basically breaks it)
So I guess I have two options, dig dig dig and see if there is a proper solution, or, somehow find a way to stop the error log building up by ignoring the warning some how as it doesn't seem to actually affect the functionality of the site at all. After all its only a warning right??
Can anyone please help? I spoke to a friend that also has this mod on a fresh install of zen-cart and also has the same warning log files.
Thanks in Advance,
Re: Need some help diagnosing functions_general,php errors
This is from my functions_general.php file, and I don't get any errors, maybe it is helping.
it's from ZC 1.5.1
PHP Code:
/**
* Return all HTTP GET variables, except those passed as a parameter
*
* The return is a urlencoded string
*
* @param mixed either a single or array of parameter names to be excluded from output
*/
function zen_get_all_get_params($exclude_array = '', $search_engine_safe = true) {
if (!is_array($exclude_array)) $exclude_array = array();
$exclude_array = array_merge($exclude_array, array(zen_session_name(), 'main_page', 'error', 'x', 'y'));
$get_url = '';
if (is_array($_GET) && (sizeof($_GET) > 0)) {
reset($_GET);
while (list($key, $value) = each($_GET)) {
// bof dynamic filter 1 of 3
if ( (!in_array($key, $exclude_array)) && (strlen($value) > 0 || is_array($value) && array_filter($value) ) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) {
// eof dynamic filter 1 of 3
// bof dynamic filter 2 of 3
if (is_array($value)) {
foreach($value as $arr){
$get_url .= zen_sanitize_string($key) . '[]=' . rawurlencode(stripslashes($arr)) . '&';
}
} else {
// eof dynamic filter 2 of 3
$get_url .= zen_sanitize_string($key) . '=' . rawurlencode(stripslashes($value)) . '&';
// bof dynamic filter 3 of 3
}
// eof dynamic filter 3 of 3
}
}
}
while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);
while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);
return $get_url;
}
Re: Need some help diagnosing functions_general,php errors
I just tried you code and I still get the PHP warning.. :'(
I am running CEON URI Mapping but I get the same even with the mapping switched off so pretty sure its not that.. I dont get it :(
Re: Need some help diagnosing functions_general,php errors
the line the warning is triggering on is this one specifically:
PHP Code:
if ( (!in_array($key, $exclude_array)) && (strlen($value) > 0 || is_array($value) && array_filter($value) ) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) {
Re: Need some help diagnosing functions_general,php errors
@Design75 so you don't get any php warning files in your /log directory at all??
Re: Need some help diagnosing functions_general,php errors
Re: Need some help diagnosing functions_general,php errors
That's really weird. This code is above me, do you know what it's all doing etc? If so any ideas where else I might look as clearly something isn't liking it even now I'm using your code for that function exactly.
Says its expecting an array, so one would assume its perhaps not seeing one when it should? Anyway we can degug it to see where it's going wrong?
Re: Need some help diagnosing functions_general,php errors
I am not much of a php guru. I know enough to be dangerous :laugh:. I am learning, and I will try to help.
What version of ZC, php, and mysql are you using? maybe I can try to duplicate the error by setting up a test-site with the same variables
Re: Need some help diagnosing functions_general,php errors
Thanks,
Zen Cart 1.5.1
Database Patch Level: 1.5.1
PHP Version: 5.3.10
Database: MySQL 5.1.66-cll
I have various mods but only one that really has core overrides is CEON URI MAPPINGS
I guess I need to understand where some of these variables on that line are called from to see if any of the files are modified by any of the mods I had installed?
Re: Need some help diagnosing functions_general,php errors
Okay, it's bedtime over here, so I'll report back tomorrow with my results from the test