• Resolved alx359

    (@alx359)


    When trying to rename a bunch of 154 files the wait icon appeared but didn’t work, and got this error in debug.log:

    PHP Fatal error: Uncaught Error: An iterator cannot be used with foreach by reference in D:\domains\www.evitaworks.com\wp-content\plugins\phoenix-media-rename\class-media-rename.php:1279

    Tweaked the impeding code as below and it seems to work now:

    #alx359-->
    /*
    foreach($subj as &$item) {
           $item = self::replace_media_urls($item, $searches, $replaces);
    }
    */// https://stackoverflow.com/questions/29798586/
    foreach($subj as $key => $f) {
           $item = &$subj[$key];
           $item = self::replace_media_urls($item, $searches, $replaces);
    }
    #<--alx359

    Thanks.

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

    (@crossi72)

    Hi @alx359,
    I’ll check this as soon as possible, thank you for reporting and for the proposed solution.

    C.

    Plugin Author crossi72

    (@crossi72)

    Hi @alx359,
    I just released version 3.4.10 that implements your suggestion.

    I’ve never been able to reproduce the issue on my development server, so I can’t say if this resolves your problem, can you tell me if the issue persists?

    Thank you
    C.

    • This reply was modified 3 years, 1 month ago by crossi72.
    Thread Starter alx359

    (@alx359)

    Thanks @crossi72. Just did a quick test in my setup and 3.4.10 appears to be renaming fine. I was doing an overhaul and renamed a few hundred files after that fix, so it worked great, at least for me. I can’t take credit, btw; it just implements a stackoverflow answer I referred to in the OP code.

    Plugin Author crossi72

    (@crossi72)

    Hi @alx359,
    I’m glad that the new release has resolved your issue.

    I’ve made a good work: you searched and found a good solution, I only had to replace my code with the one you suggested, even if you found it on stackoverflow, you gave me the solution ??

    C.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP Fatal error: An iterator cannot be used with foreach by reference’ is closed to new replies.