Skip to content

Commit

Permalink
Tweak the finaliseUpgrade step for the manifest change
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Babker committed Mar 14, 2016
1 parent d9264d8 commit bccb2c3
Showing 1 changed file with 25 additions and 54 deletions.
79 changes: 25 additions & 54 deletions administrator/components/com_joomlaupdate/models/default.php
Expand Up @@ -541,52 +541,42 @@ public function finaliseUpgrade()
{
$installer = JInstaller::getInstance();

$installer->setPath('source', JPATH_ROOT);
$installer->setPath('extension_root', JPATH_ROOT);
$manifest = $installer->isManifest(JPATH_MANIFESTS . '/files/joomla.xml');

if (!$installer->setupInstall())
if ($manifest === false)
{
$installer->abort(JText::_('JLIB_INSTALLER_ABORT_DETECTMANIFEST'));

return false;
}

$installer->manifest = $manifest;

$installer->setUpgrade(true);
$installer->setOverwrite(true);

$installer->extension = JTable::getInstance('extension');
$installer->extension->load(700);

$installer->setAdapter($installer->extension->type);

$manifest = $installer->getManifest();
$installer->setPath('manifest', JPATH_MANIFESTS . '/files/joomla.xml');
$installer->setPath('source', JPATH_MANIFESTS . '/files');
$installer->setPath('extension_root', JPATH_ROOT);

$manifestPath = JPath::clean($installer->getPath('manifest'));
$element = preg_replace('/\.xml/', '', basename($manifestPath));

// Run the script file.
$manifestScript = (string) $manifest->scriptfile;

if ($manifestScript)
{
$manifestScriptFile = JPATH_ROOT . '/' . $manifestScript;

if (is_file($manifestScriptFile))
{
// Load the file.
include_once $manifestScriptFile;
}
JLoader::register('JoomlaInstallerScript', JPATH_ADMINISTRATOR . '/components/com_admin/script.php');

$classname = 'JoomlaInstallerScript';

if (class_exists($classname))
{
$manifestClass = new $classname($this);
}
}
$manifestClass = new JoomlaInstallerScript;

ob_start();
ob_implicit_flush(false);

if ($manifestClass && method_exists($manifestClass, 'preflight'))
{
if ($manifestClass->preflight('update', $this) === false)
if ($manifestClass->preflight('update', $installer) === false)
{
$installer->abort(JText::_('JLIB_INSTALLER_ABORT_FILE_INSTALL_CUSTOM_INSTALL_FAILURE'));

Expand Down Expand Up @@ -622,7 +612,7 @@ public function finaliseUpgrade()
{
// Install failed, roll back changes.
$installer->abort(
JText::sprintf('JLIB_INSTALLER_ABORT_FILE_ROLLBACK', JText::_('JLIB_INSTALLER_UPDATE'), $db->stderr(true))
JText::sprintf('JLIB_INSTALLER_ABORT_FILE_ROLLBACK', JText::_('JLIB_INSTALLER_UPDATE'), $e->getMessage())
);

return false;
Expand All @@ -646,7 +636,7 @@ public function finaliseUpgrade()
{
// Install failed, roll back changes.
$installer->abort(
JText::sprintf('JLIB_INSTALLER_ABORT_FILE_ROLLBACK', JText::_('JLIB_INSTALLER_UPDATE'), $db->stderr(true))
JText::sprintf('JLIB_INSTALLER_ABORT_FILE_ROLLBACK', JText::_('JLIB_INSTALLER_UPDATE'), $row->getError())
);

return false;
Expand All @@ -672,7 +662,7 @@ public function finaliseUpgrade()
if (!$row->store())
{
// Install failed, roll back changes.
$installer->abort(JText::sprintf('JLIB_INSTALLER_ABORT_FILE_INSTALL_ROLLBACK', $db->stderr(true)));
$installer->abort(JText::sprintf('JLIB_INSTALLER_ABORT_FILE_INSTALL_ROLLBACK', $row->getError()));

return false;
}
Expand All @@ -685,20 +675,14 @@ public function finaliseUpgrade()
$installer->pushStep(array('type' => 'extension', 'extension_id' => $row->extension_id));
}

/*
* Let's run the queries for the file.
*/
if ($manifest->update)
{
$result = $installer->parseSchemaUpdates($manifest->update->schemas, $row->extension_id);
$result = $installer->parseSchemaUpdates($manifest->update->schemas, $row->extension_id);

if ($result === false)
{
// Install failed, rollback changes.
$installer->abort(JText::sprintf('JLIB_INSTALLER_ABORT_FILE_UPDATE_SQL_ERROR', $db->stderr(true)));
if ($result === false)
{
// Install failed, rollback changes.
$installer->abort(JText::sprintf('JLIB_INSTALLER_ABORT_FILE_UPDATE_SQL_ERROR', $db->stderr(true)));

return false;
}
return false;
}

// Start Joomla! 1.6.
Expand All @@ -720,23 +704,10 @@ public function finaliseUpgrade()
$msg .= ob_get_contents();
ob_end_clean();

// Lastly, we will copy the manifest file to its appropriate place.
$manifest = array();
$manifest['src'] = $installer->getPath('manifest');
$manifest['dest'] = JPATH_MANIFESTS . '/files/' . basename($installer->getPath('manifest'));

if (!$installer->copyFiles(array($manifest), true))
{
// Install failed, rollback changes.
$installer->abort(JText::_('JLIB_INSTALLER_ABORT_FILE_INSTALL_COPY_SETUP'));

return false;
}

// Clobber any possible pending updates.
$update = JTable::getInstance('update');
$uid = $update->find(
array('element' => $element, 'type' => 'file', 'client_id' => '0', 'folder' => '')
array('element' => 'joomla', 'type' => 'file', 'client_id' => '0', 'folder' => '')
);

if ($uid)
Expand All @@ -750,7 +721,7 @@ public function finaliseUpgrade()

if ($manifestClass && method_exists($manifestClass, 'postflight'))
{
$manifestClass->postflight('update', $this);
$manifestClass->postflight('update', $installer);
}

// Append messages.
Expand Down

0 comments on commit bccb2c3

Please sign in to comment.