hotfix- Security array lookup - #2362
Merged
Merged
Conversation
RTMediaModel::get_by_activity_id() returns ARRAY_A rows, so the media-id extraction added in b289b1d read `$media_row->id` on an array. Every API call that builds a media feed emitted "Attempt to read property id on array" and passed [0] to RTMediaActivity, so activity_content rendered as an empty media list. The privacy gate above this loop already casts to object, so visibility was unaffected; only the id extraction was wrong. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
|
Unable to PHPCS or SVG scan one or more files due to error running PHPCS/SVG scanner:
The error may be temporary. If the error persists, please contact a human (commit-ID: c624a02). |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes media feed rendering by correctly extracting IDs from array-based database rows.
Changes:
- Supports array and object media rows when building activity media IDs.
- Prevents empty
activity_contentand related PHP warnings.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
NoumaanAhamed
approved these changes
Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
One-line fix in
app/main/controllers/api/RTMediaJsonApiFunctions.php.RTMediaModel::get_by_activity_id()returnsARRAY_Arows, but the media-id extraction added in b289b1d (merged via #2357) reads$media_row->idon an array.Impact
Every JSON API call that builds a media feed (
rtmedia_get_media_details, and any feed path where the activity has media rows):PHP Warning: Attempt to read property "id" on arrayintval(null)=0, soRTMediaActivityis constructed with[0]andactivity_contentrenders as an empty media listBefore:
After:
The
mediaarray in the response was always correct — onlyactivity_contentwas affected.Security
None. The privacy gate immediately above this loop casts to object via
(object) $media, so it handles both row shapes and visibility filtering was never affected. Verified after the fix:Testing
Reproduced and verified against a local BuddyPress + rtMedia site with token-authenticated API calls: warning count for
RTMediaJsonApiFunctionsdropped to 0,activity_contentrenders the correct thumbnail, and the privacy matrix above is unchanged.🤖 Generated with Claude Code