Skip to content

Commit

Permalink
MDL-47647 lib: Fix message unit test failure.
Browse files Browse the repository at this point in the history
Messaging unit tests on Windows were failing because
of a comparison between two file paths. Part of the
path would have a forward slash instead of a backslash
and so would fail.
  • Loading branch information
abgreeve committed Oct 27, 2014
1 parent d63a81c commit afc3431
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -5919,9 +5919,14 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml = '',

$attachmentpath = $attachment;

// Before doing the comparison, make sure that the paths are correct (Windows uses slashes in the other direction).
$attachpath = str_replace('\\', '/', $attachmentpath);
// Make sure both variables are normalised before comparing.
$temppath = str_replace('\\', '/', $CFG->tempdir);

// If the attachment is a full path to a file in the tempdir, use it as is,
// otherwise assume it is a relative path from the dataroot (for backwards compatibility reasons).
if (strpos($attachmentpath, $CFG->tempdir) !== 0) {
if (strpos($attachpath, $temppath) !== 0) {
$attachmentpath = $CFG->dataroot . '/' . $attachmentpath;
}

Expand Down

0 comments on commit afc3431

Please sign in to comment.