Skip to content

Commit 71e92f6

Browse files
authored
Merge branch 'codeigniter4:develop' into fix/xml-export-zero-value
2 parents a4f7c65 + ad8526f commit 71e92f6

7 files changed

Lines changed: 19 additions & 27 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"psr/log": "^3.0"
1818
},
1919
"require-dev": {
20-
"boundwize/structarmed": "0.14.6",
20+
"boundwize/structarmed": "0.14.7",
2121
"codeigniter/phpstan-codeigniter": "^2.1",
2222
"fakerphp/faker": "^1.24",
2323
"kint-php/kint": "^6.1",

system/Common.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,21 @@ function command(string $command)
185185
$params[$arg] = $value;
186186
}
187187

188+
$bufferLevel = ob_get_level();
189+
188190
try {
189191
ob_start();
190192
service('commands')->run($command, $params);
191193

194+
if (ob_get_level() <= $bufferLevel) {
195+
return false;
196+
}
197+
192198
return ob_get_contents();
193199
} finally {
194-
ob_end_clean();
200+
while (ob_get_level() > $bufferLevel) {
201+
ob_end_clean();
202+
}
195203
}
196204
}
197205
}

tests/system/CommonFunctionsSendTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ public function testRedirectResponseCookiesSent(): void
5858
// send it
5959
ob_start();
6060
$response->send();
61-
if (ob_get_level() > 0) {
62-
ob_end_clean();
63-
}
61+
ob_end_clean();
6462

6563
// and what actually got sent?
6664
$this->assertHeaderEmitted('Set-Cookie: foo=onething;');

tests/system/HTTP/DownloadResponseTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,7 @@ public function testRealOutput(): void
377377
// send it
378378
ob_start();
379379
$response->send();
380-
if (ob_get_level() > 0) {
381-
ob_end_clean();
382-
}
380+
ob_end_clean();
383381

384382
// and what actually got sent?
385383
$this->assertHeaderEmitted('Content-Length: ' . filesize(__FILE__));

tests/system/HTTP/ResponseSendTest.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ public function testHeadersMissingDate(): void
6767
// send it
6868
ob_start();
6969
$response->send();
70-
if (ob_get_level() > 0) {
71-
ob_end_clean();
72-
}
70+
ob_end_clean();
7371

7472
// and what actually got sent?
7573
$this->assertHeaderEmitted('Date:');
@@ -102,9 +100,7 @@ public function testHeadersWithCSP(): void
102100
// send it
103101
ob_start();
104102
$response->send();
105-
if (ob_get_level() > 0) {
106-
ob_end_clean();
107-
}
103+
ob_end_clean();
108104

109105
// and what actually got sent?; test both ways
110106
$this->assertHeaderEmitted('Content-Security-Policy:');
@@ -140,9 +136,7 @@ public function testRedirectResponseCookies(): void
140136
// send it
141137
ob_start();
142138
$response->send();
143-
if (ob_get_level() > 0) {
144-
ob_end_clean();
145-
}
139+
ob_end_clean();
146140

147141
// and what actually got sent?
148142
$this->assertHeaderEmitted('Set-Cookie: foo=bar;');
@@ -213,9 +207,7 @@ public function testHeaderOverride(): void
213207
header('Access-Control-Expose-Headers: Content-Encoding');
214208
header('Allow: GET, POST');
215209
$response->send();
216-
if (ob_get_level() > 0) {
217-
ob_end_clean();
218-
}
210+
ob_end_clean();
219211

220212
// single header
221213
$this->assertHeaderEmitted('Vary: Accept-Encoding');

tests/system/Test/BootstrapFCPATHTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private function fileContents(): string
100100
return $fileContents . 'echo FCPATH;' . PHP_EOL;
101101
}
102102

103-
private function readOutput(string $file): false|string
103+
private function readOutput(string $file): string
104104
{
105105
ob_start();
106106
system('php -f ' . $file);

tests/system/Test/TestCaseEmissionsTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ public function testHeadersEmitted(): void
6262
// send it
6363
ob_start();
6464
$response->send();
65-
if (ob_get_level() > 0) {
66-
ob_end_clean();
67-
}
65+
ob_end_clean();
6866

6967
// and what actually got sent?; test both ways
7068
$this->assertHeaderEmitted('Set-Cookie: foo=bar;');
@@ -90,9 +88,7 @@ public function testHeadersNotEmitted(): void
9088
// send it
9189
ob_start();
9290
$response->send(); // what really was sent
93-
if (ob_get_level() > 0) {
94-
ob_end_clean();
95-
}
91+
ob_end_clean();
9692

9793
$this->assertHeaderNotEmitted('Set-Cookie: pop=corn', true);
9894
}

0 commit comments

Comments
 (0)