Merge in 5.11
[civicrm-core.git] / CRM / Utils / Type.php
index 3cd8085a2d216dc67f0d3c1ebaa617fe731aa98f..d45392353d4b799e2eb4d85ef4a0cec082313173 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
  */
 class CRM_Utils_Type {
   const
@@ -67,6 +67,16 @@ class CRM_Utils_Type {
     FORTYFIVE = 45,
     HUGE = 45;
 
+  /**
+   * Maximum size of a MySQL BLOB or TEXT column in bytes.
+   */
+  const BLOB_SIZE = 65535;
+
+  /**
+   * Maximum value of a MySQL signed INT column.
+   */
+  const INT_MAX = 2147483647;
+
   /**
    * Gets the string representation for a data type.
    *
@@ -423,6 +433,7 @@ class CRM_Utils_Type {
       'MysqlOrderBy',
       'ExtensionKey',
       'Json',
+      'Alphanumeric',
     );
     if (!in_array($type, $possibleTypes)) {
       if ($isThrowException) {
@@ -537,6 +548,12 @@ class CRM_Utils_Type {
           return $data;
         }
         break;
+
+      case 'Alphanumeric':
+        if (CRM_Utils_Rule::alphanumeric($data)) {
+          return $data;
+        }
+        break;
     }
 
     if ($abort) {