Skip to content

Commit

Permalink
LUGG-1221 Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
jrearick committed Dec 23, 2020
2 parents ed1b9d8 + e9cc1ec commit 3e63ea7
Show file tree
Hide file tree
Showing 40 changed files with 1,331 additions and 54 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Drupal 7.77, 2020-12-03
-----------------------
- Hotfix for schema.prefixed tables

Drupal 7.76, 2020-12-02
-----------------------
- Support for MySQL 8
- Core tests pass in SQLite
- Better user flood control logging

Drupal 7.75, 2020-11-26
-----------------------
- Fixed security issues:
Expand Down
5 changes: 5 additions & 0 deletions LUGGAGE_CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ How to read this changelog:

The LUGG- prefix refers to JIRA issue numbers; the # prefix refers to GitHub issue numbers.

Luggage 3.6.17, 2020-12-23
Drupal 7.77, 2020-12-03
-------------------------
- LUGG-1221 - Drupal 7.77

Luggage 3.6.16, 2020-12-02
Drupal 7.75, 2020-11-25
-------------------------
Expand Down
2 changes: 1 addition & 1 deletion LUGGAGE_VERSION.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

$version = "3.6.16";
$version = "3.6.17";
2 changes: 1 addition & 1 deletion MAINTAINERS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The branch maintainers for Drupal 7 are:

- Dries Buytaert 'dries' https://www.drupal.org/u/dries
- Fabian Franz 'Fabianx' https://www.drupal.org/u/fabianx
- (provisional) Drew Webber 'mcdruid' https://www.drupal.org/u/mcdruid
- Drew Webber 'mcdruid' https://www.drupal.org/u/mcdruid


Component maintainers
Expand Down
18 changes: 10 additions & 8 deletions includes/bootstrap.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* The current system version.
*/
define('VERSION', '7.75');
define('VERSION', '7.77');

/**
* Core API compatibility.
Expand Down Expand Up @@ -1189,19 +1189,21 @@ function variable_initialize($conf = array()) {
$variables = $cached->data;
}
else {
// Cache miss. Avoid a stampede.
// Cache miss. Avoid a stampede by acquiring a lock. If the lock fails to
// acquire, optionally just continue with uncached processing.
$name = 'variable_init';
if (!lock_acquire($name, 1)) {
// Another request is building the variable cache.
// Wait, then re-run this function.
$lock_acquired = lock_acquire($name, 1);
if (!$lock_acquired && variable_get('variable_initialize_wait_for_lock', FALSE)) {
lock_wait($name);
return variable_initialize($conf);
}
else {
// Proceed with variable rebuild.
// Load the variables from the table.
$variables = array_map('unserialize', db_query('SELECT name, value FROM {variable}')->fetchAllKeyed());
cache_set('variables', $variables, 'cache_bootstrap');
lock_release($name);
if ($lock_acquired) {
cache_set('variables', $variables, 'cache_bootstrap');
lock_release($name);
}
}
}

Expand Down
23 changes: 17 additions & 6 deletions includes/common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6653,30 +6653,41 @@ function element_children(&$elements, $sort = FALSE) {
$sort = isset($elements['#sorted']) ? !$elements['#sorted'] : $sort;

// Filter out properties from the element, leaving only children.
$children = array();
$count = count($elements);
$child_weights = array();
$i = 0;
$sortable = FALSE;
foreach ($elements as $key => $value) {
if (is_int($key) || $key === '' || $key[0] !== '#') {
$children[$key] = $value;
if (is_array($value) && isset($value['#weight'])) {
$weight = $value['#weight'];
$sortable = TRUE;
}
else {
$weight = 0;
}
// Support weights with up to three digit precision and conserve the
// insertion order.
$child_weights[$key] = floor($weight * 1000) + $i / $count;
}
$i++;
}

// Sort the children if necessary.
if ($sort && $sortable) {
uasort($children, 'element_sort');
asort($child_weights);
// Put the sorted children back into $elements in the correct order, to
// preserve sorting if the same element is passed through
// element_children() twice.
foreach ($children as $key => $child) {
foreach ($child_weights as $key => $weight) {
$value = $elements[$key];
unset($elements[$key]);
$elements[$key] = $child;
$elements[$key] = $value;
}
$elements['#sorted'] = TRUE;
}

return array_keys($children);
return array_keys($child_weights);
}

/**
Expand Down
47 changes: 45 additions & 2 deletions includes/database/database.inc
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,13 @@ abstract class DatabaseConnection extends PDO {
*/
protected $escapedAliases = array();

/**
* List of un-prefixed table names, keyed by prefixed table names.
*
* @var array
*/
protected $unprefixedTablesMap = array();

function __construct($dsn, $username, $password, $driver_options = array()) {
// Initialize and prepare the connection prefix.
$this->setPrefix(isset($this->connectionOptions['prefix']) ? $this->connectionOptions['prefix'] : '');
Expand Down Expand Up @@ -338,7 +345,9 @@ abstract class DatabaseConnection extends PDO {
// Destroy all references to this connection by setting them to NULL.
// The Statement class attribute only accepts a new value that presents a
// proper callable, so we reset it to PDOStatement.
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array()));
if (!empty($this->statementClass)) {
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array()));
}
$this->schema = NULL;
}

Expand Down Expand Up @@ -442,6 +451,13 @@ abstract class DatabaseConnection extends PDO {
$this->prefixReplace[] = $this->prefixes['default'];
$this->prefixSearch[] = '}';
$this->prefixReplace[] = '';

// Set up a map of prefixed => un-prefixed tables.
foreach ($this->prefixes as $table_name => $prefix) {
if ($table_name !== 'default') {
$this->unprefixedTablesMap[$prefix . $table_name] = $table_name;
}
}
}

/**
Expand Down Expand Up @@ -477,6 +493,17 @@ abstract class DatabaseConnection extends PDO {
}
}

/**
* Gets a list of individually prefixed table names.
*
* @return array
* An array of un-prefixed table names, keyed by their fully qualified table
* names (i.e. prefix + table_name).
*/
public function getUnprefixedTablesMap() {
return $this->unprefixedTablesMap;
}

/**
* Prepares a query string and returns the prepared statement.
*
Expand Down Expand Up @@ -2840,7 +2867,6 @@ function db_field_exists($table, $field) {
*
* @param $table_expression
* An SQL expression, for example "simpletest%" (without the quotes).
* BEWARE: this is not prefixed, the caller should take care of that.
*
* @return
* Array, both the keys and the values are the matching tables.
Expand All @@ -2849,6 +2875,23 @@ function db_find_tables($table_expression) {
return Database::getConnection()->schema()->findTables($table_expression);
}

/**
* Finds all tables that are like the specified base table name. This is a
* backport of the change made to db_find_tables in Drupal 8 to work with
* virtual, un-prefixed table names. The original function is retained for
* Backwards Compatibility.
* @see https://www.drupal.org/node/2552435
*
* @param $table_expression
* An SQL expression, for example "simpletest%" (without the quotes).
*
* @return
* Array, both the keys and the values are the matching tables.
*/
function db_find_tables_d8($table_expression) {
return Database::getConnection()->schema()->findTablesD8($table_expression);
}

function _db_create_keys_sql($spec) {
return Database::getConnection()->schema()->createKeysSql($spec);
}
Expand Down

0 comments on commit 3e63ea7

Please sign in to comment.