Support » Plugin: Polylang » Invalid argument supplied for foreach() in .. polylang/include/mo.php on line 57

  • I updated to 1.2.1 recently. All looked okay from the plugin update screen and I didn’t look at my site after the update.
    Now that I do, I see a warning at the top of each page|post|index:

    Invalid argument supplied for foreach() in /var/www/vhosts/ on line 57

    The homepage is unavailable because of this warning (“headers already sent”); if I append “/nl” or “/en”, the languages that I use, I do get the respective homepages.

    From looking at the code, the line causing the warning is in import_from_db($lang):
    foreach (unserialize($post->post_content) as $msg). Could there be something wrong in the database causing unserialize to go “can’t do that”?

    In the database I notice inconsistent values for _translations keys:
    (post 346) s:37:"a:2:{s:2:"nl";i:346;s:2:"en";s:0:"";}";
    (post 359) a:2:{s:2:"nl";s:3:"359";s:2:"en";s:1:"0";}
    (post 733) a:2:{s:2:"nl";s:3:"733";s:2:"en";s:1:"0";}
    (post 765) a:2:{s:2:"en";i:765;s:2:"nl";i:0;}

    The first one is off, and I don’t know why. The last one is again different. Is this causing trouble?

    Most noticeable, though, is that all posts with type “image” have no language information anymore when looking at the posts overview.
    What can I do? Normalise the database values?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Chouby


    Please do not touch the database manually. There are risks to make something wrong.

    Did you make a database database backup before upgrade? If yes revert to 1.1.6 with your database backup.

    if no, make one. And follow this procedure to revert to 1.1.6:

    Reverting worked to get rid of the warning.

    Plugin Author Chouby


    Good. Have you the possibility to run a mirror test site to detect why the ugrade broke?

    I had the same problem. Reverting worked.

    Oddly enough, the upgrade inverted the problem reported here – only the first language showed the right color for the latest portfolio item on the home page, the second language (/en/) showing the default color instead.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Invalid argument supplied for foreach() in .. polylang/include/mo.php on line 57’ is closed to new replies.