Skip to content

Instantly share code, notes, and snippets.

Last active November 11, 2022 20:11
Show Gist options
  • Save mbabker/d7bfb4e1e2fbc6b7815a733607f89281 to your computer and use it in GitHub Desktop.
Save mbabker/d7bfb4e1e2fbc6b7815a733607f89281 to your computer and use it in GitHub Desktop.

Post-Manual Update Script

If you have found yourself in a scenario where you cannot update Joomla! via the Joomla! Update Component and need to perform a manual update for any reason whatsoever, this script will assist with performing all necessary steps that would be taken after the update component runs the updates on the filesystem.

This script assumes that you have manually extracted the update package over your site and are ready to finish the update. You should trigger this script immediately after this process and before logging into your site's admin to do anything else, including the "database fix" routine.

To use this script, you should copy the postupdate.php file to your site's administrator directory. You can either access this script via a web request ( or from the command line interface (php /path/to/administrator/postupdate.php).

This script will run the "finalise" and "cleanup" steps from the update component, which performs such tasks as any database migrations and the removal of old files from your installation.

Once complete, you should immediately remove this script from your server.

* @package Joomla.Administrator
* @copyright Copyright (C) 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Define the application's minimum supported PHP version as a constant so it can be referenced within the application.
define('JOOMLA_MINIMUM_PHP', '5.3.10');
if (version_compare(PHP_VERSION, JOOMLA_MINIMUM_PHP, '<'))
die('Your host needs to use PHP ' . JOOMLA_MINIMUM_PHP . ' or higher to run this version of Joomla!');
* Constant that is checked in included files to prevent direct access.
* define() is used in the installation folder rather than "const" to not error for PHP 5.2 and lower
define('_JEXEC', 1);
// Load the administrator application's path constants
if (file_exists(__DIR__ . '/defines.php'))
include_once __DIR__ . '/defines.php';
if (!defined('_JDEFINES'))
define('JPATH_BASE', __DIR__);
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
require_once JPATH_BASE . '/includes/helper.php';
// Account for moved JToolbarHelper class in 3.9
if (file_exists(JPATH_BASE . '/includes/toolbar.php'))
require_once JPATH_BASE . '/includes/toolbar.php';
require_once JPATH_BASE . '/includes/subtoolbar.php';
// Boot JApplicationAdministrator so the application references in the factory resolve correctly.
// Set the component path (un)constants
define('JPATH_COMPONENT', JPATH_ADMINISTRATOR . '/components/com_joomlaupdate');
define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/com_joomlaupdate');
define('JPATH_COMPONENT_SITE', JPATH_SITE . '/components/com_joomlaupdate');
// Load the update component's model to run the cleanup methods
JModelLegacy::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/models', 'JoomlaupdateModel');
/** @var JoomlaupdateModelDefault $model */
$model = JModelLegacy::getInstance('default', 'JoomlaupdateModel');
// Make sure we got the model
if (!($model instanceof JoomlaupdateModelDefault))
echo 'Could not load update component model, please check the logs for additional details.' . PHP_EOL;
// Load up the logger
'format' => '{DATE}\t{TIME}\t{LEVEL}\t{CODE}\t{MESSAGE}',
'text_file' => 'joomla_update.php',
array('Update', 'databasequery', 'jerror')
JLog::add('Starting manual update using postupdate', JLog::INFO, 'Update');
// Load the Joomla library and update component language files
// Finalize the update
if ($model->finaliseUpgrade() === false)
echo 'Failed to finalize the upgrade, please check the logs for additional details.' . PHP_EOL;
// Cleanup after the update
JLog::add('Finished manual update using postupdate', JLog::INFO, 'Update');
echo 'Update to ' . JVERSION . ' completed successfully.' . PHP_EOL;
Copy link

Mbocha commented Jan 24, 2018

Thanks a Million!! with this I was able to update a client's website from 3.4 to 3.8.3. Be blessed!!

Copy link

markic commented Jan 25, 2018

Thank you very much. Fixed from 3.8 to 3.8.1 after 2 hours of google work! Awesome!

Copy link

I'm experiencing a failure when attempting to upgrade 3.7.4 to 3.8.5
After running the upgrade via joomla update, attempting to visit the site, I only get "ERROR" in typewriter font and nothing else.
I've tried dumping the upgrade folder into the existing folders but nothing changes at all.
I then ran the above referenced php script and the response is similar to - ...3.7.4 successfully upgraded
Running the upgrade again and repeat "ERROR" message

Copy link

I was upgrading from 3.7.5 to 3.8.5 and I was receiving a 500 error on the front-end and just a blank admin page. Now it's working fine. Thank you!

Copy link

Works with errors from3.4.x to 3.8.6, but when i login to administrator works 👍 , I fix the db from the administrator and i have my site working right now. Thank you very much!!!

