Skip to content

Commit 8ff764e

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.8
2 parents 86da134 + f44bf11 commit 8ff764e

53 files changed

Lines changed: 469 additions & 343 deletions

Some content is hidden

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

.github/scripts/random-tests-config.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Autoloader
1414
# Cache
1515
CLI
1616
# Commands
17-
# Config
17+
Config
1818
Cookie
1919
# DataCaster
2020
# DataConverter
@@ -29,7 +29,7 @@ Files
2929
Format
3030
# HTTP
3131
# Helpers
32-
# Honeypot
32+
Honeypot
3333
HotReloader
3434
# I18n
3535
# Images
@@ -42,7 +42,7 @@ RESTful
4242
# Router
4343
Security
4444
# Session
45-
# Test
45+
Test
4646
Throttle
4747
Typography
4848
# Validation

.github/workflows/label-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ jobs:
4242
console.log('No changes to workflow file detected, proceeding with label addition.');
4343
4444
- name: Add labels
45-
uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # v6.0.1
45+
uses: actions/labeler@f27b608878404679385c85cfa523b85ccb86e213 # v6.1.0
4646
with:
4747
sync-labels: true # Remove labels when matching files are reverted

psalm-autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
$iterator = new RecursiveIteratorIterator(
2525
new RecursiveDirectoryIterator(
2626
$directory,
27-
RecursiveDirectoryIterator::UNIX_PATHS | RecursiveDirectoryIterator::CURRENT_AS_FILEINFO,
27+
RecursiveDirectoryIterator::UNIX_PATHS | RecursiveDirectoryIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS,
2828
),
2929
RecursiveIteratorIterator::CHILD_FIRST,
3030
);

rector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
__DIR__ . '/tests',
6868
__DIR__ . '/utils/src',
6969
])
70+
->withRootFiles()
7071
// do you need to include constants, class aliases or custom autoloader? files listed will be executed
7172
->withBootstrapFiles([
7273
__DIR__ . '/phpstan-bootstrap.php',

system/CLI/CLI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,8 @@ public static function generateDimensions()
754754
static::$height = (int) $matches[1];
755755
static::$width = (int) $matches[2];
756756
} else {
757-
static::$height = (int) exec('tput lines');
758-
static::$width = (int) exec('tput cols');
757+
static::$height = (int) exec('tput lines 2>/dev/null');
758+
static::$width = (int) exec('tput cols 2>/dev/null');
759759
}
760760
} catch (Throwable $e) {
761761
// Reset the dimensions so that the default values will be returned later.

system/Commands/Encryption/GenerateKey.php

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -165,36 +165,41 @@ private function writeNewEncryptionKeyToFile(string $oldKey, string $newKey): bo
165165
}
166166

167167
$oldFileContents = (string) file_get_contents($envFile);
168-
$replacementKey = "\nencryption.key = {$newKey}";
169168

170-
if (! str_contains($oldFileContents, 'encryption.key')) {
171-
return file_put_contents($envFile, $replacementKey, FILE_APPEND) !== false;
169+
// Match an active setting line, preserving any leading whitespace and `export` prefix.
170+
$activePattern = $this->keyPattern($oldKey);
171+
172+
if (preg_match($activePattern, $oldFileContents) === 1) {
173+
$newFileContents = (string) preg_replace($activePattern, '$1' . $newKey, $oldFileContents, 1);
174+
175+
return file_put_contents($envFile, $newFileContents) !== false;
172176
}
173177

174-
$newFileContents = preg_replace($this->keyPattern($oldKey), $replacementKey, $oldFileContents);
178+
// Match a commented-out setting line (e.g., from the shipped `env` template) and
179+
// uncomment it. The optional `export` prefix is dropped on uncomment for predictability.
180+
$commentedPattern = '/^\h*#\h*(?:export\h+)?encryption\.key\h*=\h*[^\r\n]*$/m';
181+
182+
if (preg_match($commentedPattern, $oldFileContents) === 1) {
183+
$newFileContents = (string) preg_replace($commentedPattern, "encryption.key = {$newKey}", $oldFileContents, 1);
175184

176-
if ($newFileContents === $oldFileContents) {
177-
$newFileContents = preg_replace(
178-
'/^[#\s]*encryption.key[=\s]*(?:hex2bin\:[a-f0-9]{64}|base64\:(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?)$/m',
179-
$replacementKey,
180-
$oldFileContents,
181-
);
185+
return file_put_contents($envFile, $newFileContents) !== false;
182186
}
183187

184-
return file_put_contents($envFile, $newFileContents) !== false;
188+
// No setting present (active or commented); append.
189+
return file_put_contents($envFile, "\nencryption.key = {$newKey}", FILE_APPEND) !== false;
185190
}
186191

187192
/**
188-
* Get the regex of the current encryption key.
193+
* Returns the regex used to locate an active `encryption.key = ...` setting in the `.env`
194+
* contents. The single capture group spans everything up to (and including) the `=` and any
195+
* separating whitespace, so a `preg_replace` substitution preserves an optional `export`
196+
* prefix while rewriting only the value.
197+
*
198+
* The `$oldKey` parameter is retained for backward compatibility with subclasses that
199+
* override this method; it is no longer consulted because the pattern matches any value.
189200
*/
190201
private function keyPattern(string $oldKey): string
191202
{
192-
$escaped = preg_quote($oldKey, '/');
193-
194-
if ($escaped !== '') {
195-
$escaped = "[{$escaped}]*";
196-
}
197-
198-
return "/^[#\\s]*encryption.key[=\\s]*{$escaped}$/m";
203+
return '/^(\h*(?:export\h+)?encryption\.key\h*=\h*)[^\r\n]*$/m';
199204
}
200205
}

system/Database/BaseConnection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1843,9 +1843,11 @@ protected function getDriverFunctionPrefix(): string
18431843
public function listTables(bool $constrainByPrefix = false)
18441844
{
18451845
if (isset($this->dataCache['table_names']) && $this->dataCache['table_names']) {
1846-
return $constrainByPrefix
1846+
$tables = $constrainByPrefix
18471847
? preg_grep("/^{$this->DBPrefix}/", $this->dataCache['table_names'])
18481848
: $this->dataCache['table_names'];
1849+
1850+
return array_values($tables);
18491851
}
18501852

18511853
$sql = $this->_listTables($constrainByPrefix);

system/Database/BasePreparedQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ abstract public function _execute(array $data): bool;
192192
/**
193193
* Returns the result object for the prepared query.
194194
*
195-
* @return object|resource|null
195+
* @return false|object|resource|null
196196
*/
197197
abstract public function _getResult();
198198

system/Database/ConnectionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getDatabase(): string;
7878
* Must return this format: ['code' => string|int, 'message' => string]
7979
* intval(code) === 0 means "no error".
8080
*
81-
* @return array<string, int|string>
81+
* @return array{code: int|string|null, message: string|null}
8282
*/
8383
public function error(): array;
8484

system/Database/MySQLi/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ protected function _enableForeignKeyChecks()
605605
* Must return this format: ['code' => string|int, 'message' => string]
606606
* intval(code) === 0 means "no error".
607607
*
608-
* @return array<string, int|string>
608+
* @return array{code: int|string|null, message: string|null}
609609
*/
610610
public function error(): array
611611
{

0 commit comments

Comments
 (0)