mabu Posted January 20, 2009 Share Posted January 20, 2009 I moved my application to the latest version of PHP. One aspect appears to be breaking down now and I can't tell if it's an environmental thing or a change in PHP - here's what's happening. I have a cron script running this command: /usr/local/bin/php /www/webroot/app/mlrun.php mlid=3 it's called by this: setup_args($CMD); it generates this error: PHP Warning: array_merge(): Argument #1 is not an array in /usr/www/webroot/bsalert/l-argv.php on line 15 Warning: array_merge(): Argument #1 is not an array in /usr/www/webroot/bsalert/l-argv.php on line 15 Subject: Mailing List Run () It's been awhile since I worked on the code but it appears to be using $CMD and breaking it into name/value pairs - has the structure of this info now changed? Here's the routine which generates the error: function setup_args(&$setarray) { global $argc,$argv; // // if ($argc > 0) { for ($i=1;$i < $argc;$i++) { parse_str($argv[$i],$tmp); $setarray = array_merge($setarray, $tmp); // <-- generating warning? } } return ($argc); } ?> Any idea what's wrong? Link to comment https://forums.phpfreaks.com/topic/141619-change-in-how-parms-are-handled-from-323-to-5x/ Share on other sites More sharing options...
cooldude832 Posted January 20, 2009 Share Posted January 20, 2009 You moved from a php 3.x to a php 5.x Odds are nothing will work right unless the script is designed to run on php 5.x Superglobals, class construct, sessions its all very well changed to the point most things will fail. Link to comment https://forums.phpfreaks.com/topic/141619-change-in-how-parms-are-handled-from-323-to-5x/#findComment-741275 Share on other sites More sharing options...
mabu Posted January 20, 2009 Author Share Posted January 20, 2009 You moved from a php 3.x to a php 5.x Odds are nothing will work right unless the script is designed to run on php 5.x Superglobals, class construct, sessions its all very well changed to the point most things will fail. Everything works except for that one thing... has $CMD changed? Link to comment https://forums.phpfreaks.com/topic/141619-change-in-how-parms-are-handled-from-323-to-5x/#findComment-741278 Share on other sites More sharing options...
cooldude832 Posted January 20, 2009 Share Posted January 20, 2009 $CMD is not a variable I am aware of in php at all. Odds are you have some sort of superglobal issue and really there are a ton of underlying issues, but the page is failing really early. Read your script's manual on what $cmd is odds are it is really $_GET['cmd'] or $_POST['cmd']; Link to comment https://forums.phpfreaks.com/topic/141619-change-in-how-parms-are-handled-from-323-to-5x/#findComment-741282 Share on other sites More sharing options...
mabu Posted January 20, 2009 Author Share Posted January 20, 2009 $CMD is not a variable I am aware of in php at all. Odds are you have some sort of superglobal issue and really there are a ton of underlying issues, but the page is failing really early. Read your script's manual on what $cmd is odds are it is really $_GET['cmd'] or $_POST['cmd']; If you look at the code, it makes sense now... $CMD is a variable passed to the setup_args function which sets it based on $argc/$argv.. It creates an associative array that I use later in the program.. so maybe the structure of $argv has changed in php 5? Link to comment https://forums.phpfreaks.com/topic/141619-change-in-how-parms-are-handled-from-323-to-5x/#findComment-741287 Share on other sites More sharing options...
PFMaBiSmAd Posted January 20, 2009 Share Posted January 20, 2009 The posted code expects $CMD to be an array, even if it is an empty array. The function is also poorly written to operate directly on $CMD instead of returning the results from the function call and making an assignment. If there is no code that references $CMD prior to where that function is called, add the following to create an empty array right before you call the function - $CMD = array(); Link to comment https://forums.phpfreaks.com/topic/141619-change-in-how-parms-are-handled-from-323-to-5x/#findComment-741300 Share on other sites More sharing options...
mabu Posted January 20, 2009 Author Share Posted January 20, 2009 The posted code expects $CMD to be an array, even if it is an empty array. The function is also poorly written to operate directly on $CMD instead of returning the results from the function call and making an assignment. If there is no code that references $CMD prior to where that function is called, add the following to create an empty array right before you call the function - $CMD = array(); ZING! That fixed it... Thank you very much! I know that code is crap... I swear I look at it and I don't even think I wrote it. I don't know what I was thinking... Link to comment https://forums.phpfreaks.com/topic/141619-change-in-how-parms-are-handled-from-323-to-5x/#findComment-741305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.