/**
  * @return void
  */
 public function setHomepageToWordpressPageAndDeleteCurrentHomePage()
 {
     $this->logFunctionStart(__FUNCTION__);
     $wordpressHomeID = $this->_db->getFrontPageID();
     if ($wordpressHomeID) {
         $record = SiteTree::get()->find('WordpressID', $wordpressHomeID);
         if ($record && $record->exists()) {
             // todo(Jake): use home constant/var in SS framework
             if ($record->URLSegment !== 'home') {
                 $record->setField('URLSegment', 'home');
                 if ($record->getChangedFields(true, DataObject::CHANGE_VALUE)) {
                     $list = SiteTree::get()->filter(array('WordpressID' => 0, 'URLSegment' => 'home'));
                     foreach ($list as $i => $oldHomePage) {
                         try {
                             $oldHomePage->delete();
                             $oldHomePage->doUnpublish();
                             $this->log($oldHomePage, 'deleted');
                         } catch (Exception $e) {
                             $this->log($oldHomePage, 'delete_error', $e);
                         }
                     }
                     try {
                         $this->writeAndPublishRecord($record);
                     } catch (Exception $e) {
                         $this->log($record, 'error', $e);
                         throw $e;
                     }
                 }
             }
         }
     }
     $this->logFunctionEnd(__FUNCTION__);
 }