Skip to content

Instantly share code, notes, and snippets.

Last active Jun 15, 2022
What would you like to do?

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

BlueViewConsulting commented Dec 28, 2017

Guys please help... not a fundi at this.

Upgraded to 3.8.3

When i launch me WEBSITE I get.... 'DIRECT ACCESS TO THIS LOCATION IS NOT ALLOWED' ... "Error messages Error:1054 Unkown column ‘a.client_id’ in ‘where clause’.

When i try and fix my database I get ' 1709 Index column size too large. The maximum column size is 767 bytes.'

When I apply the postupdate.php in phpMYADMIN I get definition error where "#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near"... see attachment...

I am at a loss....

Gary B

Copy link

vale82on commented Jan 9, 2018

Dear Michael, I found your script because I got an error 1054 (control panel blocked) after running the automatic upgrade from joomla 3.5.1 to 3.6.5.
I downloaded and launched your script, but unfortunately I got the error message: Failed to finalize the upgrade, please check the logs for additional details.
Here are the logs, I wasn't able to get any help from the logs:

#Fields: datetime	priority clientip	category	message
2018-01-09T19:14:51+00:00	INFO	update	Update started by user Super User (6306). Old version is 3.5.1.
2018-01-09T19:14:51+00:00	INFO	update	Downloading update file from
2018-01-09T19:15:04+00:00	INFO	update	File successfully downloaded.
2018-01-09T19:15:04+00:00	INFO	update	Starting installation of new version.
2018-01-09T19:17:12+00:00	INFO	update	Finalising installation.
2018-01-09T19:17:12+00:00	INFO	update	Cleaning up after installation.
2018-01-09T19:17:12+00:00	INFO	update	Update to version 3.6.5 is complete.
2018-01-09T19:18:18+00:00	INFO	update	Update started by user Super User (6306). Old version is 3.6.5.
2018-01-09T19:18:18+00:00	INFO	update	Downloading update file from
2018-01-09T19:18:24+00:00	INFO	update	File successfully downloaded.
2018-01-09T19:18:24+00:00	INFO	update	Starting installation of new version.
2018-01-09T19:19:39+00:00	INFO	update	Finalising installation.
2018-01-09T19:19:39+00:00	INFO	update	Cleaning up after installation.
2018-01-09T19:19:39+00:00	INFO	update	Update to version 3.8.3 is complete.
2018-01-09T19:42:39+00:00	INFO	update	Starting manual update using postupdate
2018-01-09T19:42:39+00:00	INFO	update	Finalising installation.

I don't know what to do. Should I try a manual upgrade? But how if the control panel is blocked? Thanks!

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

Rational-Storm commented Feb 23, 2018

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

rapid1004 commented Mar 5, 2018

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

alejoasotelo commented Mar 15, 2018

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

panter011 commented Apr 4, 2018

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

verosandri commented May 1, 2018

Hey mbabker,

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


Copy link

nympheastudio commented May 3, 2018

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

OESternad commented May 12, 2018

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

Copy link

OESternad commented May 12, 2018

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

Chris2508 commented May 15, 2018

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

xander182 commented Jun 29, 2018

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

invent-studio commented Jul 25, 2018

Thank's you

Copy link

invent-studio commented Jul 25, 2018

GOD bless you

Copy link

LazarBaruk commented Oct 3, 2018

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

schultz-it-solutions commented Nov 30, 2018

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

Legallity commented Dec 29, 2018

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

scoutdubna commented May 5, 2019

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

schultz-it-solutions commented Jan 29, 2020

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

gistamelandy commented Jul 16, 2020

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

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