Skip to content

Commit f0405ad

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.3
Conflicts: system/CodeIgniter.php user_guide_src/source/installation/upgrading.rst
2 parents 807a16b + d7ba764 commit f0405ad

File tree

15 files changed

+140
-277
lines changed

15 files changed

+140
-277
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ contributing/ export-ignore
1515
.nojekyll export-ignore export-ignore
1616
CODE_OF_CONDUCT.md export-ignore
1717
CONTRIBUTING.md export-ignore
18-
Vagrantfile.dist export-ignore
1918

2019
# They don't want our test files
2120
tests/AutoReview/ export-ignore

Vagrantfile.dist

Lines changed: 0 additions & 203 deletions
This file was deleted.

system/CodeIgniter.php

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use CodeIgniter\HTTP\IncomingRequest;
2222
use CodeIgniter\HTTP\RedirectResponse;
2323
use CodeIgniter\HTTP\Request;
24-
use CodeIgniter\HTTP\RequestInterface;
2524
use CodeIgniter\HTTP\ResponseInterface;
2625
use CodeIgniter\HTTP\URI;
2726
use CodeIgniter\Router\Exceptions\RedirectException;
@@ -55,7 +54,7 @@ class CodeIgniter
5554
/**
5655
* App startup time.
5756
*
58-
* @var mixed
57+
* @var float|null
5958
*/
6059
protected $startTime;
6160

@@ -297,10 +296,9 @@ protected function initializeKint()
297296
* tries to route the response, loads the controller and generally
298297
* makes all of the pieces work together.
299298
*
300-
* @throws Exception
301299
* @throws RedirectException
302300
*
303-
* @return bool|mixed|RequestInterface|ResponseInterface|void
301+
* @return ResponseInterface|void
304302
*/
305303
public function run(?RouteCollectionInterface $routes = null, bool $returnResponse = false)
306304
{
@@ -311,6 +309,8 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
311309
);
312310
}
313311

312+
static::$cacheTTL = 0;
313+
314314
$this->startBenchmark();
315315

316316
$this->getRequestObject();
@@ -323,7 +323,9 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
323323
if ($this->request instanceof IncomingRequest && strtolower($this->request->getMethod()) === 'cli') {
324324
$this->response->setStatusCode(405)->setBody('Method Not Allowed');
325325

326-
return $this->sendResponse();
326+
$this->sendResponse();
327+
328+
return;
327329
}
328330

329331
Events::trigger('pre_system');
@@ -398,7 +400,7 @@ private function isWeb(): bool
398400
* @throws PageNotFoundException
399401
* @throws RedirectException
400402
*
401-
* @return mixed|RequestInterface|ResponseInterface
403+
* @return ResponseInterface
402404
*/
403405
protected function handleRequest(?RouteCollectionInterface $routes, Cache $cacheConfig, bool $returnResponse = false)
404406
{
@@ -463,6 +465,9 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
463465

464466
$filters->setResponse($this->response);
465467

468+
// After filter debug toolbar requires 'total_execution'.
469+
$this->totalTime = $this->benchmark->getElapsedTime('total_execution');
470+
466471
// Run "after" filters
467472
$this->benchmark->start('after_filters');
468473
$response = $filters->run($uri, 'after');
@@ -472,6 +477,17 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
472477
$this->response = $response;
473478
}
474479

480+
// Cache it without the performance metrics replaced
481+
// so that we can have live speed updates along the way.
482+
// Must be run after filters to preserve the Response headers.
483+
if (static::$cacheTTL > 0) {
484+
$this->cachePage($cacheConfig);
485+
}
486+
487+
// Update the performance metrics
488+
$output = $this->displayPerformanceMetrics($this->response->getBody());
489+
$this->response->setBody($output);
490+
475491
// Save our current URI as the previous URI in the session
476492
// for safer, more accurate use with `previous_url()` helper function.
477493
$this->storePreviousURL(current_url(true));
@@ -505,7 +521,7 @@ protected function detectEnvironment()
505521
{
506522
// Make sure ENVIRONMENT isn't already set by other means.
507523
if (! defined('ENVIRONMENT')) {
508-
define('ENVIRONMENT', $_SERVER['CI_ENVIRONMENT'] ?? 'production');
524+
define('ENVIRONMENT', env('CI_ENVIRONMENT', 'production'));
509525
}
510526
}
511527

@@ -617,7 +633,7 @@ protected function forceSecureAccess($duration = 31_536_000)
617633
*
618634
* @throws Exception
619635
*
620-
* @return bool|ResponseInterface
636+
* @return false|ResponseInterface
621637
*/
622638
public function displayCache(Cache $config)
623639
{
@@ -640,7 +656,8 @@ public function displayCache(Cache $config)
640656
$this->response->setHeader($name, $value);
641657
}
642658

643-
$output = $this->displayPerformanceMetrics($output);
659+
$this->totalTime = $this->benchmark->getElapsedTime('total_execution');
660+
$output = $this->displayPerformanceMetrics($output);
644661
$this->response->setBody($output);
645662

646663
return $this->response;
@@ -710,8 +727,6 @@ protected function generateCacheName(Cache $config): string
710727
*/
711728
public function displayPerformanceMetrics(string $output): string
712729
{
713-
$this->totalTime = $this->benchmark->getElapsedTime('total_execution');
714-
715730
return str_replace('{elapsed_time}', (string) $this->totalTime, $output);
716731
}
717732

@@ -921,7 +936,10 @@ protected function display404errors(PageNotFoundException $e)
921936
* Gathers the script output from the buffer, replaces some execution
922937
* time tag in the output and displays the debug toolbar, if required.
923938
*
939+
* @param Cache|null $cacheConfig Deprecated. No longer used.
924940
* @param ResponseInterface|string|null $returned
941+
*
942+
* @deprecated $cacheConfig is deprecated.
925943
*/
926944
protected function gatherOutput(?Cache $cacheConfig = null, $returned = null)
927945
{
@@ -957,14 +975,6 @@ protected function gatherOutput(?Cache $cacheConfig = null, $returned = null)
957975
$this->output .= $returned;
958976
}
959977

960-
// Cache it without the performance metrics replaced
961-
// so that we can have live speed updates along the way.
962-
if (static::$cacheTTL > 0) {
963-
$this->cachePage($cacheConfig);
964-
}
965-
966-
$this->output = $this->displayPerformanceMetrics($this->output);
967-
968978
$this->response->setBody($this->output);
969979
}
970980

@@ -1034,6 +1044,8 @@ public function spoofRequestMethod()
10341044
/**
10351045
* Sends the output of this request back to the client.
10361046
* This is what they've been waiting for!
1047+
*
1048+
* @return void
10371049
*/
10381050
protected function sendResponse()
10391051
{

system/HTTP/DownloadResponse.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ public function setCache(array $options = [])
247247
/**
248248
* {@inheritDoc}
249249
*
250+
* @return $this
251+
*
250252
* @todo Do downloads need CSP or Cookies? Compare with ResponseTrait::send()
251253
*/
252254
public function send()

system/Images/Handlers/ImageMagickHandler.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
/**
2020
* Class ImageMagickHandler
2121
*
22-
* To make this library as compatible as possible with the broadest
23-
* number of installations, we do not use the Imagick extension,
24-
* but simply use the command line version.
25-
*
26-
* hmm - the width & height accessors at the end use the imagick extension.
27-
*
2822
* FIXME - This needs conversion & unit testing, to use the imagick extension
2923
*/
3024
class ImageMagickHandler extends BaseHandler

0 commit comments

Comments
 (0)