Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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();
share|improve this answer
    
Actually I am the developer, a noob one. :-) –  Joann Nov 27 '10 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 '10 at 19:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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