barryvdh / laravel-elfinder

elFinder bundle for Laravel
738 stars 169 forks source link

Order of arguments to array_merge is incorrect leading to options not being overriden #314

Open codewise-nicolas opened 2 years ago

codewise-nicolas commented 2 years ago

Problem: root_options values that have the same key as in the default root (local) are not overridden.

Example: 'root_options' => array('URL' => 'something') This wont override the URL attribute.

Cause: The arguments to array_merge here https://github.com/barryvdh/laravel-elfinder/blob/03b8bc85c12baf41e6db794fe3d41a77351c8eb3/src/ElfinderController.php#L129 are backwards for the intended functionality of allowing $rootOptions to override the $root values.

php's array_merge keeps the values from the last arguments array when there are key collisions.

Fix: Change the order of the arguments

-            $roots[$key] = array_merge($rootOptions, $root);
+            $roots[$key] = array_merge($root, $rootOptions);