WordPress Toolkit – fix out of memory error when cloning a site

WordPress Toolkit is a great feature included with cPanel in our hosting accounts, allowing easy publication and management of WordPress websites. We are now able to offer WordPress Toolkit Deluxe, which provides a number of additional useful features, not least of which is the ability to clone a WordPress installation to create a staging site in a couple of clicks, with a new subdomain and database created automatically. However, we found a little catch which was resolved with just a little code…

To use WordPress Toolkit, log in to cPanel and find the WordPress Toolkit icon. Click here and then a list of WordPress installations is displayed. If WordPress Toolkit Deluxe is installed, extra options are available on each installation, including copy, clone and backup. This allows easy management of a staging site, allowing you to work on the staging site without disrupting a live website, and then copy your work to the live site when ready in a click or two.

However, when testing the clone feature, we came up against a snag. The clone process failed due to an error which indicated WordPress was out of memory; something like this:

[12-May-2022 16:30:28 UTC] PHP Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 32768 bytes) in /home/XXXXX/public_html/wp-includes/pomo/streams.php on line 180

This would typically be a simple fix: in cPanel, go to the MultiPHP INI Editor (this is, I should note, on the set up supplied with our hosting accounts, others may vary) and set memory_limit to a larger value, say 256M. However, this did not work as expected. Memory limits set in php.ini and .user.ini by this method were being ignored and the clone process continued to fail.

So to cut to the chase, some head scratching later, we discovered that setting the memory limit in the wp-config.php file did solve the problem and the clone process completed successfully. So for example, edit wp-config.php and add:

define('WP_MEMORY_LIMIT', '256M');

Further detail on memory limits relating to hosting environments for WordPress is available on the WP documentation at https://make.wordpress.org/hosting/handbook/performance/#memory-limits

Comments are closed.