XDebug (short):
Notice: Constant QQ already defined in /home/temaiken/public_html/net/libraries/src/Language/Language.php on line 18
Error: Call to undefined method JApplicationAdministrator::isClient() in /home/temaiken/public_html/net/libraries/src/Helper/ModuleHelper.php on line 411
Fatal error: Uncaught Error: Call to undefined method JApplicationAdministrator::isClient() in /home/temaiken/public_html/net/libraries/src/Helper/ModuleHelper.php on line 411
Error: Call to undefined method JApplicationAdministrator::isClient() in /home/temaiken/public_html/net/libraries/src/Helper/ModuleHelper.php on line 411

Copy link

luca7766 commented Mar 22, 2018

With update to 3.8.6 I get blank page and this error in page title title:
Error: 0 DirectoryIterator::__construct(/web/htdocs/[WEBSITE_FOLDER]/home/libraries/cms/installer/adapter): failed to open dir: No such file or directory

but the website v3.8.6 seems to work correctly, just have to fix DB

Copy link

Hello Everyone,
I have made the steps above but my admin joomla is still showing blank page with this error on top:

Error: Unknown column 'a.client_id' in 'where clause': Unknown column 'a.client_id' in 'where clause'

Please help.

Copy link

ajrange commented Apr 23, 2018

This is awesome, thank you so much!!!!!! Huge help!

Copy link

Hey mbabker,

Thank you very much it worked for me also, you save a lot of time :)


Copy link

Thanks, it worked for me,
first i get the error "adapter/ folder missing", after correct this issue (by copying folder and files),
the script worked for an update to Joomla! 3.8.7 Stable.

Copy link

after running this scriopt I got "Server Failure error 500" Doesn´t work for me . . . what do I wrong

Copy link

I removed htaccess and htpasswd from the admin folder, ran the script again - works. Have some warning, but I guess it is just about cleaning up a bit.
Thank you for the script!

Copy link

Thank you so much! I had updated from Joomla! 3.7.5 to 3.8.5 and received an "error: 500 failed to start application" on the backend. I ran your script, deleted the file, did the database fix and everything is working fine again. Thank you, thank you, thank you! You saved my day.

Copy link

Thanks for this great script! It saved me so much headache and basically my site as well

Copy link

oxyzium commented Jul 4, 2018


A big thanks.... really thanks a lot for saving my efforts and time.

I was upgrading Joomla from 3.3 to 3.8.0 all the upgrades worked fine.. but while upgrading the version from 3.7.5 to 3.8.0 both frontend and backend were showing blank pages.. all site was broken... using this script has resolved all the issues.

Copy link

Thank's you

Copy link

GOD bless you

Copy link

Very impressive.

Copy link

GrapGat commented Nov 28, 2018

I keep getting the HTTP 500 Error no matter what I try, I have tried the automatic update, the manual why described above, and still getting the same error. Am I doing something wrong?

Copy link

Line 39 require_once JPATH_BASE . '/includes/toolbar.php';
needs to be changed to
require_once JPATH_BASE . '/includes/subtoolbar.php';

Copy link

mbabker commented Dec 24, 2018

The script has been updated to account for the changes in 3.9.

Copy link

Legallity commented Dec 29, 2018

you forgot a ; at: require_once JPATH_BASE . '/includes/subtoolbar.php'

Copy link

also the script doesnt work for me, it still gives me the following error:
Error displaying the error page: Call to undefined method JLanguageHelper::parseIniFile(): Call to undefined method JLanguageHelper::parseIniFile()

Copy link

I have 6 Joomla sites of various ages and now transferring them to a new server running php7 so I need to upgrade. All have been successful using the manual system to upgrade to Joomla 3.9.4 except for one which is being stubborn. On running the postupdate.php script I am getting the following errors. Can anyone point me in the right direction please?

PHP Notice: Undefined index: HTTP_HOST in /var/www/HITACHI/gss/joomla_gss /libraries/joomla/application/web.php on line 869
PHP Notice: Undefined index: HTTP_HOST in /var/www/HITACHI/gss/joomla_gss /libraries/joomla/uri/uri.php on line 96

I am running the script using the command line via PUTTY.

Copy link

ghost commented May 6, 2019

Array to string conversion in /home/vol15_8/ on line 342

Copy link

Mister-A commented Aug 8, 2019

I love you 😄 ❤️

Saved my bacon, works a treat!

Copy link

Thank you Mike!
I am using this script (since 2016) in a complex multisite environment to automate the update for several dozen websites in one swoop - this saves me a ton of work!!!

Just one suggestion: you should include the "github" link within the sourcecode (as a comment) and maybe even a version number or "date-last-changed").

Copy link

where Postupdate. PHP is located? I searched in cpanel, but did not find it. Please help me

Copy link

Something similar for J4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment