Skip to content

Commit 7d36c1a

Browse files
committed
Additional error checking when loading browse categories for LiDA.
1 parent c483816 commit 7d36c1a

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

code/web/release_notes/24.03.01.MD

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Other Updates
66
- Correct "Visit Website" link on Custom Pages when the location uses "default" for the home link. (Ticket 129155) (*MDN*)
7+
- Additional error checking when loading browse categories for LiDA. (*MDN*)
78

89
## This release includes code contributions from
910
- ByWater Solutions

code/web/services/API/SearchAPI.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,7 @@ function getAppActiveBrowseCategories() {
19821982
$thisId = $categoryInformation->textId . '_' . $savedSearch['id'];
19831983
$savedSearchResults = $this->getAppBrowseCategoryResults($thisId, $appUser, 12, true);
19841984
$formattedSavedSearchResults = [];
1985-
if (count($savedSearchResults) > 0) {
1985+
if (!empty($savedSearchResults)) {
19861986
foreach ($savedSearchResults as $savedSearchResult) {
19871987
$formattedSavedSearchResults[] = [
19881988
'id' => $savedSearchResult['id'],
@@ -2010,7 +2010,7 @@ function getAppActiveBrowseCategories() {
20102010
} elseif ($categoryInformation->textId == ("system_user_lists")) {
20112011
$userLists = $listApi->getUserLists();
20122012
$allUserLists = $userLists['lists'] ?? [];
2013-
if (count($allUserLists) > 0) {
2013+
if (!empty($allUserLists)) {
20142014
foreach ($allUserLists as $userList) {
20152015
if ($userList['id'] != "recommendations") {
20162016
require_once ROOT_DIR . '/sys/UserLists/UserList.php';
@@ -2116,7 +2116,7 @@ function getAppActiveBrowseCategories() {
21162116
}
21172117
} while ($listEntry->fetch() && $count < 12);
21182118

2119-
if (count($categoryResponse['lists']) != 0 || count($categoryResponse['records']) != 0) {
2119+
if (!empty($categoryResponse['lists']) || !empty($categoryResponse['records'])) {
21202120
$formattedCategories[] = $categoryResponse;
21212121
$numCategoriesProcessed++;
21222122
if ($maxCategories > 0 && $numCategoriesProcessed >= $maxCategories) {
@@ -2144,7 +2144,7 @@ function getAppActiveBrowseCategories() {
21442144
'records' => [],
21452145
];
21462146

2147-
if (count($suggestions) > 0) {
2147+
if (!empty($suggestions)) {
21482148
foreach ($suggestions as $suggestion) {
21492149
$categoryResponse['records'][] = [
21502150
'id' => $suggestion['titleInfo']['id'],
@@ -2160,10 +2160,10 @@ function getAppActiveBrowseCategories() {
21602160
}
21612161
} elseif ($categoryInformation->source == 'Events') {
21622162
$subCategories = $categoryInformation->getSubCategories();
2163-
if (count($subCategories) == 0 && !$categoryInformation->isDismissed($appUser)) {
2163+
if (empty($subCategories) && !$categoryInformation->isDismissed($appUser)) {
21642164
$eventsSearchResults = $this->getAppBrowseCategoryResults($categoryInformation->textId, null, 12, true);
21652165
$formattedEventsResults = [];
2166-
if(count($eventsSearchResults) > 0) {
2166+
if(!empty($eventsSearchResults)) {
21672167
foreach ($eventsSearchResults as $event) {
21682168
$formattedEventsResults[] = [
21692169
'id' => $event['key'],
@@ -2186,15 +2186,15 @@ function getAppActiveBrowseCategories() {
21862186
$numCategoriesProcessed++;
21872187
}
21882188
if ($includeSubCategories) {
2189-
if (count($subCategories) > 0) {
2189+
if (!empty($subCategories)) {
21902190
foreach ($subCategories as $subCategory) {
21912191
$temp = new BrowseCategory();
21922192
$temp->id = $subCategory->subCategoryId;
21932193
if ($temp->find(true)) {
21942194
if ($temp->isValidForDisplay($appUser)) {
21952195
if ($temp->source != '') {
21962196
$records = $this->getAppBrowseCategoryResults($temp->textId, null, 12, true);
2197-
if(count($records) > 0) {
2197+
if(!empty($records)) {
21982198
$parent = new BrowseCategory();
21992199
$parent->id = $subCategory->browseCategoryId;
22002200
if ($parent->find(true)) {
@@ -2230,9 +2230,9 @@ function getAppActiveBrowseCategories() {
22302230
}
22312231
} else {
22322232
$subCategories = $categoryInformation->getSubCategories();
2233-
if (count($subCategories) == 0 && !$categoryInformation->isDismissed($appUser)) {
2233+
if (empty($subCategories) && !$categoryInformation->isDismissed($appUser)) {
22342234
$records = $this->getAppBrowseCategoryResults($categoryInformation->textId, null, 12, true);
2235-
if(count($records) > 0) {
2235+
if(!empty($records)) {
22362236
$categoryResponse = [
22372237
'key' => $categoryInformation->textId,
22382238
'title' => $categoryInformation->label,
@@ -2247,15 +2247,15 @@ function getAppActiveBrowseCategories() {
22472247
}
22482248
}
22492249
if ($includeSubCategories) {
2250-
if (count($subCategories) > 0) {
2250+
if (!empty($subCategories)) {
22512251
foreach ($subCategories as $subCategory) {
22522252
$temp = new BrowseCategory();
22532253
$temp->id = $subCategory->subCategoryId;
22542254
if ($temp->find(true)) {
22552255
if ($temp->isValidForDisplay($appUser)) {
22562256
if ($temp->source != '') {
22572257
$records = $this->getAppBrowseCategoryResults($temp->textId, null, 12, true);
2258-
if(count($records) > 0) {
2258+
if(!empty($records)) {
22592259
$parent = new BrowseCategory();
22602260
$parent->id = $subCategory->browseCategoryId;
22612261
if ($parent->find(true)) {

0 commit comments

Comments
 (0)