Skip to content

Commit f048e06

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.8
2 parents 07e815b + eb6ac9f commit f048e06

File tree

27 files changed

+410
-175
lines changed

27 files changed

+410
-175
lines changed

.github/workflows/reusable-phpunit-test.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ env:
6565
jobs:
6666
tests:
6767
name: ${{ inputs.job-name }}
68-
runs-on: ubuntu-22.04
68+
runs-on: ubuntu-24.04
6969

7070
# Service containers cannot be extracted to caller workflows yet
7171
services:
@@ -97,7 +97,7 @@ jobs:
9797
--health-retries=3
9898
9999
mssql:
100-
image: mcr.microsoft.com/mssql/server:2022-latest
100+
image: mcr.microsoft.com/mssql/server:2025-CU2-ubuntu-24.04
101101
env:
102102
MSSQL_SA_PASSWORD: 1Secure*Password1
103103
ACCEPT_EULA: Y
@@ -140,17 +140,32 @@ jobs:
140140
- 11211:11211
141141

142142
steps:
143+
- name: Install mssql-tools on runner
144+
if: ${{ inputs.db-platform == 'SQLSRV' }}
145+
run: |
146+
# Detect Ubuntu version used by the runner (fallback to 24.04)
147+
DISTRO=$(lsb_release -rs 2>/dev/null || echo '24.04')
148+
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
149+
curl -sSL https://packages.microsoft.com/config/ubuntu/${DISTRO}/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
150+
sudo apt-get update
151+
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 unixodbc-dev
152+
153+
# Make sqlcmd available to subsequent steps
154+
echo "/opt/mssql-tools18/bin" >> $GITHUB_PATH
155+
143156
- name: Create database for MSSQL Server
144157
if: ${{ inputs.db-platform == 'SQLSRV' }}
145-
run: sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q "CREATE DATABASE test COLLATE Latin1_General_100_CS_AS_SC_UTF8"
158+
run: |
159+
sqlcmd -S 127.0.0.1 \
160+
-U sa -P 1Secure*Password1 \
161+
-N -C \
162+
-Q "CREATE DATABASE test COLLATE Latin1_General_100_CS_AS_SC_UTF8"
146163
147164
- name: Install latest ImageMagick
148165
if: ${{ contains(inputs.extra-extensions, 'imagick') }}
149166
run: |
150167
sudo apt-get update
151-
sudo apt-get install --reinstall libgs9-common fonts-noto-mono libgs9:amd64 libijs-0.35:amd64 fonts-urw-base35 ghostscript poppler-data libjbig2dec0:amd64 libopenjp2-7:amd64 fonts-droid-fallback fonts-dejavu-core
152-
sudo apt-get install -y gsfonts libmagickwand-dev imagemagick
153-
sudo apt-get install --fix-broken
168+
sudo apt-get install -y imagemagick libmagickwand-dev ghostscript poppler-data libjbig2dec0:amd64 libopenjp2-7:amd64
154169
155170
- name: Checkout base branch for PR
156171
if: github.event_name == 'pull_request'

.github/workflows/reusable-serviceless-phpunit-test.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ jobs:
6060
if: ${{ contains(inputs.extra-extensions, 'imagick') }}
6161
run: |
6262
sudo apt-get update
63-
sudo apt-get install --reinstall libgs9-common fonts-noto-mono libgs9:amd64 libijs-0.35:amd64 fonts-urw-base35 ghostscript poppler-data libjbig2dec0:amd64 gsfonts libopenjp2-7:amd64 fonts-droid-fallback fonts-dejavu-core
64-
sudo apt-get install -y imagemagick
65-
sudo apt-get install --fix-broken
63+
sudo apt-get install -y imagemagick libmagickwand-dev ghostscript poppler-data libjbig2dec0:amd64 libopenjp2-7:amd64
6664
6765
- name: Checkout base branch for PR
6866
if: github.event_name == 'pull_request'

.github/workflows/test-phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
# in the caller workflow are not propagated to the called workflow.
4242
coverage-php-version:
4343
name: Setup PHP Version for Code Coverage
44-
runs-on: ubuntu-22.04
44+
runs-on: ubuntu-24.04
4545
outputs:
4646
version: ${{ steps.coverage-php-version.outputs.version }}
4747
steps:

app/Config/Database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class Database extends Config
180180
'swapPre' => '',
181181
'encrypt' => false,
182182
'compress' => false,
183-
'strictOn' => false,
183+
'strictOn' => true,
184184
'failover' => [],
185185
'port' => 3306,
186186
'foreignKeys' => true,

app/Config/WorkerMode.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ class WorkerMode
4040
'cache',
4141
];
4242

