+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018 |
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
*/
class CRM_Core_I18n_Schema {
// build the column-adding SQL queries
$columns = CRM_Core_I18n_SchemaStructure::columns();
$indices = CRM_Core_I18n_SchemaStructure::indices();
- $queries = array();
+ $queries = [];
foreach ($columns as $table => $hash) {
// drop old indices
if (isset($indices[$table])) {
$retain,
$table,
$class = 'CRM_Core_I18n_SchemaStructure',
- $triggers = array()
+ $triggers = []
) {
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
$columns =& $class::columns();
$indices =& $class::indices();
- $queries = array();
- $dropQueries = array();
+ $queries = [];
+ $dropQueries = [];
// drop indices
if (isset($indices[$table])) {
foreach ($indices[$table] as $index) {
// build the required SQL queries
$columns = CRM_Core_I18n_SchemaStructure::columns();
$indices = CRM_Core_I18n_SchemaStructure::indices();
- $queries = array();
+ $queries = [];
foreach ($columns as $table => $hash) {
// add new columns
foreach ($hash as $column => $type) {
}
$indices =& $class::indices();
$tables =& $class::tables();
- $queries = array();
+ $queries = [];
$dao = new CRM_Core_DAO();
// get all of the already existing indices
- $existing = array();
+ $existing = [];
foreach (array_keys($indices) as $table) {
- $existing[$table] = array();
+ $existing[$table] = [];
$dao->query("SHOW INDEX FROM $table", FALSE);
while ($dao->fetch()) {
if (preg_match('/_[a-z][a-z]_[A-Z][A-Z]$/', $dao->Key_name)) {
$version = str_ireplace(".upgrade", "", $version);
// fetch all the SchemaStructure versions we ship and sort by version
- $schemas = array();
+ $schemas = [];
foreach (scandir(dirname(__FILE__)) as $file) {
- $matches = array();
+ $matches = [];
if (preg_match('/^SchemaStructure_([0-9a-z_]+)\.php$/', $file, $matches)) {
$schemas[] = str_replace('_', '.', $matches[1]);
}
$indices =& $class::indices();
$columns =& $class::columns();
if (!isset($indices[$table])) {
- return array();
+ return [];
}
- $queries = array();
+ $queries = [];
foreach ($indices[$table] as $index) {
$unique = isset($index['unique']) && $index['unique'] ? 'UNIQUE' : '';
foreach ($index['field'] as $i => $col) {
*/
private static function createViewQuery($locale, $table, &$dao, $class = 'CRM_Core_I18n_SchemaStructure', $isUpgradeMode = FALSE) {
$columns =& $class::columns();
- $cols = array();
- $tableCols = array();
+ $cols = [];
+ $tableCols = [];
$dao->query("DESCRIBE {$table}", FALSE);
while ($dao->fetch()) {
// view non-internationalized columns directly
continue;
}
- $trigger = array();
+ $trigger = [];
foreach ($hash as $column => $_) {
$trigger[] = "IF NEW.{$column}_{$locale} IS NOT NULL THEN";
}
foreach ($locales as $old) {
$trigger[] = "ELSEIF NEW.{$column}_{$old} IS NOT NULL THEN";
- foreach (array_merge($locales, array(
+ foreach (array_merge($locales, [
$locale,
- )) as $loc) {
+ ]) as $loc) {
if ($loc == $old) {
continue;
}
}
$sql = implode(' ', $trigger);
- $info[] = array(
- 'table' => array($table),
+ $info[] = [
+ 'table' => [$table],
'when' => 'BEFORE',
- 'event' => array('UPDATE'),
+ 'event' => ['UPDATE'],
'sql' => $sql,
- );
+ ];
}
// take care of the ON INSERT triggers
foreach ($columns as $table => $hash) {
- $trigger = array();
+ $trigger = [];
foreach ($hash as $column => $_) {
$trigger[] = "IF NEW.{$column}_{$locale} IS NOT NULL THEN";
foreach ($locales as $old) {
}
foreach ($locales as $old) {
$trigger[] = "ELSEIF NEW.{$column}_{$old} IS NOT NULL THEN";
- foreach (array_merge($locales, array(
+ foreach (array_merge($locales, [
$locale,
- )) as $loc) {
+ ]) as $loc) {
if ($loc == $old) {
continue;
}
}
$sql = implode(' ', $trigger);
- $info[] = array(
- 'table' => array($table),
+ $info[] = [
+ 'table' => [$table],
'when' => 'BEFORE',
- 'event' => array('INSERT'),
+ 'event' => ['INSERT'],
'sql' => $sql,
- );
+ ];
}
}