PR#12083 - Correct typing of "Payflow Pro" in various messages.
[civicrm-core.git] / CRM / Core / ManagedEntities.php
index 16ac0ad2fd3fe8d305255ad6abf118e29a575d08..5021859b01c0ef9a2cbabd1fa397aa7f369d5a34 100644 (file)
@@ -34,7 +34,7 @@ class CRM_Core_ManagedEntities {
   protected $declarations;
 
   /**
-   * Get an instance
+   * Get an instance.
    * @param bool $fresh
    * @return \CRM_Core_ManagedEntities
    */
@@ -334,17 +334,25 @@ class CRM_Core_ManagedEntities {
         'version' => 3,
         'id' => $dao->entity_id,
       );
-      $result = civicrm_api($dao->entity_type, 'delete', $params);
-      if ($result['is_error']) {
-        $this->onApiError($dao->entity_type, 'delete', $params, $result);
-      }
+      $check = civicrm_api3($dao->entity_type, 'get', $params);
+      if ((bool) $check['count']) {
+        $result = civicrm_api($dao->entity_type, 'delete', $params);
+        if ($result['is_error']) {
+          $this->onApiError($dao->entity_type, 'delete', $params, $result);
+        }
 
-      CRM_Core_DAO::executeQuery('DELETE FROM civicrm_managed WHERE id = %1', array(
-        1 => array($dao->id, 'Integer'),
-      ));
+        CRM_Core_DAO::executeQuery('DELETE FROM civicrm_managed WHERE id = %1', array(
+          1 => array($dao->id, 'Integer'),
+        ));
+      }
     }
   }
 
+  /**
+   * Get declarations.
+   *
+   * @return array|null
+   */
   public function getDeclarations() {
     if ($this->declarations === NULL) {
       $this->declarations = array();