Commit Graph

7 Commits

Author SHA1 Message Date
Squidly271 1859921036 Fix: GUI Search wouldn't update when plugin uninstalled 2025-11-09 13:52:27 -05:00
Eli Bosley c364912d08 fix: searchlink can error in the plugin check
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.
2025-09-02 10:46:46 -04:00
Squidly271 19bebe7ef3 Update post_plugin_checks 2024-01-07 06:51:23 -05:00
Squidly271 68552c0808 Update post_plugin_checks 2024-01-07 06:47:12 -05:00
Squidly271 adcb0de17d Update post_plugin_checks 2024-01-05 19:29:25 -05:00
bergware d4e8617eef Use "null coalescing assignment" operator for $docroot 2023-10-26 18:17:44 +02:00
Tom Mortensen f9ec00b488 repo reorg 2023-06-02 12:49:33 -07:00