diff -Naur ./xspf_playlist.module ../xspf_playlist-new/xspf_playlist.module --- ./xspf_playlist.module 2008-12-14 19:06:32.000000000 +0000 +++ ../xspf_playlist-new/xspf_playlist.module 2009-04-03 00:36:38.000000000 +0100 @@ -253,7 +253,6 @@ function xspf_playlist_invoke_fire($hook, $op, $node = NULL, $config) { // split the config data up list($module_name, $seperator, $config) = split('[--]', $config); - if (module_exists($module_name)) { if ($output = module_invoke($module_name, $hook, $op, $node, $config)) { return $output; diff -Naur ./xspf_playlist_thumb/xspf_playlist_thumb.install ../xspf_playlist-new/xspf_playlist_thumb/xspf_playlist_thumb.install --- ./xspf_playlist_thumb/xspf_playlist_thumb.install 2008-12-14 18:37:12.000000000 +0000 +++ ../xspf_playlist-new/xspf_playlist_thumb/xspf_playlist_thumb.install 2009-04-02 23:58:56.000000000 +0100 @@ -45,7 +45,7 @@ 'default' => '', ), ), - 'primary key' => array('type', 'id', 'vid'), + 'primary key' => array('type', 'id', 'vid', 'item_path'), ); return $schema; @@ -63,7 +63,7 @@ vid int unsigned NOT NULL default 0, item_path varchar(255) NOT NULL default '', thumbnail_path varchar(255) NOT NULL default '', - PRIMARY KEY (type, id, vid) + PRIMARY KEY (type, id, vid, item_path) ) DEFAULT CHARACTER SET=utf8"); break; @@ -74,7 +74,7 @@ vid int_unsigned NOT NULL default '0', item_path varchar(255) NOT NULL default '', thumbnail_path varchar(255) NOT NULL default '', - PRIMARY KEY (type, id, vid) + PRIMARY KEY (type, id, vid, item_path) )"); break; } @@ -86,5 +86,15 @@ function xspf_playlist_thumb_uninstall() { // Remove tables. drupal_uninstall_schema('xspf_playlist_thumb'); +} +/** + * implmentation of hook_update_N + */ +function xspf_playlist_update_6000() { + $ret = array(); + db_drop_primary_key($ret, 'xspf_playlist_thumb'); + db_add_primary_key($ret, 'xspf_playlist_thumb', array('type', 'id', 'vid', 'item_path')); + return $ret; } + diff -Naur ./xspf_playlist_thumb/xspf_playlist_thumb.module ../xspf_playlist-new/xspf_playlist_thumb/xspf_playlist_thumb.module --- ./xspf_playlist_thumb/xspf_playlist_thumb.module 2008-12-14 19:06:32.000000000 +0000 +++ ../xspf_playlist-new/xspf_playlist_thumb/xspf_playlist_thumb.module 2009-04-03 01:06:41.000000000 +0100 @@ -123,13 +123,15 @@ * item's thumbnail image. */ function xspf_playlist_thumb_save($item) { + // Use a VID as the primary key if present, otherwise an ID. $key = isset($item['vid']) && $item['vid'] ? 'vid' : 'id'; // Test for an existing record. - $result = db_query("SELECT * FROM {xspf_playlist_thumb} WHERE $key = %d AND type = '%s'", $item[$key], $item['type']); + $result = db_result(db_query("SELECT count(*) FROM {xspf_playlist_thumb} WHERE $key = %d AND type = '%s' AND item_path = '%s'", $item[$key], $item['type'], $item['item_path'])); + // If found, update. - if (count($result)) { - db_query("UPDATE {xspf_playlist_thumb} SET item_path = '%s', thumbnail_path = '%s' WHERE $key = %d AND type = '%s'", $item['item_path'], $item['thumbnail_path'], $item[$key], $item['type']); + if ($result) { + db_query("UPDATE {xspf_playlist_thumb} SET item_path = '%s', thumbnail_path = '%s' WHERE $key = %d AND type = '%s' AND item_path = '%s'", $item['item_path'], $item['thumbnail_path'], $item[$key], $item['type'], $item['item_path']); } // Otherwise, create a new record. else { @@ -183,7 +185,7 @@ ); foreach ($fields as $key => $placeholder) { if (isset($item[$key])) { - $conditions[] = 'id = ' . $placeholder; + $conditions[] = "$key = ". $placeholder; $parameters[] = $item[$key]; } }