Skip to content

Commit

Permalink
fixup make sure recent_debates always includes data entry.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Oct 10, 2024
1 parent 73cd73b commit 63df0b0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion classes/Homepage/Scotland.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function getSearchBox(array $data): \MySociety\TheyWorkForYou\Search\S
protected function getEditorialContent(&$data) {
$debatelist = new \SPLIST();
$item = $debatelist->display('recent_debates', ['days' => 7, 'num' => 1], 'none');
if (isset($item['data']) && count($item['data'])) {
if (count($item['data'])) {
$item = $item['data'][0];
$more_url = new \MySociety\TheyWorkForYou\Url('spdebatesfront');
$item['more_url'] = $more_url->generate();
Expand Down
2 changes: 1 addition & 1 deletion classes/Homepage/UK.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function getEditorialContent(&$data) {
$item = $this->getFeaturedDebate($gid, $title, $context, $related);
} else {
$item = $debatelist->display('recent_debates', ['days' => 7, 'num' => 1], 'none');
if (isset($item['data']) && count($item['data'])) {
if (count($item['data'])) {
$item = $item['data'][0];
$more_url = new \MySociety\TheyWorkForYou\Url('debates');
$item['more_url'] = $more_url->generate();
Expand Down
10 changes: 2 additions & 8 deletions www/includes/easyparliament/hansardlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2914,7 +2914,7 @@ public function _get_data_by_recent_debates($args = []) {
// $args['days'] is the number of days back to look for biggest debates (1 by default).
// $args['num'] is the number of links to return (1 by default).

$data = [];
$data = ['info' => [], 'data' => []];

$params = [];

Expand Down Expand Up @@ -3010,7 +3010,7 @@ public function _get_data_by_recent_debates($args = []) {
$childbody = $r['body'];
$speaker = $this->_get_speaker($r['person_id'], $r['hdate'], $r['htime'], $this->major);

$data[] = [
$data['data'][] = [
'contentcount' => $contentcount,
'body' => $body,
'hdate' => $hdate,
Expand All @@ -3028,13 +3028,7 @@ public function _get_data_by_recent_debates($args = []) {

}

$data = [
'info' => [],
'data' => $data,
];

return $data;

}

public function _get_data_by_biggest_debates($args = []) {
Expand Down

0 comments on commit 63df0b0

Please sign in to comment.