Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
integration
prechecker
Commits
f3a7f485
Commit
f3a7f485
authored
Feb 16, 2011
by
Petr Skoda
Browse files
MDL-26452 fix resource mod regression breaking upgrade on Windows
parent
d911c72b
Changes
2
Hide whitespace changes
Inline
Side-by-side
mod/resource/db/upgrade.php
View file @
f3a7f485
...
...
@@ -228,24 +228,22 @@ function xmldb_resource_upgrade($oldversion) {
$instances
=
$DB
->
get_recordset_sql
(
$sql
);
foreach
(
$instances
as
$instance
)
{
$context
=
get_context_instance
(
CONTEXT_MODULE
,
$instance
->
cmid
);
$component
=
'mod_resource'
;
$filearea
=
'content'
;
$itemid
=
0
;
$filepath
=
file_correct_filepath
(
dirname
(
$instance
->
mainfile
));
$filename
=
basename
(
$instance
->
mainfile
);
file_set_sortorder
(
$context
->
id
,
$component
,
$filearea
,
$itemid
,
$filepath
,
$filename
,
1
);
if
(
empty
(
$instance
->
mainfile
))
{
// weird
continue
;
}
$context
=
get_context_instance
(
CONTEXT_MODULE
,
$instance
->
cmid
,
MUST_EXIST
);
$parts
=
explode
(
'/'
,
$instance
->
mainfile
);
$filename
=
array_pop
(
$parts
);
$filepath
=
implode
(
'/'
,
$parts
);
file_set_sortorder
(
$context
->
id
,
'mod_resource'
,
'content'
,
0
,
$filepath
,
$filename
,
1
);
}
$instances
->
close
();
/// Define field mainfile to be dropped from resource
$table
=
new
xmldb_table
(
'resource'
);
$field
=
new
xmldb_field
(
'mainfile'
);
/// Conditionally launch drop field mainfile
if
(
$dbman
->
field_exists
(
$table
,
$field
))
{
$dbman
->
drop_field
(
$table
,
$field
);
}
$dbman
->
drop_field
(
$table
,
$field
);
/// resource savepoint reached
upgrade_mod_savepoint
(
true
,
2009080501
,
'resource'
);
...
...
mod/resource/view.php
View file @
f3a7f485
...
...
@@ -67,12 +67,13 @@ if ($resource->tobemigrated) {
}
$fs
=
get_file_storage
();
$files
=
$fs
->
get_area_files
(
$context
->
id
,
'mod_resource'
,
'content'
,
0
,
'sortorder
'
);
$files
=
$fs
->
get_area_files
(
$context
->
id
,
'mod_resource'
,
'content'
,
0
,
'sortorder
DESC, id ASC'
,
false
);
// TODO: this is not very efficient!!
if
(
count
(
$files
)
<
1
)
{
resource_print_filenotfound
(
$resource
,
$cm
,
$course
);
die
;
}
else
{
$file
=
array_pop
(
$files
);
$file
=
reset
(
$files
);
unset
(
$files
);
}
if
(
$redirect
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment