The error 500 can be got when upgrading any CMS, including WordPress, Joomla and Drupal. Check if $location is an empty string. You need trim() because $location contains linebreaks.
private function addUpdateSite($name, $type, $location, $enabled)
{
if(!trim($location))return;
$dbo =...