• Replacing the links on every page is a very process intensive feature.

    With the latest update, now your script is ALWAYS searching through every single post in our database, even when we do not choose to rename the file. This causes the latest version to *always* fail for our users, so we do not use it, and I created CSS hacks to hide this feature.

    It would be helpful if we could disable this non-working feature (rename / replace links), until it is fixed for large sites. Possible?

    At this point, I needed to fix it using the hacks seen in the screenshots here, and lock the updates until I hear from you:

    Disable replacer: https://drive.google.com/file/d/1ptbh4omKrAPY0cmD7cz9EsIdeflB5jqq/view?usp=sharing

    CSS cover ups: https://drive.google.com/file/d/1pzjO7f3H-lCHczPkz8N03onL0LW_5fvo/view?usp=sharing

    1. When not using the search-replace function, there does not appear to be any reason your code (Replacer.php – line 200) should be doing a search-replace on the entire posts table, when it has nothing to change – can you please fix?
    2. We would love to also use the link search-replacer feature, and be able to rename the file being replaced. As mentioned, it fails and times out every time, when trying to search through 20k+ pages which are very link-heavy. Have you considered using a cron process and background processing for the doReplaceQuery function? This could be the solution for you, here are some examples of ays for you to improve the script so it doesn’t time out on large sites:

      https://github.com/deliciousbrains/wp-background-processing
      https://deliciousbrains.com/background-processing-wordpress/
      OR
      https://florianbrinkmann.com/en/background-processes-wordpress-4579/

    Looking forward to hearing from you. #1 above is a blocker for us to update the plugin, so your urgent review would be most helpful, please and thanks!

    Happy to answer any questions or provide more details – Hope this helps!

    Cheers!
    Terrance

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Pedro

    (@petredobrescu)

    Hello Terrance,

    With the latest update, now your script is ALWAYS searching through every single post in our database, even when we do not choose to rename the file. This causes the latest version to always fail for our users, so we do not use it, and I created CSS hacks to hide this feature.

    We’ll look into this and get back on this thread.

    With regards to your other suggestion, please keep in mind that this is a free plugin where we always welcome Pull Requests on our public GitHub repository:

    https://github.com/short-pixel-optimizer/enable-media-replace/

    I would be more than happy to review a PR with the improvement you suggested above!

    Thanks again

    Thread Starter Earthman Media

    (@earthman100)

    We’ll look into this and get back on this thread.

    Perfect, thank you, much appreciated – would be great to not have to add that line to disable that function with each update.

    Plugin Author Pedro

    (@petredobrescu)

    Hello again @earthman100,

    After doing some checks I can explain what happens when choosing to replace the media and keep the same filename:

    • when the media replacement is done with a file having exactly the same dimensions as the previous file, then there won’t be any replacement/query done (because all thumbs should normally be the same). There is a check in our plugin for that situation and most likely this is what happened before when the replacement didn’t time out (the code didn’t really change around that part).
    • however, if the new media file has different sizes (and especially different aspect ratio), the plugin will do these replaces in the DB because the thumbnails will most likely have different sizes. And the plugin has a mechanism to check and match the old thumbnails with the closest one in size from the new image thumbnails.

    We’ll see if moving the replacement to a cron is feasible because on small sites, where the cron jobs could only be triggered by visits to the public sites, this might not work at all and bring more trouble. If you have a more clear idea about how to implement this for your use case, please submit a Pull Request and we’ll happily review it!

    Thank you!

    Thread Starter Earthman Media

    (@earthman100)

    Hi @petredobrescu

    Thanks for the detailed description, that makes sense.

    However, this was for a linked .pdf file, not an image. That is what most of these operations will be for, for our users – replacing pdf’s. No change in external dimensions.

    Also, all of our images are constrained to specific sizes, in teh WP theme. So, theoretically speaking, there should never be a change in image dimensions too, unless in the very edge case where an image is smaller than the smallest thumbnail size

    In these cases, which cover most of our use cases – Should it still be searching through every post?

    I wonder if, rather than jumping on to cron / background processing right away, can you optimize perhaps with just some filters for the use cases I mention here?

    Do these use cases make sense?

    giuscia

    (@gsciaccaglaucoit)

    I also encountered the same problem on a large site. I forked the plugin on git-hub and asked you for a pull request.

    https://github.com/short-pixel-optimizer/enable-media-replace/pull/99/commits/37cf6490a1e5e89dc191a8dc37f576454d475d07

    I simply ask you to add an apply_filters, although in my opinion you could add an option so that the user can declare that he does not want any replace in the contents.



Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Media Replacer times out on large site’ is closed to new replies.