MainWP Error Correction

Over at CyphersTECH, we use MainWP on a local server to check our customers’ WordPress installations.  It’s a great tool for keeping everything up-to-date, securing new installs, performing backups, and a lot more.  Lately, however, we began to notice an issue with one of our customer’s sites.

Some Background

MainWP adds a directory to each child site on which the Child Site plugin is installed on, at “/wp-content/uploads/mainwp”.  If anything should become amiss with this directory, MainWP is supposed to tell you to correct it.  But…what happens if the issue isn’t with the directory itself, but where WP thinks this directory should be?  See, it SHOULD fail gracefully and let you know, but it now fails in such a way that makes the child site’s dashboard entirely unusable.  It’s a BASE64 encoded string with the message, so you have absolutely no way of knowing exactly what’s happening.  It just looks like a long random string of letter and numbers with two equals signs at the end, like so (except much longer):


It’s only when we decode the string that we get the true error message, which will look something like this:

a:1:{s:5:”error”;s:154:”Unable to create directory /server/user/public_html/wp-content/uploads/mainwp/. Is its parent directory writable by the server?”;}

Once we have that, it’s clear the issue is caused by the plugin having trouble with that directory.

The Fix

The first thing to try is checking the permissions on the /wp-content/uploads/mainwp/ directory.  They should be 0755, and if they are, then that’s probably not the cause.  So, if they’re wrong and you reset them to 0755 and the issue vanishes, you’re good to go!

If the permissions are set properly and you still have the problem, then we need to get you back in to the WP dashboard for the next few steps.  So, to start with, connect to your site via FTP and delete the mainwp directory from /wp-content/plugins/.  Now, refreshing your dashboard, you should see what you normally expect to see: the dashboard.  Let’s go to Settings > Media on the left-hand navigation.  If there’s a misconfiguration, you’ll see a field at the bottom containing the path that we saw in the BASE64 decoded error message.  What we’re going to do here is change that value to match what it most likely should be (/wp-content/uploads/ as opposed to /server/user/public_html/uploads/).  Once you submit that change, check the home page of your site and verify that images you’ve previously uploaded via the Media manager are correctly loading.

If all of that worked, reinstall and reconnect the MainWP child on your child site, and you’re done!