Skip to content

Commit

Permalink
MDL-33550 Set default status for file =0 and correct setting user in …
Browse files Browse the repository at this point in the history
…phpunit test
  • Loading branch information
marinaglancy committed Jun 14, 2012
1 parent 0b2bfbd commit cfc4db4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/filestorage/file_storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,7 @@ public function create_file_from_pathname($filerecord, $pathname) {
$newrecord->source = empty($filerecord->source) ? null : $filerecord->source;
$newrecord->author = empty($filerecord->author) ? null : $filerecord->author;
$newrecord->license = empty($filerecord->license) ? null : $filerecord->license;
$newrecord->status = empty($filerecord->status) ? 0 : $filerecord->status;
$newrecord->sortorder = $filerecord->sortorder;

list($newrecord->contenthash, $newrecord->filesize, $newfile) = $this->add_file_to_pool($pathname);
Expand Down Expand Up @@ -1149,6 +1150,7 @@ public function create_file_from_string($filerecord, $content) {
$newrecord->source = empty($filerecord->source) ? null : $filerecord->source;
$newrecord->author = empty($filerecord->author) ? null : $filerecord->author;
$newrecord->license = empty($filerecord->license) ? null : $filerecord->license;
$newrecord->status = empty($filerecord->status) ? 0 : $filerecord->status;
$newrecord->sortorder = $filerecord->sortorder;

list($newrecord->contenthash, $newrecord->filesize, $newfile) = $this->add_string_to_pool($content);
Expand Down Expand Up @@ -1223,6 +1225,7 @@ public function create_file_from_reference($filerecord, $repositoryid, $referenc
$filerecord->source = empty($filerecord->source) ? null : $filerecord->source;
$filerecord->author = empty($filerecord->author) ? null : $filerecord->author;
$filerecord->license = empty($filerecord->license) ? null : $filerecord->license;
$filerecord->status = empty($filerecord->status) ? 0 : $filerecord->status;
$filerecord->filepath = clean_param($filerecord->filepath, PARAM_PATH);
if (strpos($filerecord->filepath, '/') !== 0 or strrpos($filerecord->filepath, '/') !== strlen($filerecord->filepath)-1) {
// Path must start and end with '/'.
Expand Down
2 changes: 1 addition & 1 deletion lib/filestorage/tests/file_storage_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ public function test_create_file_from_reference() {
// create user
$generator = $this->getDataGenerator();
$user = $generator->create_user();
$this->setUser($user);
$usercontext = context_user::instance($user->id);
$syscontext = context_system::instance();
$USER = $DB->get_record('user', array('id'=>$user->id));

$fs = get_file_storage();

Expand Down

0 comments on commit cfc4db4

Please sign in to comment.