mirrored from git://git.moodle.org/moodle.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
MDL-55020 admin: Fix renaming of the plugin package root folder
There was a problem with core\update\code_manager::unzip_plugin_file() if it was used to extract a plugin package into a non-empty target directory and the plugin package root folder was being renamed at the same time. The problem was caused by the underlying helper method rename_extracted_rootdir() that worked only for ZIPs extracted to an empty temporary location. When the plugin was extracted to the actual dirroot with other existing plugin folders present, the method failed badly. The solution in the patch is to always extract the ZIP into a temporary empty location, perform the eventual root renaming there, and only then move the extracted contents to the final destination. Additionally we are changing the behaviour of the rename_extracted_rootdir() method so that now it throws exception if the plugin package contains multiple root folders (it should not happen in normal situations as such a plugin would not pass the pre-install validation). Unit tests did not catch this bug before because in the tests, the target directory had been empty. Now we are adding a new directory "aaa_another" to the target location to test in more realistic environment. Tests for the new behaviour of the renaming method are added, too. p.s. I noticed that moodle_exception class was not imported into the namespace and this is fixed now too (and covered with unit tests).
- Loading branch information
Showing
3 changed files
with
60 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
Binary file not shown.
This file contains 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