API endpoints do not return post labels field
The UNA CMS REST API endpoints for posts do not return the labels field, even though labels are stored in the database and are accessible through the web interface.
Affected Endpoints
-
system/get_info/TemplServiceContent- Does not returnlabelsfield -
bx_posts/browse/Module- Does not returnlabelsfield - All other browse endpoints for posts
Current Behavior
When retrieving post data via API:
Request:
GET /api.php?r=system/get_info/TemplServiceContent¶ms=["bx_posts",40]
Response:
{
"id": 40,
"module": "bx_posts",
"title": "Post Title",
"author": {...},
"url": "...",
"image": "...",
"summary_plain": "..."
// labels field is missing
}
Database:
SELECT labels FROM bx_posts_posts WHERE id = 40;
-- Result: a:1:{i:0;s:9:"My School";}
The labels field exists in the database but is filtered out by the API response.
Expected Behavior
The API should return the labels field in the response, similar to other post fields:
{
"id": 40,
"module": "bx_posts",
"title": "Post Title",
"labels": ["My School"],
...
}
Root Cause
For system/get_info/TemplServiceContent:
- File:
public/modules/base/text/classes/BxBaseModTextModule.php - Method:
decodeDataAPI()(lines 815-854) - The method explicitly filters which fields are returned and does not include
labels
For browse endpoints:
- File:
public/modules/boonex/posts/classes/BxPostsSearchResult.php - Property:
ownFieldsarray (line 24) - The array defines:
array('id', 'title', 'abstract', 'text', 'thumb', 'thumb_data', 'author', 'added') - The
labelsfield is not included
Proposed Solution
- Add
labelsto thedecodeDataAPI()method inBxBaseModTextModule.php - Add
labelsto theownFieldsarray inBxPostsSearchResult.php - Ensure the serialized labels are properly unserialized before being returned in the API response
Use Case
We need to retrieve post labels via API for:
- Mobile applications that display post metadata
- Third-party integrations that need to filter/display posts by labels
- Analytics and reporting tools that categorize posts by labels
Workaround
Currently, the only way to access post labels is through direct database queries, which bypasses UNA's permission system and is not ideal for API consumers.
Environment
- UNA Version: 14
- PHP Version: 8.1
- Affected Modules: Posts (bx_posts), and likely all text-based modules (Events, Polls, etc.)
Additional Notes
This limitation affects all text-based content modules that extend BxBaseModTextModule, not just posts. A fix for the base class would benefit all derived modules.