43+
/**
44+
* Reset Event Listeners
45+
*
46+
* List of event names whose listeners should be removed between requests.
47+
* Use this if you register event listeners inside other event callbacks
48+
* (rather than at the top level of Config/Events.php), which would cause
49+
* them to accumulate across requests in worker mode.
50+
*
51+
* @var list<string>
52+
*/
53+
public array $resetEventListeners = [];
54+
4355
/**
4456
* Force Garbage Collection
4557
*

system/CLI/CLI.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,35 @@ protected static function fwrite($handle, string $string)
10991099
/**
11001100
* Testing purpose only
11011101
*
1102-
* @testTag
1102+
* @internal
1103+
*/
1104+
public static function reset(): void
1105+
{
1106+
static::$initialized = false;
1107+
static::$segments = [];
1108+
static::$options = [];
1109+
static::$lastWrite = 'write';
1110+
static::$height = null;
1111+
static::$width = null;
1112+
static::$isColored = static::hasColorSupport(STDOUT);
1113+
1114+
static::resetInputOutput();
1115+
}
1116+
1117+
/**
1118+
* Testing purpose only
1119+
*
1120+
* @internal
1121+
*/
1122+
public static function resetLastWrite(): void
1123+
{
1124+
static::$lastWrite = null;
1125+
}
1126+
1127+
/**
1128+
* Testing purpose only
1129+
*
1130+
* @internal
11031131
*/
11041132
public static function setInputOutput(InputOutput $io): void
11051133
{
@@ -1109,7 +1137,7 @@ public static function setInputOutput(InputOutput $io): void
11091137
/**
11101138
* Testing purpose only
11111139
*
1112-
* @testTag
1140+
* @internal
11131141
*/
11141142
public static function resetInputOutput(): void
11151143
{

system/Commands/Worker/Views/frankenphp-worker.php.tpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ while (frankenphp_handle_request($handler)) {
122122
// Reset services except persistent ones
123123
Services::resetForWorkerMode($workerConfig);
124124

125+
// Reset event listeners
126+
Events::cleanupForWorkerMode($workerConfig->resetEventListeners);
127+
125128
if (CI_DEBUG) {
126-
Events::cleanupForWorkerMode();
127129
Services::toolbar()->reset();
128130
}
129131
}

system/Database/SQLSRV/Forge.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,25 @@ public function createDatabase(string $dbName, bool $ifNotExists = false): bool
168168
}
169169
}
170170

171+
/**
172+
* {@inheritDoc}
173+
*
174+
* @see https://stackoverflow.com/questions/7469130/cannot-drop-database-because-it-is-currently-in-use
175+
*/
176+
public function dropDatabase(string $dbName): bool
177+
{
178+
try {
179+
$this->db->query(sprintf(
180+
'ALTER DATABASE %s SET SINGLE_USER WITH ROLLBACK IMMEDIATE',
181+
$this->db->escapeIdentifier($dbName),
182+
));
183+
} catch (DatabaseException) {
184+
// no-op
185+
}
186+
187+
return parent::dropDatabase($dbName);
188+
}
189+
171190
/**
172191
* CREATE TABLE attributes
173192
*/

system/Events/Events.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,18 @@ public static function getPerformanceLogs()
289289
* Cleanup performance log and request-specific listeners for worker mode.
290290
*
291291
* Called at the END of each request to clean up state.
292+
*
293+
* @param list<string> $resetEventListeners Additional event names to reset.
292294
*/
293-
public static function cleanupForWorkerMode(): void
295+
public static function cleanupForWorkerMode(array $resetEventListeners = []): void
294296
{
295-
static::$performanceLog = [];
296-
static::removeAllListeners('DBQuery');
297+
if (CI_DEBUG) {
298+
static::$performanceLog = [];
299+
static::removeAllListeners('DBQuery');
300+
}
301+
302+
foreach ($resetEventListeners as $event) {
303+
static::removeAllListeners($event);
304+
}
297305
}
298306
}

system/HTTP/ContentSecurityPolicy.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,10 @@ public function getStyleNonce(): string
400400
if ($this->styleNonce === null) {
401401
$this->styleNonce = base64_encode(random_bytes(12));
402402
$this->addStyleSrc('nonce-' . $this->styleNonce);
403+
404+
if ($this->styleSrcElem !== []) {
405+
$this->addStyleSrcElem('nonce-' . $this->styleNonce);
406+
}
403407
}
404408

405409
return $this->styleNonce;
@@ -413,6 +417,10 @@ public function getScriptNonce(): string
413417
if ($this->scriptNonce === null) {
414418
$this->scriptNonce = base64_encode(random_bytes(12));
415419
$this->addScriptSrc('nonce-' . $this->scriptNonce);
420+
421+
if ($this->scriptSrcElem !== []) {
422+
$this->addScriptSrcElem('nonce-' . $this->scriptNonce);
423+
}
416424
}
417425

418426
return $this->scriptNonce;

0 commit comments

Comments
 (0)