Merge branch 'bugfix/do-not-use-count-queries-for-emptiness-checks-9632'

fixes #9632
This commit is contained in:
Johannes Meyer 2015-08-03 16:46:44 +02:00
commit 66edf55ca6
20 changed files with 185 additions and 167 deletions

View File

@ -26,7 +26,10 @@ if (! isset($backend)) {
$reducible = $this->hasPermission('config/authentication/groups/remove') && $backend instanceof Reducible; $reducible = $this->hasPermission('config/authentication/groups/remove') && $backend instanceof Reducible;
} }
if (count($groups) > 0): ?> $firstRow = true;
foreach ($groups as $group): ?>
<?php if ($firstRow): ?>
<?php $firstRow = false; ?>
<table data-base-target="_next" class="action group-list alternating"> <table data-base-target="_next" class="action group-list alternating">
<thead> <thead>
<tr> <tr>
@ -37,7 +40,7 @@ if (count($groups) > 0): ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($groups as $group): ?> <?php endif ?>
<tr> <tr>
<td class="group-name"><?= $this->qlink($group->group_name, 'group/show', array( <td class="group-name"><?= $this->qlink($group->group_name, 'group/show', array(
'backend' => $backend->getName(), 'backend' => $backend->getName(),
@ -62,7 +65,8 @@ if (count($groups) > 0): ?>
</td> </td>
<?php endif ?> <?php endif ?>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>
<?php if ($groups->hasResult()): ?>
</tbody> </tbody>
</table> </table>
<?php else: ?> <?php else: ?>

View File

@ -49,7 +49,12 @@ if ($this->hasPermission('config/authentication/groups/edit') && $backend instan
<?php endif ?> <?php endif ?>
</div> </div>
<div class="content members" data-base-target="_next"> <div class="content members" data-base-target="_next">
<?php if (count($members) > 0): ?> <?php
$firstRow = true;
foreach ($members as $member): ?>
<?php if ($firstRow): ?>
<?php $firstRow = false; ?>
<table data-base-target="_next" class="action member-list"> <table data-base-target="_next" class="action member-list">
<thead> <thead>
<tr> <tr>
@ -60,7 +65,7 @@ if ($this->hasPermission('config/authentication/groups/edit') && $backend instan
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($members as $member): ?> <?php endif ?>
<tr> <tr>
<td class="member-name"><?= $this->escape($member->user_name); ?></td> <td class="member-name"><?= $this->escape($member->user_name); ?></td>
<?php if (isset($removeForm)): ?> <?php if (isset($removeForm)): ?>
@ -69,7 +74,8 @@ if ($this->hasPermission('config/authentication/groups/edit') && $backend instan
</td> </td>
<?php endif ?> <?php endif ?>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>
<?php if ($members->hasResult()): ?>
</tbody> </tbody>
</table> </table>
<?php else: ?> <?php else: ?>

View File

@ -26,7 +26,10 @@ if (! isset($backend)) {
$reducible = $this->hasPermission('config/authentication/users/remove') && $backend instanceof Reducible; $reducible = $this->hasPermission('config/authentication/users/remove') && $backend instanceof Reducible;
} }
if (count($users) > 0): ?> $firstRow = true;
foreach ($users as $user): ?>
<?php if ($firstRow): ?>
<?php $firstRow = false; ?>
<table data-base-target="_next" class="action user-list alternating"> <table data-base-target="_next" class="action user-list alternating">
<thead> <thead>
<tr> <tr>
@ -37,7 +40,7 @@ if (count($users) > 0): ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($users as $user): ?> <?php endif ?>
<tr> <tr>
<td class="user-name"><?= $this->qlink($user->user_name, 'user/show', array( <td class="user-name"><?= $this->qlink($user->user_name, 'user/show', array(
'backend' => $backend->getName(), 'backend' => $backend->getName(),
@ -62,7 +65,8 @@ if (count($users) > 0): ?>
</td> </td>
<?php endif ?> <?php endif ?>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>
<?php if ($users->hasResult()): ?>
</tbody> </tbody>
</table> </table>
<?php else: ?> <?php else: ?>

View File

@ -52,7 +52,12 @@ if ($this->hasPermission('config/authentication/users/edit') && $backend instanc
<?php endif ?> <?php endif ?>
</div> </div>
<div class="content memberships"> <div class="content memberships">
<?php if (count($memberships) > 0): ?> <?php
$firstRow = true;
foreach ($memberships as $membership): ?>
<?php if ($firstRow): ?>
<?php $firstRow = false; ?>
<table data-base-target="_next" class="action membership-list alternating"> <table data-base-target="_next" class="action membership-list alternating">
<thead> <thead>
<tr> <tr>
@ -61,7 +66,7 @@ if ($this->hasPermission('config/authentication/users/edit') && $backend instanc
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($memberships as $membership): ?> <?php endif ?>
<tr> <tr>
<td class="membership-group"> <td class="membership-group">
<?php if ($this->hasPermission('config/authentication/groups/show') && $membership->backend instanceof Selectable): ?> <?php if ($this->hasPermission('config/authentication/groups/show') && $membership->backend instanceof Selectable): ?>
@ -86,7 +91,8 @@ if ($this->hasPermission('config/authentication/users/edit') && $backend instanc
<?php endif ?> <?php endif ?>
</td> </td>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>
<?php if ($memberships->hasResult()): ?>
</tbody> </tbody>
</table> </table>
<?php else: ?> <?php else: ?>

View File

@ -158,7 +158,7 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
} }
$this->iterator->rewind(); $this->iterator->rewind();
$this->iteratorPosition = 0; $this->iteratorPosition = null;
Benchmark::measure('Query result iteration started'); Benchmark::measure('Query result iteration started');
} }
@ -190,6 +190,8 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
if (! $valid) { if (! $valid) {
Benchmark::measure('Query result iteration finished'); Benchmark::measure('Query result iteration finished');
return false; return false;
} elseif ($this->iteratorPosition === null) {
$this->iteratorPosition = 0;
} }
return true; return true;
@ -420,6 +422,16 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
return $this->hasMore; return $this->hasMore;
} }
/**
* Return whether this query will or has yielded any result
*
* @return bool
*/
public function hasResult()
{
return $this->iteratorPosition !== null || $this->fetchRow() !== false;
}
/** /**
* Set a limit count and offset to the query * Set a limit count and offset to the query
* *

View File

@ -367,6 +367,16 @@ class RepositoryQuery implements QueryInterface, SortRules, Iterator
return $this->query->hasMore(); return $this->query->hasMore();
} }
/**
* Return whether this query will or has yielded any result
*
* @return bool
*/
public function hasResult()
{
return $this->query->hasResult();
}
/** /**
* Limit this query's results * Limit this query's results
* *

View File

@ -368,7 +368,7 @@ class Monitoring_ListController extends Controller
$this->view->filter = Filter::fromQuerystring((string) $this->params); $this->view->filter = Filter::fromQuerystring((string) $this->params);
$query->applyFilter($this->view->filter); $query->applyFilter($this->view->filter);
$this->applyRestriction('monitoring/filter/objects', $query); $this->applyRestriction('monitoring/filter/objects', $query);
$this->view->summary = $query->getQuery()->fetchAll(); $this->view->summary = $query;
$this->view->column = $form->getValue('state'); $this->view->column = $form->getValue('state');
// $this->view->orientationBox = $orientationBox; // $this->view->orientationBox = $orientationBox;
$this->view->orientation = $orientation; $this->view->orientation = $orientation;

View File

@ -2,6 +2,19 @@
use Icinga\Module\Monitoring\Object\Host; use Icinga\Module\Monitoring\Object\Host;
use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Service;
function contactsLink($match, $view) {
$links = array();
foreach (preg_split('/,\s/', $match[1]) as $contact) {
$links[] = $view->qlink(
$contact,
'monitoring/show/contact',
array('contact_name' => $contact),
array('title' => sprintf($view->translate('Show detailed information about %s'), $contact))
);
}
return '[' . implode(', ', $links) . ']';
}
$self = $this; $self = $this;
if (! $this->compact): ?> if (! $this->compact): ?>
@ -16,29 +29,6 @@ if (! $this->compact): ?>
</div> </div>
<?php endif ?> <?php endif ?>
<div class="content"> <div class="content">
<?php
if (count($history) === 0) {
echo $this->translate('No history events found matching the filter') . '</div>';
return;
}
?>
<?php
function contactsLink($match, $view) {
$links = array();
foreach (preg_split('/,\s/', $match[1]) as $contact) {
$links[] = $view->qlink(
$contact,
'monitoring/show/contact',
array('contact_name' => $contact),
array('title' => sprintf($view->translate('Show detailed information about %s'), $contact))
);
}
return '[' . implode(', ', $links) . ']';
}
?>
<table data-base-target="_next" class="action objecthistory"> <table data-base-target="_next" class="action objecthistory">
<tbody> <tbody>
<?php foreach ($history as $event): ?> <?php foreach ($history as $event): ?>
@ -144,7 +134,10 @@ function contactsLink($match, $view) {
</div> </div>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php if (! $history->hasResult()): ?>
<?= $this->translate('No history events found matching the filter'); ?>
<?php endif ?>
</div> </div>

View File

@ -12,13 +12,6 @@
</div> </div>
<?php endif ?> <?php endif ?>
<div class="content"> <div class="content">
<?php
if (count($comments) === 0) {
echo $this->translate('No comments found matching the filter') . '</div>';
return;
}
?>
<table data-base-target="_next" <table data-base-target="_next"
class="action comments multiselect" class="action comments multiselect"
data-icinga-multiselect-url="/icingaweb2/monitoring/comments/show" data-icinga-multiselect-url="/icingaweb2/monitoring/comments/show"
@ -91,4 +84,7 @@ if (count($comments) === 0) {
<?php endforeach ?> <?php endforeach ?>
</tbody> </tbody>
</table> </table>
<?php if (! $comments->hasResult()): ?>
<?= $this->translate('No comments found matching the filter'); ?>
<?php endif ?>
</div> </div>

View File

@ -8,14 +8,7 @@
</div> </div>
<?php endif ?> <?php endif ?>
<div data-base-target="_next" class="content contacts"> <div data-base-target="_next" class="content contacts">
<?php <?php foreach ($contacts as $contact): ?>
if (count($contacts) === 0) {
echo $this->translate('No contacts found matching the filter') . '</div>';
return;
}
?>
<?php foreach ($contacts as $contact): ?>
<div class="contact"> <div class="contact">
<?= $this->img('/static/gravatar', array('email' => $contact->contact_email)); ?> <?= $this->img('/static/gravatar', array('email' => $contact->contact_email)); ?>
<strong><?= $this->qlink( <strong><?= $this->qlink(
@ -59,4 +52,7 @@ if (count($contacts) === 0) {
if (true): /* The following piece of HTML MUST be nested in <?php */ ?> if (true): /* The following piece of HTML MUST be nested in <?php */ ?>
<div style="clear: both;"></div> <div style="clear: both;"></div>
<?php endif; ?> <?php endif; ?>
<?php if (! $contacts->hasResult()): ?>
<?= $this->translate('No contacts found matching the filter'); ?>
<?php endif ?>
</div> </div>

View File

@ -16,14 +16,6 @@ if (! $this->compact): ?>
</div> </div>
<?php endif ?> <?php endif ?>
<div class="content"> <div class="content">
<?php
if (count($downtimes) === 0) {
echo $this->translate('No downtimes found matching the filter,'
. ' maybe the downtime already expired.') . '</div>';
return;
}
?>
<table data-base-target="_next" <table data-base-target="_next"
class="action multiselect" class="action multiselect"
data-icinga-multiselect-url="/icingaweb2/monitoring/downtimes/show" data-icinga-multiselect-url="/icingaweb2/monitoring/downtimes/show"
@ -143,4 +135,7 @@ if (count($downtimes) === 0) {
<?php endforeach ?> <?php endforeach ?>
</tbody> </tbody>
</table> </table>
<?php if (! $downtimes->hasResult()): ?>
<?= $this->translate('No downtimes found matching the filter, maybe the downtime already expired.'); ?>
<?php endif ?>
</div> </div>

View File

@ -15,11 +15,6 @@ if (! $this->compact): ?>
<div class="content" data-base-target="_next"> <div class="content" data-base-target="_next">
<?php <?php
if (count($summary) === 0) {
echo $this->translate('No state changes in the selected time period.') . '</div>';
return;
}
$settings = array( $settings = array(
'cnt_up' => array( 'cnt_up' => array(
'tooltip' => $this->translate('%d hosts ok on %s'), 'tooltip' => $this->translate('%d hosts ok on %s'),
@ -60,14 +55,6 @@ $settings = array(
) )
); );
$from = intval($form->getValue('from', strtotime('3 months ago')));
$to = intval($form->getValue('to', time()));
// don't display more than ten years, or else this will get really slow
if ($to - $from > 315360000) {
$from = $to - 315360000;
}
$data = array(); $data = array();
foreach ($summary as $entry) { foreach ($summary as $entry) {
$day = $entry->day; $day = $entry->day;
@ -90,6 +77,19 @@ foreach ($summary as $entry) {
); );
} }
if (! $summary->hasResult()) {
echo $this->translate('No state changes in the selected time period.') . '</div>';
return;
}
$from = intval($form->getValue('from', strtotime('3 months ago')));
$to = intval($form->getValue('to', time()));
// don't display more than ten years, or else this will get really slow
if ($to - $from > 315360000) {
$from = $to - 315360000;
}
$f = new DateTime(); $f = new DateTime();
$f->setTimestamp($from); $f->setTimestamp($from);
$t = new DateTime(); $t = new DateTime();
@ -117,11 +117,11 @@ for ($i = 0; $i < $diff->days; $i += $step) {
} }
?> ?>
<div style="width: 33.5em;"> <div style="width: 33.5em;">
<? foreach (array_reverse($grids) as $key => $grid) { ?> <?php foreach (array_reverse($grids) as $key => $grid): ?>
<div style=" <?= $this->orientation === 'horizontal' ? '' : 'display: inline-block; vertical-align: top; top; margin: 0.5em;' ?>"> <div style=" <?= $this->orientation === 'horizontal' ? '' : 'display: inline-block; vertical-align: top; top; margin: 0.5em;' ?>">
<?= $grid; ?> <?= $grid; ?>
<?= $this->orientation === 'horizontal' ? '<br />' : '' ?> <?= $this->orientation === 'horizontal' ? '<br />' : '' ?>
</div> </div>
<? } ?> <?php endforeach ?>
</div> </div>
</div> </div>

View File

@ -12,12 +12,6 @@ if (! $this->compact): ?>
</div> </div>
<?php endif ?> <?php endif ?>
<div class="content"> <div class="content">
<?php
if (count($history) === 0) {
echo $this->translate('No history events found matching the filter') . '</div>';
return;
}
?>
<table data-base-target="_next" class="action"> <table data-base-target="_next" class="action">
<tbody> <tbody>
<?php foreach ($history as $event): ?> <?php foreach ($history as $event): ?>
@ -96,4 +90,7 @@ if (count($history) === 0) {
<?php endforeach ?> <?php endforeach ?>
</tbody> </tbody>
</table> </table>
<?php if (! $history->hasResult()): ?>
<?= $this->translate('No history events found matching the filter'); ?>
<?php endif ?>
</div> </div>

View File

@ -13,11 +13,10 @@ if (! $this->compact): ?>
<div class="content"> <div class="content">
<?php <?php
if (count($hostgroups) === 0) { $firstRow = true;
echo $this->translate('No hostgroups found matching the filter') . '</div>'; foreach ($hostgroups as $h): ?>
return; <?php if ($firstRow): ?>
} <?php $firstRow = false; ?>
?>
<table class="groupview action" data-base-target="_next"> <table class="groupview action" data-base-target="_next">
<thead> <thead>
<th><?= $this->translate('Last Problem'); ?></th> <th><?= $this->translate('Last Problem'); ?></th>
@ -28,16 +27,18 @@ if (count($hostgroups) === 0) {
<th><?= $this->translate('Service States'); ?></th> <th><?= $this->translate('Service States'); ?></th>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($hostgroups as $h): <?php endif ?>
if ($h->hosts_down_unhandled) { <?php
if ($h->hosts_down_unhandled) {
$handled = false; $handled = false;
$state = Host::STATE_DOWN; $state = Host::STATE_DOWN;
$lastStateChange = $h->hosts_down_last_state_change_unhandled; $lastStateChange = $h->hosts_down_last_state_change_unhandled;
} elseif ($h->hosts_unreachable_unhandled) { } elseif ($h->hosts_unreachable_unhandled) {
$handled = false; $handled = false;
$state = Host::STATE_UNREACHABLE; $state = Host::STATE_UNREACHABLE;
$lastStateChange = $h->hosts_unreachable_last_state_change_unhandled; $lastStateChange = $h->hosts_unreachable_last_state_change_unhandled;
} else { } else {
$handled = true; $handled = true;
if ($h->hosts_down_handled) { if ($h->hosts_down_handled) {
$state = Host::STATE_DOWN; $state = Host::STATE_DOWN;
@ -52,8 +53,9 @@ if (count($hostgroups) === 0) {
$state = Host::STATE_PENDING; $state = Host::STATE_PENDING;
$lastStateChange = $h->hosts_pending_last_state_change; $lastStateChange = $h->hosts_pending_last_state_change;
} }
} }
?>
?>
<tr class="state <?= Host::getStateText($state) ?><?= $handled ? ' handled' : '' ?>" href="<?= <tr class="state <?= Host::getStateText($state) ?><?= $handled ? ' handled' : '' ?>" href="<?=
$this->href('monitoring/list/hosts', array('hostgroup_name' => $h->hostgroup_name)) $this->href('monitoring/list/hosts', array('hostgroup_name' => $h->hostgroup_name))
?>"> ?>">
@ -461,7 +463,11 @@ if (count($hostgroups) === 0) {
<?php endif ?> <?php endif ?>
</td> </td>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>
<?php if ($hostgroups->hasResult()): ?>
</tbody> </tbody>
</table> </table>
<?php else: ?>
<?= $this->translate('No hostgroups found matching the filter'); ?>
<?php endif ?>
</div> </div>

View File

@ -15,14 +15,6 @@ if (! $this->compact): ?>
</div> </div>
<?php endif ?> <?php endif ?>
<div class="content"> <div class="content">
<?php
if (count($hosts) === 0) {
echo $this->translate('No hosts found matching the filter') . '</div>';
return;
}
?>
<table <table
data-base-target="_next" data-base-target="_next"
class="action multiselect" class="action multiselect"
@ -99,4 +91,7 @@ if (count($hosts) === 0) {
<?php endforeach ?> <?php endforeach ?>
</tbody> </tbody>
</table> </table>
<?php if (! $hosts->hasResult()): ?>
<?= $this->translate('No hosts found matching the filter'); ?>
<?php endif ?>
</div> </div>

View File

@ -12,13 +12,6 @@ if (! $this->compact): ?>
</div> </div>
<?php endif ?> <?php endif ?>
<div class="content"> <div class="content">
<?php
if (count($notifications) === 0) {
echo $this->translate('No notifications found matching the filter') . '</div>';
return;
}
?>
<table data-base-target="_next" class="action"> <table data-base-target="_next" class="action">
<tbody> <tbody>
<?php foreach ($notifications as $notification): <?php foreach ($notifications as $notification):
@ -71,4 +64,7 @@ if (count($notifications) === 0) {
<?php endforeach ?> <?php endforeach ?>
</tbody> </tbody>
</table> </table>
<?php if (! $notifications->hasResult()): ?>
<?= $this->translate('No notifications found matching the filter'); ?>
<?php endif ?>
</div> </div>

View File

@ -10,11 +10,10 @@
<div class="content"> <div class="content">
<?php <?php
if (count($servicegroups) === 0) { $firstRow = true;
echo $this->translate('No servicegroups found matching the filter') . '</div>'; foreach ($servicegroups as $s): ?>
return; <?php if ($firstRow): ?>
} <?php $firstRow = false; ?>
?>
<table class="groupview action" data-base-target="_next"> <table class="groupview action" data-base-target="_next">
<thead> <thead>
<th><?= $this->translate('Last Problem'); ?></th> <th><?= $this->translate('Last Problem'); ?></th>
@ -23,7 +22,7 @@ if (count($servicegroups) === 0) {
<th><?= $this->translate('Service States'); ?></th> <th><?= $this->translate('Service States'); ?></th>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($servicegroups as $s): ?> <?php endif ?>
<tr href="<?= $this->href('monitoring/list/services', array('servicegroup_name' => $s->servicegroup_name)); ?>"> <tr href="<?= $this->href('monitoring/list/services', array('servicegroup_name' => $s->servicegroup_name)); ?>">
<?php if ($s->services_critical_last_state_change_unhandled): ?> <?php if ($s->services_critical_last_state_change_unhandled): ?>
<td class="state change critical unhandled"> <td class="state change critical unhandled">
@ -298,7 +297,11 @@ if (count($servicegroups) === 0) {
<?php endif ?> <?php endif ?>
</td> </td>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>
<?php if ($servicegroups->hasResult()): ?>
</tbody> </tbody>
</table> </table>
<?php else: ?>
<?= $this->translate('No servicegroups found matching the filter'); ?>
<?php endif ?>
</div> </div>

View File

@ -18,13 +18,6 @@ if (! $this->compact): ?>
</div> </div>
<?php endif ?> <?php endif ?>
<div class="content"> <div class="content">
<?php
if (count($services) === 0) {
echo $this->translate('No services found matching the filter') . '</div>';
return;
}
?>
<table data-base-target="<?= isset($baseTarget) ? $baseTarget : '_next'; ?>" <table data-base-target="<?= isset($baseTarget) ? $baseTarget : '_next'; ?>"
class="action multiselect <?php if ($this->compact): ?> compact<?php endif ?>" style="table-layout: auto;" class="action multiselect <?php if ($this->compact): ?> compact<?php endif ?>" style="table-layout: auto;"
data-icinga-multiselect-url="<?= $this->href("monitoring/services/show") ?>" data-icinga-multiselect-url="<?= $this->href("monitoring/services/show") ?>"
@ -91,4 +84,7 @@ if (count($services) === 0) {
<?php endforeach ?> <?php endforeach ?>
</tbody> </tbody>
</table> </table>
<?php if (! $services->hasResult()): ?>
<?= $this->translate('No services found matching the filter'); ?>
<?php endif ?>
</div> </div>

View File

@ -1,6 +1,19 @@
<?php <?php
use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Service;
function contactsLink($match, $view) {
$links = array();
foreach (preg_split('/,\s/', $match[1]) as $contact) {
$links[] = $view->qlink(
$contact,
'monitoring/show/contact',
array('contact_name' => $contact),
array('title' => sprintf($view->translate('Show detailed information about %s'), $contact))
);
}
return '[' . implode(', ', $links) . ']';
}
$self = $this; $self = $this;
if (! $this->compact): ?> if (! $this->compact): ?>
@ -15,29 +28,6 @@ if (! $this->compact): ?>
</div> </div>
<?php endif ?> <?php endif ?>
<div class="content"> <div class="content">
<?php
if (count($history) === 0) {
echo $this->translate('No history events found matching the filter') . '</div>';
return;
}
?>
<?php
function contactsLink($match, $view) {
$links = array();
foreach (preg_split('/,\s/', $match[1]) as $contact) {
$links[] = $view->qlink(
$contact,
'monitoring/show/contact',
array('contact_name' => $contact),
array('title' => sprintf($view->translate('Show detailed information about %s'), $contact))
);
}
return '[' . implode(', ', $links) . ']';
}
?>
<table data-base-target="_next" class="action objecthistory"> <table data-base-target="_next" class="action objecthistory">
<tbody> <tbody>
<?php foreach ($history as $event): ?> <?php foreach ($history as $event): ?>
@ -126,7 +116,10 @@ function contactsLink($match, $view) {
</div> </div>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php if (! $history->hasResult()): ?>
<?= $this->translate('No history events found matching the filter'); ?>
<?php endif ?>
</div> </div>

View File

@ -433,6 +433,16 @@ abstract class DataView implements QueryInterface, SortRules, IteratorAggregate
return $this->query->hasMore(); return $this->query->hasMore();
} }
/**
* Return whether this query will or has yielded any result
*
* @return bool
*/
public function hasResult()
{
return $this->query->hasResult();
}
/** /**
* Set a limit count and offset * Set a limit count and offset
* *