Skip to content

Commit f2becc3

Browse files
committed
Upgrade to Backdrop 1.21.2. Security release. For more details: https://github.com/backdrop/backdrop/releases/tag/1.21.2
2 parents 0b9c425 + d2b9f9a commit f2becc3

File tree

71 files changed

+400
-291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+400
-291
lines changed

.github/workflows/functional-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
php-versions: ['5.3', '7.4', '8.0']
13+
php-versions: ['5.3', '7.4', '8.1']
1414
fraction: ['1/3', '2/3', '3/3']
1515
database-versions: ['mariadb-10.3']
1616

core/includes/bootstrap.inc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* The current system version.
99
*/
10-
define('BACKDROP_VERSION', '1.21.1');
10+
define('BACKDROP_VERSION', '1.21.2');
1111

1212
/**
1313
* Core API compatibility.
@@ -373,13 +373,15 @@ abstract class BackdropCacheArray implements ArrayAccess {
373373
/**
374374
* Implements ArrayAccess::offsetExists().
375375
*/
376+
#[\ReturnTypeWillChange]
376377
public function offsetExists($offset) {
377378
return $this->offsetGet($offset) !== NULL;
378379
}
379380

380381
/**
381382
* Implements ArrayAccess::offsetGet().
382383
*/
384+
#[\ReturnTypeWillChange]
383385
public function offsetGet($offset) {
384386
if (isset($this->storage[$offset]) || array_key_exists($offset, $this->storage)) {
385387
return $this->storage[$offset];
@@ -392,13 +394,15 @@ abstract class BackdropCacheArray implements ArrayAccess {
392394
/**
393395
* Implements ArrayAccess::offsetSet().
394396
*/
397+
#[\ReturnTypeWillChange]
395398
public function offsetSet($offset, $value) {
396399
$this->storage[$offset] = $value;
397400
}
398401

399402
/**
400403
* Implements ArrayAccess::offsetUnset().
401404
*/
405+
#[\ReturnTypeWillChange]
402406
public function offsetUnset($offset) {
403407
unset($this->storage[$offset]);
404408
}
@@ -2058,7 +2062,7 @@ function format_string($string, array $args = array()) {
20582062
* @ingroup sanitization
20592063
*/
20602064
function check_plain($text) {
2061-
return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
2065+
return htmlspecialchars((string) $text, ENT_QUOTES, 'UTF-8');
20622066
}
20632067

20642068
/**
@@ -2086,7 +2090,7 @@ function check_plain($text) {
20862090
* TRUE if the text is valid UTF-8, FALSE if not.
20872091
*/
20882092
function backdrop_validate_utf8($text) {
2089-
if (strlen($text) == 0) {
2093+
if (strlen((string) $text) == 0) {
20902094
return TRUE;
20912095
}
20922096
// With the PCRE_UTF8 modifier 'u', preg_match() fails silently on strings
@@ -2553,7 +2557,7 @@ function backdrop_random_bytes($count) {
25532557
// $random_state does not use backdrop_static as it stores random bytes.
25542558
static $random_state, $bytes, $has_openssl;
25552559

2556-
$missing_bytes = $count - strlen($bytes);
2560+
$missing_bytes = $count - strlen((string) $bytes);
25572561

25582562
if ($missing_bytes > 0) {
25592563
// PHP versions prior 5.3.4 experienced openssl_random_pseudo_bytes()

core/includes/common.inc

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ function backdrop_parse_url($url) {
770770
* The encoded path.
771771
*/
772772
function backdrop_encode_path($path) {
773-
return str_replace('%2F', '/', rawurlencode($path));
773+
return str_replace('%2F', '/', rawurlencode((string) $path));
774774
}
775775

776776
/**
@@ -1102,7 +1102,7 @@ function backdrop_http_request($url, array $options = array()) {
11021102
// or PUT request. Some non-standard servers get confused by Content-Length in
11031103
// at least HEAD/GET requests, and Squid always requires Content-Length in
11041104
// POST/PUT requests.
1105-
$content_length = strlen($options['data']);
1105+
$content_length = strlen((string) $options['data']);
11061106
if ($content_length > 0 || $options['method'] == 'POST' || $options['method'] == 'PUT') {
11071107
$options['headers']['Content-Length'] = $content_length;
11081108
}
@@ -1178,7 +1178,7 @@ function backdrop_http_request($url, array $options = array()) {
11781178
$result->headers = array();
11791179

11801180
// Parse the response headers.
1181-
while ($line = trim(array_shift($response))) {
1181+
while ($line = trim((string) array_shift($response))) {
11821182
list($name, $value) = explode(':', $line, 2);
11831183
$name = strtolower($name);
11841184
if (isset($result->headers[$name]) && $name == 'set-cookie') {
@@ -1825,6 +1825,7 @@ function filter_xss($string, $allowed_tags = NULL) {
18251825
if (!backdrop_validate_utf8($string)) {
18261826
return '';
18271827
}
1828+
$string = (string) $string;
18281829
// Store the text format.
18291830
_filter_xss_split($allowed_tags, TRUE);
18301831
// Remove NULL characters (ignored by some browsers).
@@ -2380,7 +2381,7 @@ function format_interval($interval, $granularity = 2, $langcode = NULL) {
23802381
$key = explode('|', $key);
23812382
if ($interval >= $value) {
23822383
$output .= ($output ? ' ' : '') . format_plural(floor($interval / $value), $key[0], $key[1], array(), array('langcode' => $langcode));
2383-
$interval %= $value;
2384+
$interval = (int) $interval % $value;
23842385
$granularity--;
23852386
}
23862387

@@ -2649,7 +2650,7 @@ function url($path = NULL, array $options = array()) {
26492650
// Strip leading slashes from internal paths to prevent them becoming external
26502651
// URLs without protocol. /example.com should not be turned into
26512652
// //example.com.
2652-
$path = ltrim($path, '/');
2653+
$path = ltrim((string) $path, '/');
26532654

26542655
global $base_url, $base_secure_url, $base_insecure_url;
26552656

@@ -2686,7 +2687,7 @@ function url($path = NULL, array $options = array()) {
26862687
}
26872688

26882689
$base = $options['absolute'] ? $options['base_url'] . '/' : base_path();
2689-
$prefix = empty($path) ? rtrim($options['prefix'], '/') : $options['prefix'];
2690+
$prefix = empty($path) ? rtrim((string) $options['prefix'], '/') : $options['prefix'];
26902691

26912692
// Cache the clean URLs setting, as url() is called very frequently.
26922693
static $backdrop_static_fast;
@@ -2752,6 +2753,7 @@ function url($path = NULL, array $options = array()) {
27522753
* Boolean TRUE or FALSE, where TRUE indicates an external path.
27532754
*/
27542755
function url_is_external($path) {
2756+
$path = (string) $path;
27552757
$colonpos = strpos($path, ':');
27562758
// Some browsers treat \ as / so normalize to forward slashes.
27572759
$path = str_replace('\\', '/', $path);
@@ -3300,7 +3302,8 @@ function backdrop_set_time_limit($time_limit) {
33003302
* The path to the requested item or an empty string if the item is not found.
33013303
*/
33023304
function backdrop_get_path($type, $name) {
3303-
return dirname(backdrop_get_filename($type, $name));
3305+
$path = (string) backdrop_get_filename($type, $name);
3306+
return dirname($path);
33043307
}
33053308

33063309
/**
@@ -3396,8 +3399,9 @@ function backdrop_css_defaults($data = NULL) {
33963399
* $options['preprocess'] should be only set to TRUE when a file is required for
33973400
* all typical visitors and most pages of a site. It is critical that all
33983401
* preprocessed files are added unconditionally on every page, even if the
3399-
* files do not happen to be needed on a page. This is normally done by calling
3400-
* backdrop_add_css() in a hook_init() implementation.
3402+
* files do not happen to be needed on a page. However, it is preferred that
3403+
* modules do not use this function, but declare CSS files intended for all
3404+
* pages in their .info file instead.
34013405
*
34023406
* Non-preprocessed files should only be added to the page when they are
34033407
* actually needed.
@@ -4525,8 +4529,9 @@ function backdrop_region_class($region) {
45254529
* $options['preprocess'] should be only set to TRUE when a file is required for
45264530
* all typical visitors and most pages of a site. It is critical that all
45274531
* preprocessed files are added unconditionally on every page, even if the
4528-
* files are not needed on a page. This is normally done by calling
4529-
* backdrop_add_js() in a hook_init() implementation.
4532+
* files are not needed on a page. However, it is preferred that modules do not
4533+
* use this function, but declare JS files intended for all pages in their
4534+
* .info file instead.
45304535
*
45314536
* Non-preprocessed files should only be added to the page when they are
45324537
* actually needed.
@@ -5655,6 +5660,9 @@ function backdrop_build_js_cache($files) {
56555660
return FALSE;
56565661
}
56575662
}
5663+
if (!$map) {
5664+
$map = array();
5665+
}
56585666
$map[$key] = $uri;
56595667
state_set('js_cache_files', $map);
56605668
}
@@ -8515,6 +8523,9 @@ function watchdog_severity_levels() {
85158523
* @see backdrop_implode_tags()
85168524
*/
85178525
function backdrop_explode_tags($tags) {
8526+
if (empty($tags)) {
8527+
return array();
8528+
}
85188529
// This regexp allows the following types of user input:
85198530
// this, "somecompany, llc", "and ""this"" w,o.rks", foo bar
85208531
$regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x';
@@ -8692,7 +8703,7 @@ function backdrop_parse_dependency($dependency) {
86928703

86938704
if (isset($matches['patch']) && ($matches['patch'] === '0' || $matches['patch'])) {
86948705
if ($matches['patch'] == 'x' && $matches['minor'] !== 'x') {
8695-
// See comments above about "x" in minor.
8706+
// See comments above about "x" in minor.
86968707
// Same principle applies to patch in relation to minor.
86978708
if ($op == '>' || $op == '<=') {
86988709
$matches['minor']++;

core/includes/config.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ class Config {
698698
*/
699699
public function getOverride($key) {
700700
$value = NULL;
701-
$parts = explode('.', $key);
701+
$parts = explode('.', (string) $key);
702702
$popped_parts = array();
703703
while ($parts) {
704704
$assembled_key = implode('.', $parts);

core/includes/database/database.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,6 +2263,7 @@ class DatabaseStatementBase extends PDOStatement implements DatabaseStatementInt
22632263
$this->setFetchMode(PDO::FETCH_OBJ);
22642264
}
22652265

2266+
#[\ReturnTypeWillChange]
22662267
public function execute($args = array(), $options = array()) {
22672268
if (isset($options['fetch'])) {
22682269
if (is_string($options['fetch'])) {
@@ -2401,22 +2402,27 @@ class DatabaseStatementEmpty implements Iterator, DatabaseStatementInterface {
24012402

24022403
/* Implementations of Iterator. */
24032404

2405+
#[\ReturnTypeWillChange]
24042406
public function current() {
24052407
return NULL;
24062408
}
24072409

2410+
#[\ReturnTypeWillChange]
24082411
public function key() {
24092412
return NULL;
24102413
}
24112414

2415+
#[\ReturnTypeWillChange]
24122416
public function rewind() {
24132417
// Nothing to do: our DatabaseStatement can't be rewound.
24142418
}
24152419

2420+
#[\ReturnTypeWillChange]
24162421
public function next() {
24172422
// Do nothing, since this is an always-empty implementation.
24182423
}
24192424

2425+
#[\ReturnTypeWillChange]
24202426
public function valid() {
24212427
return FALSE;
24222428
}

core/includes/database/mysql/database.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ class DatabaseConnection_mysql extends DatabaseConnection {
6868
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE,
6969
// Because MySQL's prepared statements skip the query cache, because it's dumb.
7070
PDO::ATTR_EMULATE_PREPARES => TRUE,
71+
// Convert numeric values to strings when fetching. In PHP 8.1,
72+
// PDO::ATTR_EMULATE_PREPARES now behaves the same way as non emulated
73+
// prepares and returns integers. See https://externals.io/message/113294
74+
// for further discussion.
75+
\PDO::ATTR_STRINGIFY_FETCHES => TRUE,
7176
);
7277
if (defined('PDO::MYSQL_ATTR_MULTI_STATEMENTS')) {
7378
// An added connection option in PHP 5.5.21+ to optionally limit SQL to a

core/includes/database/prefetch.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ class DatabaseStatementPrefetch implements Iterator, DatabaseStatementInterface
265265
* @return
266266
* The current row formatted as requested.
267267
*/
268+
#[\ReturnTypeWillChange]
268269
public function current() {
269270
if (isset($this->currentRow)) {
270271
switch ($this->fetchStyle) {
@@ -315,14 +316,17 @@ class DatabaseStatementPrefetch implements Iterator, DatabaseStatementInterface
315316

316317
/* Implementations of Iterator. */
317318

319+
#[\ReturnTypeWillChange]
318320
public function key() {
319321
return $this->currentKey;
320322
}
321323

324+
#[\ReturnTypeWillChange]
322325
public function rewind() {
323326
// Nothing to do: our DatabaseStatement can't be rewound.
324327
}
325328

329+
#[\ReturnTypeWillChange]
326330
public function next() {
327331
if (!empty($this->data)) {
328332
$this->currentRow = reset($this->data);
@@ -334,6 +338,7 @@ class DatabaseStatementPrefetch implements Iterator, DatabaseStatementInterface
334338
}
335339
}
336340

341+
#[\ReturnTypeWillChange]
337342
public function valid() {
338343
return isset($this->currentRow);
339344
}

core/includes/database/query.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,6 +1737,7 @@ class DatabaseCondition implements QueryConditionInterface, Countable {
17371737
* size of its conditional array minus one, because one element is the
17381738
* conjunction.
17391739
*/
1740+
#[\ReturnTypeWillChange]
17401741
public function count() {
17411742
return count($this->conditions) - 1;
17421743
}

core/includes/date.class.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class BackdropDateTime extends DateTime {
197197
* @return DateTime
198198
* This object with the timezone updated.
199199
*/
200+
#[\ReturnTypeWillChange]
200201
public function setTimezone($timezone, $force = FALSE) {
201202
if (!$this->hasTime() || !$this->hasGranularity('timezone') || $force) {
202203
// This has no time or timezone granularity, so timezone doesn't mean
@@ -228,6 +229,7 @@ class BackdropDateTime extends DateTime {
228229
* @return string|false
229230
* Returns the formatted date string on success or FALSE on failure.
230231
*/
232+
#[\ReturnTypeWillChange]
231233
public function format($format, $force = FALSE) {
232234
// If there are errors, formatting will likely not succeed. Return FALSE.
233235
if (!empty($this->errors)) {

core/includes/file.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function file_stream_wrapper_get_class($scheme) {
196196
* @see file_uri_target()
197197
*/
198198
function file_uri_scheme($uri) {
199-
$position = strpos($uri, '://');
199+
$position = strpos((string) $uri, '://');
200200
return $position ? substr($uri, 0, $position) : FALSE;
201201
}
202202

@@ -524,6 +524,9 @@ function file_save_htaccess($directory, $private = TRUE, $force_overwrite = FALS
524524
/**
525525
* Returns the standard .htaccess lines that Backdrop adds to file directories.
526526
*
527+
* This .htaccess code block is replicated in files/.htaccess. If you update
528+
* this code block then make sure you also update files/.htaccess.
529+
*
527530
* @param $private
528531
* (Optional) Set to FALSE to return the .htaccess lines for an open and
529532
* public directory. The default is TRUE, which returns the .htaccess lines

0 commit comments

Comments
 (0)