Help - Invalid argument supplied for foreach()

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
KeithW
New php-forum User
New php-forum User
Posts: 1
Joined: Tue Mar 12, 2019 1:19 pm

Tue Mar 12, 2019 1:22 pm

Hi All,

Im new to here, so a big HI to all

I have been pulling my hair out trying to remove some errors from a wordpress plugin, the vendor says its fine but when you end up with log files over 40MB and have to delete each few days I'm not convinced

From the many lines of my log file I have these

[12-Mar-2019 20:48:23 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/xxxxxxx/public_html/wp-content/plugins/streamline-core/resortpro.php on line 202

Line starting 199 to 205 of the addressed file

Code: Select all

function streamshare_rewrite_rules(){
    $resortPro = ResortPro();
    $rules = $resortPro->ssml_routes_for_search_results_pages();
    foreach($rules as $page_s_id => $rule) {
        add_rewrite_rule(''.$rule.'/(.+)/?','index.php?page_id='.$page_s_id.'&stream_search=$matches[1]','top');
    }
}

Can anyone help me here

Regards

Keith

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 808
Joined: Mon Feb 22, 2016 5:52 pm

Tue Mar 12, 2019 2:52 pm

It looks like $rules is not iterable (can't be used in a foreach loop)

try

Code: Select all

echo gettype ($rules);
to see what you've got.

Post Reply