An application that registers a core/Loader extension and returns a flat list of URLs will take down every front-end page on the site, not just its own.
The symptom
Every front page returns a 500. The log says:
TypeError: array_merge(): Argument #2 must be of type array, string given #0 /system/Dispatcher/Front.php(188): array_merge(Array, 'https://...')
Note where the error comes from: the dispatcher, not your application. Nothing in the trace names the app responsible.
The cause
The front dispatcher merges each entry into its file list:
foreach ( $loader->js() as $js )
{
$jsFiles = array_merge( $jsFiles, $js );
}
Each element is expected to be an array. Returning array( $url ) passes a string into array_merge() and throws before any page renders.
The fix
public function js(): array
{
return array( array( $url ) ); // an array OF arrays
}
Why this is easy to miss
Calling js() yourself and seeing a non-empty array back is not a test. The failure only happens inside the dispatcher merge loop. Test by reproducing that loop across every installed Loader extension, or by actually requesting a page.
Recovering
If a site is already down, disabling the application restores it immediately: set app_enabled = 0 for that application and clear the datastore. No files need to be touched.
Recommended Comments