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

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