ensure that the indexed column is not an FK before deleting the index
[civicrm-core.git] / CRM / Core / Task.php
index 29aa84280c3e75cb07f005400476f57104d9fc50..51e67c8346621eaae772f16ac44f1d74cba4bc03 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
+ | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017                                |
+ | Copyright CiviCRM LLC (c) 2004-2018                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -27,7 +27,7 @@
 
 /**
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2017
+ * @copyright CiviCRM LLC (c) 2004-2018
  */
 
 /**
@@ -82,7 +82,7 @@ abstract class CRM_Core_Task {
    *            ]
    */
   public static function tasks() {
-    CRM_Utils_Hook::searchTasks(self::$objectType, self::$_tasks);
+    CRM_Utils_Hook::searchTasks(static::$objectType, self::$_tasks);
     asort(self::$_tasks);
 
     return self::$_tasks;
@@ -172,8 +172,8 @@ abstract class CRM_Core_Task {
     static::tasks();
 
     if (!CRM_Utils_Array::value($value, self::$_tasks)) {
-      // Children can specify a default task (eg. print), we don't here
-      return array();
+      // Children can specify a default task (eg. print), pick another if it is not valid.
+      $value = key(self::$_tasks);
     }
     return array(
       CRM_Utils_Array::value('class', self::$_tasks[$value]),