The error occurred because of how searchLink() is called on line 49:
if ($support = searchLink($info, $url) ?: searchLink($info, newurl($url))) {
Here's the sequence of events that caused the issue:
1. First call: searchLink($info, $url) - This works fine if $info contains the JSON data from
/tmp/community.applications/tempFiles/templates.json
2. If first call returns falsy: The ?: operator (shorthand ternary) triggers the second call:
searchLink($info, newurl($url))
3. The problem: When the first searchLink() returns null or false, PHP's ?: operator evaluates
the second expression. However, if $info itself is null (which can happen if the JSON file
doesn't exist or is empty - see line 19 where readJson() returns [] for missing files), then
searchLink(null, newurl($url)) is called.
4. The crash: Inside searchLink(), when $db is null, calling count($db) throws the TypeError
because count() requires an array or Countable object, not null.
Root causes:
- The JSON file at /tmp/community.applications/tempFiles/templates.json might not exist or could
be corrupted
- The readJson() function returns an empty array [] for missing files, but if the JSON decode
fails, it could return null
- The code wasn't defensive against null values being passed to searchLink()
The fix adds is_array($db) check to ensure we only attempt to count when we have a valid array.
- Merged styles from the deleted PluginHelpers.css into default-base.css.
- Updated .upgrade_notice and .ca_element_notice styles for consistency.
- Added padding to .bannerInfo and adjusted related selectors for improved layout.
- Updated the plugin installation page to provide a console warning when no plugin file is selected, improving user feedback.
- Added a file tree for easier selection of plugin files, enhancing user experience during plugin installation.
- Adjusted the form layout for better alignment and consistency.
- Added utility classes for width, height, and overflow to improve layout structure in PluginInstall.page.
- Removed the obsolete Plugins.css file as its styles are no longer needed.
- This change continues the effort to enhance visual consistency across the plugin.
- Wrapped input fields and labels in <div> elements for better structure and responsiveness.
- Updated headings to use <p><strong> for improved semantic clarity.
- This change aligns with previous updates for consistent layout across similar components.
- Wrapped tables in a <div> with class "TableContainer" for better responsiveness.
- Ensured consistent styling and structure across ArrayDevices.page, BootDevice.page, DiskList.page, ShareList.page, DockerContainers.page, Plugins.page, and VMMachines.page.
- Updated CSS to support new table container classes for enhanced layout control.
- Removed commented-out styles for .Theme--black and .Theme--white to streamline the CSS.
- Eliminated redundant margin-top adjustment in span.status.vhshift for improved layout clarity.
- Modified the calculation of the 'top' variable to remove the offset adjustment, simplifying the logic.
- Ensured that the scroll position is set correctly based on the cookie value.
This change improves the handling of scroll position based on user preferences.
* Added security headers to the setupEnvironment method for improved security.
* Implemented stricter validation for the altUrl parameter to ensure it matches allowed domains and uses HTTPS.
* Enhanced script execution checks to validate permissions before running the unraidcheck script.
* Added `UnraidCheckExec` class to handle execution of the unraidcheck script and return JSON responses.
* Updated the unraidcheck script to parse query parameters for better integration with web components.
* This change maintains separation of concerns between UnraidCheck and ReplaceKey functionalities.
* Added `ReplaceKey` initialization and check to `Registration.page`, `Downgrade.page`, `Update.page`, and `unraidcheck` script.
* Ensures consistent handling of key replacement across relevant components.