Skip to content

Commit f64a4e4

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.3
Conflicts: system/CodeIgniter.php system/Common.php tests/system/CodeIgniterTest.php
2 parents ef8646a + 76e2dac commit f64a4e4

35 files changed

+170
-97
lines changed

.github/workflows/test-phpunit.yml

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ concurrency:
3333

3434
env:
3535
COVERAGE_PHP_VERSION: '8.1'
36+
NLS_LANG: 'AMERICAN_AMERICA.UTF8'
37+
NLS_DATE_FORMAT: 'YYYY-MM-DD HH24:MI:SS'
38+
NLS_TIMESTAMP_FORMAT: 'YYYY-MM-DD HH24:MI:SS'
39+
NLS_TIMESTAMP_TZ_FORMAT: 'YYYY-MM-DD HH24:MI:SS'
3640

3741
jobs:
3842
tests:
@@ -82,12 +86,18 @@ jobs:
8286
options: --health-cmd="/opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q 'SELECT @@VERSION'" --health-interval=10s --health-timeout=5s --health-retries=3
8387

8488
oracle:
85-
image: quillbuilduser/oracle-18-xe
89+
image: gvenzl/oracle-xe:21
8690
env:
87-
ORACLE_ALLOW_REMOTE: true
91+
ORACLE_RANDOM_PASSWORD: true
92+
APP_USER: ORACLE
93+
APP_USER_PASSWORD: ORACLE
8894
ports:
8995
- 1521:1521
90-
options: --health-cmd="/opt/oracle/product/18c/dbhomeXE/bin/sqlplus -s sys/Oracle18@oracledbxe/XE as sysdba <<< 'SELECT 1 FROM DUAL'" --health-interval=10s --health-timeout=5s --health-retries=3
96+
options: >-
97+
--health-cmd healthcheck.sh
98+
--health-interval 20s
99+
--health-timeout 10s
100+
--health-retries 10
91101
92102
redis:
93103
image: redis
@@ -105,28 +115,6 @@ jobs:
105115
if: matrix.db-platforms == 'SQLSRV'
106116
run: sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q "CREATE DATABASE test"
107117

108-
- name: Install Oracle InstantClient
109-
if: matrix.db-platforms == 'OCI8'
110-
run: |
111-
sudo apt-get install wget libaio1 alien
112-
sudo wget https://download.oracle.com/otn_software/linux/instantclient/185000/oracle-instantclient18.5-basic-18.5.0.0.0-3.x86_64.rpm
113-
sudo wget https://download.oracle.com/otn_software/linux/instantclient/185000/oracle-instantclient18.5-devel-18.5.0.0.0-3.x86_64.rpm
114-
sudo wget https://download.oracle.com/otn_software/linux/instantclient/185000/oracle-instantclient18.5-sqlplus-18.5.0.0.0-3.x86_64.rpm
115-
sudo alien oracle-instantclient18.5-basic-18.5.0.0.0-3.x86_64.rpm
116-
sudo alien oracle-instantclient18.5-devel-18.5.0.0.0-3.x86_64.rpm
117-
sudo alien oracle-instantclient18.5-sqlplus-18.5.0.0.0-3.x86_64.rpm
118-
sudo dpkg -i oracle-instantclient18.5-basic_18.5.0.0.0-4_amd64.deb oracle-instantclient18.5-devel_18.5.0.0.0-4_amd64.deb oracle-instantclient18.5-sqlplus_18.5.0.0.0-4_amd64.deb
119-
echo "LD_LIBRARY_PATH=/lib/oracle/18.5/client64/lib/" >> $GITHUB_ENV
120-
echo "NLS_LANG=AMERICAN_AMERICA.UTF8" >> $GITHUB_ENV
121-
echo "C_INCLUDE_PATH=/usr/include/oracle/18.5/client64" >> $GITHUB_ENV
122-
echo 'NLS_DATE_FORMAT=YYYY-MM-DD HH24:MI:SS' >> $GITHUB_ENV
123-
echo 'NLS_TIMESTAMP_FORMAT=YYYY-MM-DD HH24:MI:SS' >> $GITHUB_ENV
124-
echo 'NLS_TIMESTAMP_TZ_FORMAT=YYYY-MM-DD HH24:MI:SS' >> $GITHUB_ENV
125-
126-
- name: Create database for Oracle Database
127-
if: matrix.db-platforms == 'OCI8'
128-
run: echo -e "ALTER SESSION SET CONTAINER = XEPDB1;\nCREATE BIGFILE TABLESPACE \"TEST\" DATAFILE '/opt/oracle/product/18c/dbhomeXE/dbs/TEST' SIZE 10M AUTOEXTEND ON MAXSIZE UNLIMITED SEGMENT SPACE MANAGEMENT AUTO EXTENT MANAGEMENT LOCAL AUTOALLOCATE;\nCREATE USER \"ORACLE\" IDENTIFIED BY \"ORACLE\" DEFAULT TABLESPACE \"TEST\" TEMPORARY TABLESPACE TEMP QUOTA UNLIMITED ON \"TEST\";\nGRANT CONNECT,RESOURCE TO \"ORACLE\";\nexit;" | /lib/oracle/18.5/client64/bin/sqlplus -s sys/Oracle18@localhost:1521/XE as sysdba
129-
130118
- name: Checkout
131119
uses: actions/checkout@v3
132120

