Skip to content

Commit

Permalink
Merge branch 'MDL-64497-master' of https://github.com/sammarshallou/m…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jan 8, 2019
2 parents 024b5c5 + fc570e6 commit 66f13f8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions privacy/classes/local/request/moodle_content_writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,14 @@ protected function get_files_target_url($component, $filearea, $itemid) : string
*
* @param string $path The path to export the data at.
* @param string $data The data to be exported.
* @throws \moodle_exception If the file cannot be written for some reason.
*/
protected function write_data(string $path, string $data) {
$targetpath = $this->path . DIRECTORY_SEPARATOR . $path;
check_dir_exists(dirname($targetpath), true, true);
file_put_contents($targetpath, $data);
if (file_put_contents($targetpath, $data) === false) {
throw new \moodle_exception('cannotsavefile', 'error', '', $targetpath);
}
$this->files[$path] = $targetpath;
}

Expand Down Expand Up @@ -706,12 +709,12 @@ protected function condense_array(array $array) : Array {
*
* @param string $filepath The file path.
* @return string contents of the file.
* @throws \moodle_exception If the file cannot be opened.
*/
protected function get_file_content(string $filepath) : String {
$filepointer = fopen($filepath, 'r');
$content = '';
while (!feof($filepointer)) {
$content .= fread($filepointer, filesize($filepath));
$content = file_get_contents($filepath);
if ($content === false) {
throw new \moodle_exception('cannotopenfile', 'error', '', $filepath);
}
return $content;
}
Expand Down

0 comments on commit 66f13f8

Please sign in to comment.