Skip to content

Extension Manager can crash when last_update_run.global.limitedPackages is stored as object instead of array #15

Description

@vadkuz

Environment:

  • Flarum: v2.0.0-beta.7
  • Extension Manager: v2.0.0-beta.7

Problem:
In some cases, flarum-extension-manager.last_update_run stores global.limitedPackages as an object (example: {"19":"vendor/package"}) instead of an array.
After that, Extension Manager admin page can crash with:
TypeError: e.global.limitedPackages is not iterable

Observed behavior:

  • Extension Manager page becomes unstable / may fail to render correctly.
  • Navigation in admin can become unreliable after opening that page.

Expected behavior:

  • Extension Manager should always render without crashing.
  • Stored setting shape should remain consistent (limitedPackages should be a JSON array).

Likely root cause:
array_intersect() preserves original array keys.
When encoded to JSON with non-sequential numeric keys, PHP produces an object instead of an array.

Suggested backend fix (patch snippet):
In src/Listener/ReCheckForUpdates.php, normalize keys before saving:

->with('limitedPackages', array_values(array_intersect($previousPackages, $lastPackages)))

Current code appears to be:

->with('limitedPackages', array_intersect($previousPackages, $lastPackages))

Optional hardening:

  • Frontend could defensively handle non-array limitedPackages.
  • A one-time normalization for existing malformed flarum-extension-manager.last_update_run values would help existing installs.

If needed, I can also provide a minimal reproducible test case for the setting payload format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions