EE v2.7.2 Build Date: 20131008
MSM 2.1.6
When I try to delete a site from MSM, I get a 500 Server error. However, if I manually delete everything, then delete the site, it works. I have tested all stages of a site build to find that this only happens if I have an entry in the site. There doesn't have to be anything in regards to templates, channel field groups, channel fields, etc...
To reproduce this all I have to do is create a new site, add a channel, create entry, (entry has nothing but a name and url), try to delete... 500
Has anyone had this happen? What could be causing it? I looked at the server records, but they told me nothing. It's just happening at the POST on confirmation...
2013-10-28 18:06:42 W3SVC3 [PRIVATE] POST /index.php S=af6796b5075bdafba2d73bf3136677cb5ebf5d39&D=cp&C=sites&M=delete_site 80 - [PRIVATE] HTTP/1.1 Mozilla/5.0+(Windows+NT+6.1;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/30.0.1599.101+Safari/537.36 - http://adminDomain/index.php?S=af6796b5075bdafba2d73bf3136677cb5ebf5d39&D=cp&C=sites&M=site_delete_confirm&site_id=106 adminDomain 500 0 0 1405 787 1201
* UPDATE * I have traced it to this portion in the sites.php file (line 1972)
// Just like a gossipy so-and-so, we will now destroy relationships! Category post is also toast.
if (count($entries) > 0)
{
// delete leftovers in category_posts
$this->db->where_in('entry_id', $entries);
$this->db->delete('category_posts');
{!-- 1972 --}
// delete parents
$this->db->where_in('parent_id', $entries);
$this->db->delete('relationships');
// are there children?
$this->db->select('relationship_id');
$this->db->where_in('child_id', $entries);
$child_results = $this->db->get('relationships');
if ($child_results->num_rows() > 0)
{
// gather related fields
$this->db->select('field_id');
$this->db->where('field_type', 'relationship');
$fquery = $this->db->get('channel_fields');
// We have children, so we need to do a bit of housekeeping
// so parent entries don't continue to try to reference them
$cids = array();
foreach ($child_results->result_array() as $row)
{
$cids[] = $row['relationship_id'];
}
foreach($fquery->result_array() as $row)
{
$this->db->where_in('field_id_'.$row['field_id'], $cids);
$this->db->update('channel_data', array('field_id_'.$row['field_id'] => 0));
}
}
// aaaand delete
$this->db->where_in('child_id', $entries);
$this->db->delete('relationships');
}
* UPDATE *
So I ported this to Apache and was given a 'clear' error:
A Database Error Occurred
Error Number: 1146
Table 'db.exp_relationships' doesn't exist
DELETE FROM `exp_relationships` WHERE `parent_id` IN ('217')
Filename: C:\TEST-ENV\DOMAIN\system\codeigniter\system\database\DB_driver.php
Line Number: 330