dev/core#887 Fix fatal error on pledge search
[civicrm-core.git] / CRM / Core / Form / Search.php
index 836ed37eecb32cf162a9bc5abd4e5ce62d4819ba..07b1a85489672ce9d60e2d58234af08a42b48a41 100644 (file)
@@ -170,12 +170,19 @@ class CRM_Core_Form_Search extends CRM_Core_Form {
    *
    * @param array $fields
    *   Posted values of the form.
+   * @param array $files
+   * @param object $form
    *
    * @return array
    *   list of errors to be posted back to the form
    */
   public static function formRule($fields, $files, $form) {
     $errors = [];
+    if (!is_a($form, 'CRM_Core_Form_Search')) {
+      // So this gets hit with a form object when doing an activity date search from
+      // advanced search, but a NULL object when doing a pledge search.
+      return $errors;
+    }
     foreach ($form->getSearchFieldMetadata() as $entity => $spec) {
       foreach ($spec as $fieldName => $fieldSpec) {
         if ($fieldSpec['type'] === CRM_Utils_Type::T_DATE || $fieldSpec['type'] === (CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME)) {