applySeoTags() accesses protected $doc->_links property #78

Closed
opened 2026-06-23 13:32:50 +00:00 by jmiller · 1 comment
Owner

Summary

The applySeoTags() method in MokoOG.php accesses $doc->_links, which is a protected property of Joomla\CMS\Document\HtmlDocument. This works due to PHP's loose access control in some contexts but is fragile and may break in future Joomla versions.

Risk

  • Joomla could rename or restructure _links in a future release
  • Static analysis tools flag this as an error
  • Violates encapsulation

Recommendation

Use the public API instead:

  • $doc->getHeadData() to read links
  • $doc->setHeadData() or $doc->addHeadLink() to modify them
  • If no public API exists for removing a canonical link, consider filing upstream or using Reflection as a documented workaround
## Summary The `applySeoTags()` method in `MokoOG.php` accesses `$doc->_links`, which is a protected property of `Joomla\CMS\Document\HtmlDocument`. This works due to PHP's loose access control in some contexts but is fragile and may break in future Joomla versions. ## Risk - Joomla could rename or restructure `_links` in a future release - Static analysis tools flag this as an error - Violates encapsulation ## Recommendation Use the public API instead: - `$doc->getHeadData()` to read links - `$doc->setHeadData()` or `$doc->addHeadLink()` to modify them - If no public API exists for removing a canonical link, consider filing upstream or using Reflection as a documented workaround
jmiller added this to the Code Quality & Testing milestone 2026-06-23 13:32:50 +00:00
jmiller added the bug label 2026-06-23 13:32:50 +00:00
Author
Owner

Branch created: feature/78-applyseotags-accesses-protected-links-pr

git fetch origin
git checkout feature/78-applyseotags-accesses-protected-links-pr
Branch created: [`feature/78-applyseotags-accesses-protected-links-pr`](https://git.mokoconsulting.tech/MokoConsulting/MokoSuiteOpenGraph/src/branch/feature/78-applyseotags-accesses-protected-links-pr) ```bash git fetch origin git checkout feature/78-applyseotags-accesses-protected-links-pr ```
Sign in to join this conversation.
Priority Medium
Type Feature
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoSuiteOpenGraph#78