[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Handle missing trackerId in category browsing for tracker items
Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <69150e358e5a0_2c1ea3701324d@gitlab-sidekiq-low-urgency-cpu-bound-v2-598795bdd5-zd6j4.mail> |
Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
9bca3578 by Moïse Nturubika at 2025-11-12T22:38:29+00:00
[FIX] Handle missing trackerId in category browsing for tracker items
---
* [FIX] Improve tracker item display in category browsing
* [FIX] Simplify some redudant codes and fix typo in variables name
* [FIX] Use Tracker_Item API for category browsing and improve missing item handling
* [FIX] Handle missing trackerId in category browsing for tracker items
See merge request tikiwiki/tiki!7393
- - - - -
1 changed file:
- lib/categories/categlib.php
Changes:
=====================================
lib/categories/categlib.php
=====================================
@@ -786,16 +786,34 @@ class CategLib extends ObjectLib
foreach ($result as $res) {
if (! in_array($res['objectId'] . '-' . $res['category_ids'], $objs)) { // same object and same categories
if (preg_match('/trackeritem/', $res['type']) && $res['description'] == '') {
- $trklib = TikiLib::lib('trk');
- //This is a performance optimisation, but we can't rely on trackerId being present - benoitg - 2024-03-18
- $count = 0;
- $trackerIdRes = preg_replace('/^.*trackerId=([0-9]+).*$/', '$1', $res['href'], -1, $count);
- $trackerId = $count ? $trackerIdRes : null;
- $res['name'] = $trklib->get_isMain_value($trackerId, $res['itemId']);
- $filed = $trklib->get_field_id($trackerId, "description");
- $res['description'] = $trklib->get_item_value($trackerId, $res['itemId'], $filed);
- if (empty($res['description'])) {
- $res['description'] = $this->getOne("select `name` from `tiki_trackers` where `trackerId`=?", [(int)$trackerId]);
+ // Use the Tracker_Item API to get item information
+ $itemObject = Tracker_Item::fromId($res['itemId']);
+
+ if ($itemObject) {
+ $definition = $itemObject->getDefinition();
+ $trklib = TikiLib::lib('trk');
+ $res['name'] = $trklib->get_isMain_value(null, $res['itemId']);
+ if (empty($res['name'])) {
+ $res['name'] = $definition->getConfiguration('name') . ' #' . $res['itemId'];
+ }
+
+ // Try to get a description field
+ $trackerId = $definition->getConfiguration('trackerId');
+ $field = $trklib->get_field_id($trackerId, "description");
+ if (! empty($field)) {
+ $itemInfo = $itemObject->getInfo();
+ $res['description'] = $itemInfo[$field] ?? '';
+ }
+ if (empty($res['description'])) {
+ $res['description'] = $definition->getConfiguration('description');
+ }
+ } else {
+ // Item doesn't exist, show a message
+ Feedback::error(tr('Tracker item #%0 could not be found', $res['itemId']));
+
+ // We still showing something in the list
+ $res['name'] = tr('Missing Tracker Item #%0', $res['itemId']);
+ $res['description'] = tr('This tracker item could not be found');
}
}
if ($prefs['feature_sefurl'] == 'y') {
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/9bca3578078e41717304fde6bb8c0b0e7f3c7f25
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/9bca3578078e41717304fde6bb8c0b0e7f3c7f25
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs