Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Commit

Permalink
The template install adapter never return an existing extension id (s…
Browse files Browse the repository at this point in the history
…etQuery was not set). Updated query with exception and direct rollback.
  • Loading branch information
hieblmedia committed Jan 21, 2012
1 parent 216102d commit f2eefd8
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions libraries/joomla/installer/adapters/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public function loadLanguage($path = null)
*/
public function install()
{
// Get a database connector object
$db = $this->parent->getDbo();

$lang = JFactory::getLanguage();
$xml = $this->parent->getManifest();

Expand Down Expand Up @@ -108,13 +111,25 @@ public function install()
$element = strtolower(str_replace(" ", "_", $name));
$this->set('name', $name);
$this->set('element', $element);

$db = $this->parent->getDbo();
// Check to see if a template by the same name is already installed.
$query = $db->getQuery(true);
$query->select($db->quoteName('extension_id'));
$query->from($db->quoteName('#__extensions'));
$query->where($db->quoteName('type') . ' = ' . $db->quote('template'));
$query->where($db->quoteName('element') . ' = ' . $element);
$query->select($query->qn('extension_id'))->from($query->qn('#__extensions'));
$query->where($query->qn('type') . ' = ' . $query->q('template'));
$query->where($query->qn('element') . ' = ' . $query->q($element));
$db->setQuery($query);

try
{
$db->Query();
}
catch (JException $e)

This comment has been minimized.

Copy link
@realityking

realityking Jan 26, 2012

Contributor

Probably better to catch the specific extension thrown.

{
// Install failed, roll back changes
$this->parent
->abort(JText::sprintf('JLIB_INSTALLER_ABORT_PLG_INSTALL_ROLLBACK', JText::_('JLIB_INSTALLER_' . $this->route), $db->stderr(true)));
return false;
}
$id = $db->loadResult();

// Set the template root path
Expand Down

1 comment on commit f2eefd8

@realityking
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is enough, the platform still supports the legacy error handling and this doesn't account for it.

Please sign in to comment.