0

Warning: Invalid argument supplied for foreach() in /.../ipn_res.php on line 28

Warning: Invalid argument supplied for foreach() in /.../ipn_cls.php on line 30

From line 28 is a foreach loop:

foreach ($paypal_ipn->paypal_post_vars as $key=>$value) {
    if (getType($key)=="string") {
        eval("\$$key=\$value;");
    }
}

From line 30 is also a foreach loop:

foreach($this->paypal_post_vars AS $key => $value) {
    if (@get_magic_quotes_gpc()) {
        $value = stripslashes($value);
    }
    $values[] = "$key" . "=" . urlencode($value);
}

And I think the root cause of the errors is this:

//This is located before foreach loop in ipn_res.php
require_once("ipn_cls.php");

$paypal_info = $HTTP_POST_VARS;
$paypal_ipn = new paypal_ipn($paypal_info);

The constructor of class paypal_ipn is passed with a non-array var because nothing has been sent yet that would fill out $HTTP_POST_VARS. Wordpress runs the code which is not the case when not in it. How do I get away from this?

1 Answer 1

1

Contact plugin's developer and ask him to fix?.. But I guess that is probably not an option if plugin is broken badly and remains that way.

For a quick band-aid try this right after object is created, to handle case of constructor not setting up field properly:

if( !isset( $paypal_ipn->paypal_post_vars ) )
    $paypal_ipn->paypal_post_vars = array();
2
  • Actually I am the developer, a noob one. :-)
    – Joann
    Nov 27, 2010 at 18:46
  • Ah. :) Then you probably need to handle the case when there is nothing to write into field. Either init field to empty array in constructor or do not run your loops if there is no data to process.
    – Rarst
    Nov 27, 2010 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.