Commit 1975ca02 authored by paalj's avatar paalj

update hook fix once more.

parent e5782ae6
...@@ -416,20 +416,23 @@ function h5p_update_6105(&$sandbox) { ...@@ -416,20 +416,23 @@ function h5p_update_6105(&$sandbox) {
$ret = array(); $ret = array();
if (isset($sandbox['content']) === FALSE) { if (isset($sandbox['content']) === FALSE) {
db_drop_primary_key($ret, 'h5p_nodes_libraries');
db_change_field($ret, 'h5p_nodes_libraries', 'preloaded', 'dependency_type', array(
'description' => "dynamic, preloaded or editor",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'preloaded',
), array(
'primary key' => array('content_id', 'library_id', 'dependency_type')
));
$result = end($ret); if (db_column_exists('h5p_nodes_libraries', 'preloaded')) {
if ($result['success'] === FALSE) { db_drop_primary_key($ret, 'h5p_nodes_libraries');
return $ret; // Do not update nodes if update failed. db_change_field($ret, 'h5p_nodes_libraries', 'preloaded', 'dependency_type', array(
'description' => "dynamic, preloaded or editor",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'preloaded',
), array(
'primary key' => array('content_id', 'library_id', 'dependency_type')
));
$result = end($ret);
if ($result['success'] === FALSE) {
return $ret; // Do not update nodes if update failed.
}
} }
// Update h5p_nodes_libraries to get all dependencies. // Update h5p_nodes_libraries to get all dependencies.
...@@ -442,8 +445,9 @@ function h5p_update_6105(&$sandbox) { ...@@ -442,8 +445,9 @@ function h5p_update_6105(&$sandbox) {
JOIN {h5p_libraries} hl ON hl.library_id = hn.main_library_id JOIN {h5p_libraries} hl ON hl.library_id = hn.main_library_id
"); ");
// Clean h5p_nodes_libraries - it will be rebuilt // Update h5p_nodes_libraries since column has changed type
db_query('delete from h5p_nodes_libraries'); 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(); $sandbox['content'] = array();
while ($content = db_fetch_object($result)) { while ($content = db_fetch_object($result)) {
...@@ -481,11 +485,5 @@ function h5p_save_content_dependencies($content) { ...@@ -481,11 +485,5 @@ function h5p_save_content_dependencies($content) {
$dependencies = array(); $dependencies = array();
$core->findLibraryDependencies($dependencies, $library); $core->findLibraryDependencies($dependencies, $library);
// Add main library
$dependencies['preloaded-' . $content->libraryName] = array(
'library' => $library,
'type' => 'preloaded'
);
$i->saveLibraryUsage($content->id, $dependencies); $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