bug: multi-slug params may return stdClass instead of array #96

Closed
opened 2026-05-22 03:30:32 +00:00 by jmiller · 1 comment
Owner

Description

With multiple="true" on the tos_slug field, Joomla stores the value as a JSON array. However, Registry::get() may return a stdClass instead of an array in some Joomla 4 versions. Iterating over stdClass with foreach fails silently.

Fix

Add $slugs = (array) $slugs before the empty check in the extension class.

Files

  • src/src/Extension/MokoJoomTOS.php - params handling
## Description With `multiple="true"` on the `tos_slug` field, Joomla stores the value as a JSON array. However, `Registry::get()` may return a `stdClass` instead of an array in some Joomla 4 versions. Iterating over `stdClass` with `foreach` fails silently. ## Fix Add `$slugs = (array) $slugs` before the empty check in the extension class. ## Files - `src/src/Extension/MokoJoomTOS.php` - params handling
jmiller added the joomlapriority: mediumbug labels 2026-05-22 03:30:32 +00:00
Author
Owner

Testing Steps -- stdClass cast for multi-slug params

Setup

  1. Install plugin on Joomla 5.x

Test A: Multiple slugs

  1. Go to System > Plugins > MokoJoomTOS
  2. Select multiple slugs from the dropdown (e.g., terms-of-service and another page)
  3. Save
  4. Set site offline
  5. Visit each configured slug in incognito browser
  6. Expected: Both pages are accessible

Test B: Single slug (legacy format)

  1. Manually edit the plugin params in #__extensions to set tos_slug to a plain string: "terms-of-service"
  2. Set site offline, visit the slug
  3. Expected: Page is accessible (backwards compatible)

Pass criteria

  • Multiple selected slugs all work
  • Legacy single-string format still works
  • No PHP errors about non-iterable types
## Testing Steps -- stdClass cast for multi-slug params ### Setup 1. Install plugin on Joomla 5.x ### Test A: Multiple slugs 1. Go to **System > Plugins > MokoJoomTOS** 2. Select multiple slugs from the dropdown (e.g., `terms-of-service` and another page) 3. Save 4. Set site offline 5. Visit each configured slug in incognito browser 6. **Expected:** Both pages are accessible ### Test B: Single slug (legacy format) 1. Manually edit the plugin params in `#__extensions` to set `tos_slug` to a plain string: `"terms-of-service"` 2. Set site offline, visit the slug 3. **Expected:** Page is accessible (backwards compatible) ### Pass criteria - [ ] Multiple selected slugs all work - [ ] Legacy single-string format still works - [ ] No PHP errors about non-iterable types
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoJoomTOS#96