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);

    {!-- 1972 --}
    // delete parents
    $this->db->where_in('parent_id', $entries);

    // are there children?
    $this->db->where_in('child_id', $entries);
    $child_results = $this->db->get('relationships');

    if ($child_results->num_rows() > 0)
        // gather related fields
        $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);


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

1 Answer 1


Try clearing the "Cached Relationship Entries" before you delete a site.

You can do this from the Clear Cache page in the control panel.

The relationship cache template in the database can become very large and is possibly the cause of the 500 error.

  • Thanks Anna. I cleared all the caches. I gave up and ported the entire setup over to a local dev box and processed it through IIS there to ensure I could replicate it. Once that happened, I ran it through Apache and was given the error above. (Just added to the original)
    – W3bGuy
    Commented Oct 29, 2013 at 17:12
  • Check the DB... Do you see the "exp_relationships" table? Sounds like it was deleted previously somehow or never created in the first place. Best way to fix this is to export the table structure using phpmyadmin from another 2.7.2 install and import it into your install... you can do a fresh install to get the structure.
    – Anna_MediaGirl
    Commented Oct 29, 2013 at 18:00
  • Anna, thanks for pointing out the obvious to this challenged shell of a coder... lol - Spot on! :)
    – W3bGuy
    Commented Oct 29, 2013 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.