tmuras / moosh

Moosh
GNU General Public License v3.0
229 stars 175 forks source link

moosh file-upload fails when absolute filepath is provided #243

Open johnennewdeeson opened 5 years ago

johnennewdeeson commented 5 years ago

Actual behaviour

Getting this error when executing moosh file-upload --filename=169.mbz /app/moodledata/backup.mdz

Notice: Undefined variable: filepath in /app/vendor/tmuras/moosh/Moosh/Command/Moodle23/File/FileUpload.php on line 71
Default exception handler: Cannot read file. Either the file does not exist or there is a permission problem. Debug:
Error code: storedfilecannotread

Expected behaviour

File is uploaded to moodle and no error messages or notices about undeclared variables.

Steps to reproduce

Try to upload a file by providing its absolute path, e.g moosh file-upload --filename=169.mbz /app/moodledata/backup.mdz

Looking at the code in FileUpload.php $filepath variable is only set when the specified file does not start with a leading forward slash. In addition, $arguments[0] is used to reference the filepath throughout the code so suggest its more consistent to just use that throughout.

johnennewdeeson commented 5 years ago

Pull requests here: https://github.com/tmuras/moosh/pull/242