Merge pull request #10588 from JMAConsulting/CRM-20793
[civicrm-core.git] / CRM / Core / DAO.php
index e2636dee5d12fbb0a322e17e84af92f469e06d1f..b1bf5ba765e53429e82b3114f722565a21e23fab 100644 (file)
@@ -234,7 +234,6 @@ class CRM_Core_DAO extends DB_DataObject {
           break;
 
         case CRM_Utils_Type::T_DATE:
-        case CRM_Utils_Type::T_TIMESTAMP:
         case CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME:
           $this->$dbName = '19700101';
           if ($dbName == 'end_date') {
@@ -243,6 +242,10 @@ class CRM_Core_DAO extends DB_DataObject {
           }
           break;
 
+        case CRM_Utils_Type::T_TIMESTAMP:
+          $this->$dbName = '19700201000000';
+          break;
+
         case CRM_Utils_Type::T_TIME:
           CRM_Core_Error::fatal("T_TIME shouldn't be used.");
           //$object->$dbName='000000';
@@ -343,6 +346,11 @@ class CRM_Core_DAO extends DB_DataObject {
     // rewrite queries that should use $dbLocale-based views for multi-language installs
     global $dbLocale, $_DB_DATAOBJECT;
 
+    if (empty($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {
+      // Will force connection to be populated per CRM-20541.
+      new CRM_Core_DAO();
+    }
+
     $conn = &$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
     $orig_options = $conn->options;
     $this->_setDBOptions($this->_options);
@@ -2201,7 +2209,7 @@ SELECT contact_id
   public static function buildOptions($fieldName, $context = NULL, $props = array()) {
     // If a given bao does not override this function
     $baoName = get_called_class();
-    return CRM_Core_PseudoConstant::get($baoName, $fieldName, array(), $context);
+    return CRM_Core_PseudoConstant::get($baoName, $fieldName, $props, $context);
   }
 
   /**