system/CodeIgniter.php

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ class CodeIgniter
159159
*/
160160
protected bool $enableFilters = true;
161161

162+
/**
163+
* Whether to return Response object or send response.
164+
*/
165+
protected bool $returnResponse = false;
166+
162167
/**
163168
* Constructor.
164169
*/
@@ -312,6 +317,8 @@ private function configureKint(): void
312317
*/
313318
public function run(?RouteCollectionInterface $routes = null, bool $returnResponse = false)
314319
{
320+
$this->returnResponse = $returnResponse;
321+
315322
if ($this->context === null) {
316323
throw new LogicException(
317324
'Context must be set before run() is called. If you are upgrading from 4.1.x, '
@@ -333,6 +340,10 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
333340
if ($this->request instanceof IncomingRequest && strtolower($this->request->getMethod()) === 'cli') {
334341
$this->response->setStatusCode(405)->setBody('Method Not Allowed');
335342

343+
if ($this->returnResponse) {
344+
return $this->response;
345+
}
346+
336347
$this->sendResponse();
337348

338349
return;
@@ -364,13 +375,22 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
364375
// If the route is a 'redirect' route, it throws
365376
// the exception with the $to as the message
366377
$this->response->redirect(base_url($e->getMessage()), 'auto', $e->getCode());
378+
379+
if ($this->returnResponse) {
380+
return $this->response;
381+
}
382+
367383
$this->sendResponse();
368384

369385
$this->callExit(EXIT_SUCCESS);
370386

371387
return;
372388
} catch (PageNotFoundException $e) {
373-
$this->display404errors($e);
389+
$return = $this->display404errors($e);
390+
391+
if ($return instanceof ResponseInterface) {
392+
return $return;
393+
}
374394
}
375395
}
376396

@@ -421,9 +441,13 @@ public function disableFilters(): void
421441
*
422442
* @throws PageNotFoundException
423443
* @throws RedirectException
444+
*
445+
* @deprecated $returnResponse is deprecated.
424446
*/
425447
protected function handleRequest(?RouteCollectionInterface $routes, Cache $cacheConfig, bool $returnResponse = false)
426448
{
449+
$this->returnResponse = $returnResponse;
450+
427451
$routeFilter = $this->tryToRouteIt($routes);
428452

429453
$uri = $this->determinePath();
@@ -453,7 +477,7 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
453477

454478
// If a ResponseInterface instance is returned then send it back to the client and stop
455479
if ($possibleResponse instanceof ResponseInterface) {
456-
return $returnResponse ? $possibleResponse : $possibleResponse->send();
480+
return $this->returnResponse ? $possibleResponse : $possibleResponse->send();
457481
}
458482

459483
if ($possibleResponse instanceof Request) {
@@ -528,7 +552,7 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
528552

529553
unset($uri);
530554

531-
if (! $returnResponse) {
555+
if (! $this->returnResponse) {
532556
$this->sendResponse();
533557
}
534558

@@ -919,6 +943,8 @@ protected function runController($class)
919943
/**
920944
* Displays a 404 Page Not Found error. If set, will try to
921945
* call the 404Override controller/method that was set in routing config.
946+
*
947+
* @return ResponseInterface|void
922948
*/
923949
protected function display404errors(PageNotFoundException $e)
924950
{
@@ -943,6 +969,10 @@ protected function display404errors(PageNotFoundException $e)
943969

944970
$cacheConfig = new Cache();
945971
$this->gatherOutput($cacheConfig, $returned);
972+
if ($this->returnResponse) {
973+
return $this->response;
974+
}
975+
946976
$this->sendResponse();
947977

948978
return;

system/Common.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ function command(string $command)
147147
$args[] = stripcslashes($match[1]);
148148
} else {
149149
// @codeCoverageIgnoreStart
150-
throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ...".', substr($command, $cursor, 10)));
150+
throw new InvalidArgumentException(sprintf(
151+
'Unable to parse input near "... %s ...".',
152+
substr($command, $cursor, 10)
153+
));
151154
// @codeCoverageIgnoreEnd
152155
}
153156

@@ -477,18 +480,13 @@ function force_https(int $duration = 31_536_000, ?RequestInterface $request = nu
477480
}
478481

479482
if ((ENVIRONMENT !== 'testing' && (is_cli() || $request->isSecure())) || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'test')) {
480-
// @codeCoverageIgnoreStart
481-
return;
482-
// @codeCoverageIgnoreEnd
483+
return; // @codeCoverageIgnore
483484
}
484485

485486
// If the session status is active, we should regenerate
486487
// the session ID for safety sake.
487488
if (ENVIRONMENT !== 'testing' && session_status() === PHP_SESSION_ACTIVE) {
488-
// @codeCoverageIgnoreStart
489-
Services::session(null, true)
490-
->regenerate();
491-
// @codeCoverageIgnoreEnd
489+
Services::session(null, true)->regenerate(); // @codeCoverageIgnore
492490
}
493491

494492
$baseURL = config(App::class)->baseURL;
@@ -513,9 +511,7 @@ function force_https(int $duration = 31_536_000, ?RequestInterface $request = nu
513511
$response->sendHeaders();
514512

515513
if (ENVIRONMENT !== 'testing') {
516-
// @codeCoverageIgnoreStart
517-
exit();
518-
// @codeCoverageIgnoreEnd
514+
exit(); // @codeCoverageIgnore
519515
}
520516
}
521517
}
@@ -779,10 +775,7 @@ function log_message(string $level, string $message, array $context = [])
779775
return $logger->log($level, $message, $context);
780776
}
781777

782-
// @codeCoverageIgnoreStart
783-
return Services::logger(true)
784-
->log($level, $message, $context);
785-
// @codeCoverageIgnoreEnd
778+
return Services::logger(true)->log($level, $message, $context); // @codeCoverageIgnore
786779
}
787780
}
788781

