Jump to content

change in how parms are handled from 3.23.* to 5.x?


mabu

Recommended Posts

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? 

 

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?

 

 

$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'];

$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?

 

 

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();

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...

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.