Commit 1975ca02 authored by paalj's avatar paalj

update hook fix once more.

parent e5782ae6
......@@ -416,6 +416,8 @@ function h5p_update_6105(&$sandbox) {
$ret = array();
if (isset($sandbox['content']) === FALSE) {
if (db_column_exists('h5p_nodes_libraries', 'preloaded')) {
db_drop_primary_key($ret, 'h5p_nodes_libraries');
db_change_field($ret, 'h5p_nodes_libraries', 'preloaded', 'dependency_type', array(
'description' => "dynamic, preloaded or editor",
......@@ -431,6 +433,7 @@ function h5p_update_6105(&$sandbox) {
if ($result['success'] === FALSE) {
return $ret; // Do not update nodes if update failed.
}
}
// Update h5p_nodes_libraries to get all dependencies.
$result = db_query("
......@@ -442,8 +445,9 @@ function h5p_update_6105(&$sandbox) {
JOIN {h5p_libraries} hl ON hl.library_id = hn.main_library_id
");
// Clean h5p_nodes_libraries - it will be rebuilt
db_query('delete from h5p_nodes_libraries');
// Update h5p_nodes_libraries since column has changed type
db_query("UPDATE {h5p_nodes_libraries} set dependency_type='preloaded' where dependency_type='1'");
db_query("UPDATE {h5p_nodes_libraries} set dependency_type='dynamic' where dependency_type='0'");
$sandbox['content'] = array();
while ($content = db_fetch_object($result)) {
......@@ -481,11 +485,5 @@ function h5p_save_content_dependencies($content) {
$dependencies = array();
$core->findLibraryDependencies($dependencies, $library);
// Add main library
$dependencies['preloaded-' . $content->libraryName] = array(
'library' => $library,
'type' => 'preloaded'
);
$i->saveLibraryUsage($content->id, $dependencies);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment