Thoughts on sorting this out - will need a script to do:
Step 1: Find the duplicate feed urls: (1 db call)
SELECT COUNT(url), url, authuser, authpassword FROM {blocktype_externalfeed_data} GROUP BY url, authuser, authpassword HAVING COUNT(url) > 1 ORDER BY COUNT(url);
step 2: get the feed ids and use the 1st one to be the feed id for the block instances: (many db calls depending on how many rows from step 1 have duplicates)
SELECT id FROM {blocktype_externalfeed_data} WHERE url = ?, authuser = ?, authpassword = ?;
- add the ids to an $array[$duplicatefeed]['ids'][] and use 'ids'[0] as the 'true' id
step 3: Find the block instances using external feeds. (1 db call). Check to see if they are not using the 'true' id and update them accordingly:
SELECT id FROM {block_instance} WHERE blocktype = 'externalfeed';
- get block_instance object and get $blockfeedid from object
$blockinstance = new BlockInstance($blockid);
$configdata = $blockinstance->get('configdata');
if (!empty($configdata['feedid'])) {
foreach ($array as $duplicatefeed => $ids) {
foreach ($ids as $key => $id) {
if ($id == $configdata['feedid'] && $key != '0') {
// not using the first instance id of this feed $configdata['feedid'] = $ids[0];
$blockinstance->set('dirty') = true; $blockinstance->commit(); (possibly very many db calls) break;
}
}
}
}
step 4: delete the now orphaned feed id(s) rows
foreach ($array as $duplicatefeed => $ids) {
foreach ($ids as $key => $id) {
if ($key != '0') {
DELETE FROM {blocktype_externalfeed_data} WHERE id = ? (possibly very many db calls)
}
}
}
Currently I'm thinking that this approach may use too many db calls. But not sure how to get feedid from configdata column in an easier way. Maybe a preg_match on the serialized data?
Thoughts on sorting this out - will need a script to do:
Step 1: Find the duplicate feed urls: (1 db call)
SELECT COUNT(url), url, authuser, authpassword FROM {blocktype_ externalfeed_ data} GROUP BY url, authuser, authpassword HAVING COUNT(url) > 1 ORDER BY COUNT(url);
step 2: get the feed ids and use the 1st one to be the feed id for the block instances: (many db calls depending on how many rows from step 1 have duplicates)
SELECT id FROM {blocktype_ externalfeed_ data} WHERE url = ?, authuser = ?, authpassword = ?;
- add the ids to an $array[ $duplicatefeed] ['ids'] [] and use 'ids'[0] as the 'true' id
step 3: Find the block instances using external feeds. (1 db call). Check to see if they are not using the 'true' id and update them accordingly:
SELECT id FROM {block_instance} WHERE blocktype = 'externalfeed';
- get block_instance object and get $blockfeedid from object $blockid) ; >get('configdat a'); $configdata[ 'feedid' ])) { 'feedid' ] && $key != '0') {
$configdata[ 'feedid' ] = $ids[0]; e->set( 'dirty' ) = true;
$blockinstanc e->commit( ); (possibly very many db calls)
break;
$blockinstance = new BlockInstance(
$configdata = $blockinstance-
if (!empty(
foreach ($array as $duplicatefeed => $ids) {
foreach ($ids as $key => $id) {
if ($id == $configdata[
// not using the first instance id of this feed
$blockinstanc
}
}
}
}
step 4: delete the now orphaned feed id(s) rows
foreach ($array as $duplicatefeed => $ids) { externalfeed_ data} WHERE id = ? (possibly very many db calls)
foreach ($ids as $key => $id) {
if ($key != '0') {
DELETE FROM {blocktype_
}
}
}
Currently I'm thinking that this approach may use too many db calls. But not sure how to get feedid from configdata column in an easier way. Maybe a preg_match on the serialized data?