From: Coleman Watts Date: Fri, 5 Feb 2021 01:52:45 +0000 (-0500) Subject: APIv4 - Increase alias max length to 256 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8f508853d6653b95ebf301a62006213a207eb420;p=civicrm-core.git APIv4 - Increase alias max length to 256 --- diff --git a/Civi/Api4/Query/Api4SelectQuery.php b/Civi/Api4/Query/Api4SelectQuery.php index 3aacf3b1e5..ad05e798c7 100644 --- a/Civi/Api4/Query/Api4SelectQuery.php +++ b/Civi/Api4/Query/Api4SelectQuery.php @@ -534,7 +534,7 @@ class Api4SelectQuery { // Which might contain an alias. Split on the keyword "AS" list($entity, $alias) = array_pad(explode(' AS ', $entity), 2, NULL); // Ensure alias is a safe string, and supply default if not given - $alias = $alias ? \CRM_Utils_String::munge($alias) : strtolower($entity); + $alias = $alias ? \CRM_Utils_String::munge($alias, '_', 256) : strtolower($entity); // First item in the array is a boolean indicating if the join is required (aka INNER or LEFT). // The rest are join conditions. $side = array_shift($join) ? 'INNER' : 'LEFT'; diff --git a/Civi/Api4/Query/SqlExpression.php b/Civi/Api4/Query/SqlExpression.php index bce3d47144..5f80321b67 100644 --- a/Civi/Api4/Query/SqlExpression.php +++ b/Civi/Api4/Query/SqlExpression.php @@ -73,7 +73,7 @@ abstract class SqlExpression { public static function convert(string $expression, $parseAlias = FALSE, $mustBe = [], $cantBe = ['SqlWild']) { $as = $parseAlias ? strrpos($expression, ' AS ') : FALSE; $expr = $as ? substr($expression, 0, $as) : $expression; - $alias = $as ? \CRM_Utils_String::munge(substr($expression, $as + 4)) : NULL; + $alias = $as ? \CRM_Utils_String::munge(substr($expression, $as + 4), '_', 256) : NULL; $bracketPos = strpos($expr, '('); $firstChar = substr($expr, 0, 1); $lastChar = substr($expr, -1); @@ -153,7 +153,7 @@ abstract class SqlExpression { * @return string */ public function getAlias(): string { - return $this->alias ?? $this->fields[0] ?? \CRM_Utils_String::munge($this->expr); + return $this->alias ?? $this->fields[0] ?? \CRM_Utils_String::munge($this->expr, '_', 256); } /**