One thing I often do is end up overseeing WordPress site updates, both to the WordPress core and to plugins. In theory this is an easy task, and a very important one especially security wise, but often people are reluctant do it. There’s one main reason and that is breaking things. Generally it doesn’t happen and the benefits of breaking a small section of a site are usually massively outweighed by not leaving a vulnerability in the site and getting hacked.
Of course a WordPress core update, especially to a new version needs a bit of planning, but a plugin update is usually trivial. However the issues that can occur were highlighted recently when I discovered a change in the Theme My Login plugin. This plugin allows WordPress site owners to setup login and registration forms that are powered by the site templates, thus keeping everything more focussed and on brand. In a recent version the developers have now removed automatic redirecting after login and have instead added this functionality as a paid for plugin. I’ll be honest I don’t think that’s a great idea and will annoy a lot of the user base for the plugin but I’m sure the developers have weighed up their thinking behind the decision. That said removing this core functionality essentially breaks the login process. You login and land on the same page with an empty login form, which would take an eagle eyed user to spot. So what to do? If you don’t wish to pay for the plugin then I would point you in the direction of this tutorial on Envato (https://code.tutsplus.com/series/build-a-custom-wordpress-user-flow–cms-816) It needs a little developer know how but there is a downloadable version you can grab from github on the article to get you going.
If you’ve been sensible and backed up you can always roll back and use an old version and continue on with that.
It is worth having a think through the options. But mainly I just wanted to point out the Envato tutorial for anyone who’s looking for a solution to this problem at the moment.
It’s a problem you should look to fix though, as mentioned at the start of the article, building up security issues is not worth it to save solving a few functionality issues.
I’ve been working on a third party API plugin for WordPress that requires a script that auto updates from the API. It consists of pulling a big list of items from the API and checking them against the local site entries, often adding new items or updating existing entries.
The problem was with a number of memory allocation errors with PHP as the script went on, often about half way through the execution. Memory exhausted and Fatal Allowed memory issues popping up. A memory limit change would fix the problem to a point, it would still leave issues though – to work through the full list of items would need a very high PHP memory limit and also what happens if the list gets bigger in future? When 64Mb stops being enough do we simply up it to 128Mb what about when that isn’t enough do we carry on upping it? That still leaves a period where errors are being thrown and updates are missed until it is picked up and the memory limit is upped.
I made sure I called wordpress without themes to reduce a little bit of load and a quick check through to make sure unset() was being used as it should be – I’ll admit my code discipline has been lax in the past with regards to this but as ever we are always learning and making sure that we can improve our techniques. Unsetting things properly to free up the memory is one of those things I now make sure I’m doing rather than just overwriting old variables.
So the script was unsetting as it should and with diligent debugging with php memory usage outputs it became apparent that it was around WordPress functions that the memory usage was going up and not being unset, gradually leading to the errors. Plenty of looking around and eventually I stumbled upon wp_cache_flush and it worked a treat – every time I went around a processing loop or finished a process I called the cache flush and it removed all the stuff WordPress had been storing. I’m sure this wouldn’t be the best fix all for every situation but it’s certainly something to be well aware of.
If you’ve made your way to the site since last night you’ll have seen the new look (a picture of the old one is above if you can’t remember it). I’m not sure if it would be classed as a redesign or realign, but it’s the biggest overhaul I’ve done in a while. I had a few new things I wanted to try out and I had some ideas that had sat around for ages, plus the site was seeming a little sluggish so I got stuck into it and decided to get it done at the weekend.