Skip to content

Commit

Permalink
[imp] Handle DB errors in search plugins. Closes #6711. Closes #6714. C…
Browse files Browse the repository at this point in the history
…loses #6715. Closes #6716. Closes #6717. Closes #7073.
  • Loading branch information
alikon authored and Thomas Hunziker committed Jun 16, 2015
1 parent a05e149 commit 06b38e2
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 7 deletions.
11 changes: 10 additions & 1 deletion plugins/editors/tinymce/tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,16 @@ public function onInit()
->where('client_id=0 AND home=' . $db->quote('1'));

$db->setQuery($query);
$template = $db->loadResult();
try
{
$template = $db->loadResult();
}
catch (RuntimeException $e)
{
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
JLog::add($e->getMessage(), JLog::ERROR, 'controller');
return;
}

$content_css = '';
$templates_path = JPATH_SITE . '/templates';
Expand Down
11 changes: 10 additions & 1 deletion plugins/search/categories/categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,16 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu
}

$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();
try
{
$rows = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$rows = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
JLog::add($e->getMessage(), JLog::ERROR, 'controller');
}

$return = array();

Expand Down
12 changes: 11 additions & 1 deletion plugins/search/contacts/contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,17 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu
}

$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();

try
{
$rows = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$rows = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
JLog::add($e->getMessage(), JLog::ERROR, 'controller');
}

if ($rows)
{
Expand Down
22 changes: 20 additions & 2 deletions plugins/search/content/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,16 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu
}

$db->setQuery($query, 0, $limit);
$list = $db->loadObjectList();
try
{
$list = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$list = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
JLog::add($e->getMessage(), JLog::ERROR, 'controller');
}
$limit -= count($list);

if (isset($list))
Expand Down Expand Up @@ -251,7 +260,16 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu
}

$db->setQuery($query, 0, $limit);
$list3 = $db->loadObjectList();
try
{
$list3 = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$list3 = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
JLog::add($e->getMessage(), JLog::ERROR, 'controller');
}

// Find an itemid for archived to use if there isn't another one.
$item = $app->getMenu()->getItems('link', 'index.php?option=com_content&view=archive', true);
Expand Down
11 changes: 10 additions & 1 deletion plugins/search/newsfeeds/newsfeeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,16 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu
}

$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();
try
{
$rows = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$rows = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
JLog::add($e->getMessage(), JLog::ERROR, 'controller');
}

if ($rows)
{
Expand Down
11 changes: 10 additions & 1 deletion plugins/search/tags/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,16 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu
$query->order($order);

$db->setQuery($query, 0, $limit);
$rows = $db->loadObjectList();
try
{
$rows = $db->loadObjectList();
}
catch (RuntimeException $e)
{
$rows = array();
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
JLog::add($e->getMessage(), JLog::ERROR, 'controller');
}

if ($rows)
{
Expand Down

0 comments on commit 06b38e2

Please sign in to comment.