@@ -817,9 +810,7 @@ function old(string $key, $default = null, $escape = 'html')
817810
{
818811
// Ensure the session is loaded
819812
if (session_status() === PHP_SESSION_NONE && ENVIRONMENT !== 'testing') {
820-
// @codeCoverageIgnoreStart
821-
session();
822-
// @codeCoverageIgnoreEnd
813+
session(); // @codeCoverageIgnore
823814
}
824815

825816
$request = Services::request();

system/Format/XMLFormatter.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ public function format($data)
3434
// SimpleXML is installed but default
3535
// but best to check, and then provide a fallback.
3636
if (! extension_loaded('simplexml')) {
37-
// never thrown in travis-ci
38-
// @codeCoverageIgnoreStart
39-
throw FormatException::forMissingExtension();
40-
// @codeCoverageIgnoreEnd
37+
throw FormatException::forMissingExtension(); // @codeCoverageIgnore
4138
}
4239

4340
$options = $config->formatterOptions['application/xml'] ?? 0;

system/Images/Handlers/ImageMagickHandler.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,9 @@ public function __construct($config = null)
4141
{
4242
parent::__construct($config);
4343

44-
// We should never see this, so can't test it
45-
// @codeCoverageIgnoreStart
4644
if (! (extension_loaded('imagick') || class_exists(Imagick::class))) {
47-
throw ImageException::forMissingExtension('IMAGICK');
45+
throw ImageException::forMissingExtension('IMAGICK'); // @codeCoverageIgnore
4846
}
49-
// @codeCoverageIgnoreEnd
5047
}
5148

5249
/**

system/Test/DOMParser.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ class DOMParser
3737
public function __construct()
3838
{
3939
if (! extension_loaded('DOM')) {
40-
// always there in travis-ci
41-
// @codeCoverageIgnoreStart
42-
throw new BadMethodCallException('DOM extension is required, but not currently loaded.');
43-
// @codeCoverageIgnoreEnd
40+
throw new BadMethodCallException('DOM extension is required, but not currently loaded.'); // @codeCoverageIgnore
4441
}
4542

4643
$this->dom = new DOMDocument('1.0', 'utf-8');

system/Test/FeatureTestCase.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,9 @@ public function call(string $method, string $path, ?array $params = null)
159159

160160
// Clean up any open output buffers
161161
// not relevant to unit testing
162-
// @codeCoverageIgnoreStart
163162
if (\ob_get_level() > 0 && (! isset($this->clean) || $this->clean === true)) {
164-
\ob_end_clean();
163+
\ob_end_clean(); // @codeCoverageIgnore
165164
}
166-
// @codeCoverageIgnoreEnd
167165

168166
// Simulate having a blank session
169167
$_SESSION = [];
@@ -202,15 +200,13 @@ public function call(string $method, string $path, ?array $params = null)
202200
Services::router()->setDirectory(null);
203201

204202
// Ensure the output buffer is identical so no tests are risky
205-
// @codeCoverageIgnoreStart
206203
while (\ob_get_level() > $buffer) {
207-
\ob_end_clean();
204+
\ob_end_clean(); // @codeCoverageIgnore
208205
}
209206

210207
while (\ob_get_level() < $buffer) {
211-
\ob_start();
208+
\ob_start(); // @codeCoverageIgnore
212209
}
213-
// @codeCoverageIgnoreEnd
214210

215211
return new FeatureResponse($response);
216212
}

system/Test/FeatureTestTrait.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,9 @@ public function call(string $method, string $path, ?array $params = null)
149149

150150
// Clean up any open output buffers
151151
// not relevant to unit testing
152-
// @codeCoverageIgnoreStart
153152
if (\ob_get_level() > 0 && (! isset($this->clean) || $this->clean === true)) {
154-
\ob_end_clean();
153+
\ob_end_clean(); // @codeCoverageIgnore
155154
}
156-
// @codeCoverageIgnoreEnd
157155

158156
// Simulate having a blank session
159157
$_SESSION = [];
@@ -192,15 +190,13 @@ public function call(string $method, string $path, ?array $params = null)
192190
Services::router()->setDirectory(null);
193191

194192
// Ensure the output buffer is identical so no tests are risky
195-
// @codeCoverageIgnoreStart
196193
while (\ob_get_level() > $buffer) {
197-
\ob_end_clean();
194+
\ob_end_clean(); // @codeCoverageIgnore
198195
}
199196

200197
while (\ob_get_level() < $buffer) {
201-
\ob_start();
198+
\ob_start(); // @codeCoverageIgnore
202199
}
203-
// @codeCoverageIgnoreEnd
204200

205201
return new TestResponse($response);
206202
}

tests/_support/Database/Seeds/CITestSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function run()
167167
}
168168

169169
if ($this->db->DBDriver === 'OCI8') {
170-
$this->db->query('alter session set NLS_DATE_FORMAT=?', ['YYYY/MM/DD HH24:MI:SS']);
170+
$this->db->query('alter session set NLS_DATE_FORMAT=?', ['YYYY-MM-DD HH24:MI:SS']);
171171
$data['type_test'][0]['type_time'] = '2020-07-18 15:22:00';
172172
$data['type_test'][0]['type_date'] = '2020-01-11 22:11:00';
173173
$data['type_test'][0]['type_time'] = '2020-07-18 15:22:00';

0 commit comments

Comments
 (0)