[3.0] Stop the package browser dying without a cached version list - #9389
Open
albertlast wants to merge 1 commit into
Open
[3.0] Stop the package browser dying without a cached version list#9389albertlast wants to merge 1 commit into
albertlast wants to merge 1 commit into
Conversation
browse() reads the emulation version list out of admin_info_files, where the copy
fetched from simplemachines.org is cached, and hands it straight to preg_replace()
and then in_array(). A forum that has never managed to fetch it has an empty row,
jsonDecode() returns null, preg_replace() gives back null rather than an array,
and the page dies:
in_array(): Argument #2 ($haystack) must be of type array, string given
That is the state of every fresh install until the first successful fetch, and the
permanent state of any forum without outbound access. Falls back to an empty list,
which the line below already handles by adding the current version to it.
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
This was referenced Aug 8, 2026
Closed
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.
Description
PackageManager::browse()cannot render on a forum that has never fetched theversion list from simplemachines.org:
The whole Package Manager → Browse Packages page is replaced by that error.
The emulation version list is fetched from simplemachines.org and cached in
admin_info_files.browse()reads it and passes it straight on:Utils::jsonDecode()opens withif (empty($json)) { return null; }, so withnothing cached
$itemsis null,preg_replace()returns null rather than anarray, and
in_array()on the next line rejects it.Every fresh install is in that state until the first successful fetch, and any
forum without outbound access is in it permanently. On mine all four rows of
admin_info_filesare zero-length:Falls back to an empty list. The three lines below already cope with that — they
add the running version to the list if it is not in it — so the dropdown offers
the current version rather than nothing.
$dataalso gets a?? '', sincefetch_assoc()returns false when there is norow at all rather than a row with an empty column.
Testing
On a clean install of
release-3.0(a7ac468b1), MySQL, with no outbound access:?action=admin;area=packages;sa=browseshows the error above, and thepage has only the "Package Manager" heading.
sections, the advanced panel, and the emulation dropdown offering
3.0 Alpha 4, selected.composer lintis clean.Found while testing the package browser for the #7933 split.
Issues References (Fixes|Related|Closes)
Related to #7933