Skip to content

Commit 9416553

Browse files
committed
Merge branch 'develop' into testing14/http
2 parents e0b63d3 + 3b31bfd commit 9416553

139 files changed

Lines changed: 700 additions & 387 deletions

File tree

Some content is hidden

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

admin/framework/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"ext-curl": "*",
1010
"ext-intl": "*",
1111
"kint-php/kint": "^2.1",
12+
"psr/log": "^1.1",
1213
"zendframework/zend-escaper": "^2.5"
1314
},
1415
"require-dev": {
@@ -19,8 +20,7 @@
1920
},
2021
"autoload": {
2122
"psr-4": {
22-
"CodeIgniter\\": "system/",
23-
"Psr\\Log\\": "system/ThirdParty/PSR/Log/"
23+
"CodeIgniter\\": "system/"
2424
}
2525
},
2626
"scripts": {

application/Config/App.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -264,30 +264,6 @@ class App extends BaseConfig
264264
*/
265265
public $CSPEnabled = false;
266266

267-
/*
268-
|--------------------------------------------------------------------------
269-
| Debug Toolbar
270-
|--------------------------------------------------------------------------
271-
| The Debug Toolbar provides a way to see information about the performance
272-
| and state of your application during that page display. By default it will
273-
| NOT be displayed under production environments, and will only display if
274-
| CI_DEBUG is true, since if it's not, there's not much to display anyway.
275-
|
276-
| toolbarMaxHistory = Number of history files, 0 for none or -1 for unlimited
277-
|
278-
*/
279-
public $toolbarCollectors = [
280-
'CodeIgniter\Debug\Toolbar\Collectors\Timers',
281-
'CodeIgniter\Debug\Toolbar\Collectors\Database',
282-
'CodeIgniter\Debug\Toolbar\Collectors\Logs',
283-
'CodeIgniter\Debug\Toolbar\Collectors\Views',
284-
// 'CodeIgniter\Debug\Toolbar\Collectors\Cache',
285-
'CodeIgniter\Debug\Toolbar\Collectors\Files',
286-
'CodeIgniter\Debug\Toolbar\Collectors\Routes',
287-
'CodeIgniter\Debug\Toolbar\Collectors\Events',
288-
];
289-
public $toolbarMaxHistory = 20;
290-
291267
/*
292268
|--------------------------------------------------------------------------
293269
| Application Salt

application/Config/Events.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
{
3030
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
3131

32-
// Handles the display of the toolbar itself. MUST remain here for toolbar to be displayed.
33-
Events::on('pre_system', 'CodeIgniter\Debug\Toolbar::eventHandler');
32+
Events::on('pre_system', function () {
33+
Services::toolbar()->respond();
34+
});
3435
}

application/Config/Toolbar.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php namespace Config;
2+
3+
use CodeIgniter\Config\BaseConfig;
4+
5+
class Toolbar extends BaseConfig
6+
{
7+
/*
8+
|--------------------------------------------------------------------------
9+
| Debug Toolbar
10+
|--------------------------------------------------------------------------
11+
| The Debug Toolbar provides a way to see information about the performance
12+
| and state of your application during that page display. By default it will
13+
| NOT be displayed under production environments, and will only display if
14+
| CI_DEBUG is true, since if it's not, there's not much to display anyway.
15+
|
16+
| toolbarMaxHistory = Number of history files, 0 for none or -1 for unlimited
17+
|
18+
*/
19+
public $collectors = [
20+
\CodeIgniter\Debug\Toolbar\Collectors\Timers::class,
21+
\CodeIgniter\Debug\Toolbar\Collectors\Database::class,
22+
\CodeIgniter\Debug\Toolbar\Collectors\Logs::class,
23+
\CodeIgniter\Debug\Toolbar\Collectors\Views::class,
24+
// \CodeIgniter\Debug\Toolbar\Collectors\Cache::class,
25+
\CodeIgniter\Debug\Toolbar\Collectors\Files::class,
26+
\CodeIgniter\Debug\Toolbar\Collectors\Routes::class,
27+
\CodeIgniter\Debug\Toolbar\Collectors\Events::class,
28+
];
29+
public $maxHistory = 20;
30+
public $viewsPath = BASEPATH . 'Debug/Toolbar/Views/';
31+
}

application/Filters/DebugToolbar.php

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use CodeIgniter\Filters\FilterInterface;
44
use CodeIgniter\HTTP\RequestInterface;
55
use CodeIgniter\HTTP\ResponseInterface;
6-
use Config\App;
76
use Config\Services;
87

98
class DebugToolbar implements FilterInterface
@@ -32,59 +31,7 @@ public function before(RequestInterface $request)
3231
*/
3332
public function after(RequestInterface $request, ResponseInterface $response)
3433
{
35-
if (! is_cli() && CI_DEBUG)
36-
{
37-
global $app;
38-
39-
$toolbar = Services::toolbar(config(App::class));
40-
$stats = $app->getPerformanceStats();
41-
$data = $toolbar->run(
42-
$stats['startTime'],
43-
$stats['totalTime'],
44-
$request,
45-
$response
46-
);
47-
48-
helper('filesystem');
49-
50-
// Updated to time() so we can get history
51-
$time = time();
52-
53-
if (! is_dir(WRITEPATH . 'debugbar'))
54-
{
55-
mkdir(WRITEPATH . 'debugbar', 0777);
56-
}
57-
58-
write_file(WRITEPATH . 'debugbar/' . 'debugbar_' . $time, $data, 'w+');
59-
60-
$format = $response->getHeaderLine('content-type');
61-
62-
// Non-HTML formats should not include the debugbar
63-
// then we send headers saying where to find the debug data
64-
// for this response
65-
if ($request->isAJAX() || strpos($format, 'html') === false)
66-
{
67-
return $response->setHeader('Debugbar-Time', (string)$time)
68-
->setHeader('Debugbar-Link', site_url("?debugbar_time={$time}"))
69-
->getBody();
70-
}
71-
72-
$script = PHP_EOL
73-
. '<script type="text/javascript" {csp-script-nonce} id="debugbar_loader" '
74-
. 'data-time="' . $time . '" '
75-
. 'src="' . rtrim(site_url(), '/') . '?debugbar"></script>'
76-
. '<script type="text/javascript" {csp-script-nonce} id="debugbar_dynamic_script"></script>'
77-
. '<style type="text/css" {csp-style-nonce} id="debugbar_dynamic_style"></style>'
78-
. PHP_EOL;
79-
80-
if (strpos($response->getBody(), '</body>') !== false)
81-
{
82-
return $response->setBody(str_replace('</body>', $script . '</body>',
83-
$response->getBody()));
84-
}
85-
86-
return $response->appendBody($script);
87-
}
34+
Services::toolbar()->prepare();
8835
}
8936

9037
//--------------------------------------------------------------------

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"ext-intl": "*",
1111
"ext-json": "*",
1212
"kint-php/kint": "^2.1",
13+
"psr/log": "^1.1",
1314
"zendframework/zend-escaper": "^2.5"
1415
},
1516
"require-dev": {
@@ -20,8 +21,7 @@
2021
},
2122
"autoload": {
2223
"psr-4": {
23-
"CodeIgniter\\": "system/",
24-
"Psr\\Log\\": "system/ThirdParty/PSR/Log/"
24+
"CodeIgniter\\": "system/"
2525
}
2626
},
2727
"scripts": {

phpunit.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,8 @@
4242
<logging>
4343
<log type="coverage-clover" target="build/logs/clover.xml"/>
4444
</logging>
45+
46+
<php>
47+
<env name="app.baseURL" value="http://example.com"/>
48+
</php>
4549
</phpunit>

system/CodeIgniter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ protected function handleRequest(RouteCollectionInterface $routes = null, $cache
303303
$possibleRedirect = $filters->run($uri, 'before');
304304
if ($possibleRedirect instanceof RedirectResponse)
305305
{
306-
return $possibleRedirect;
306+
return $possibleRedirect->send();
307307
}
308308
// If a Response instance is returned, the Response will be sent back to the client and script execution will stop
309309
if ($possibleRedirect instanceof ResponseInterface)

system/Common.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,9 @@ function helper($filenames)
581581
{
582582
if (strpos($path, APPPATH) === 0)
583583
{
584+
// @codeCoverageIgnoreStart
584585
$appHelper = $path;
586+
// @codeCoverageIgnoreEnd
585587
}
586588
elseif (strpos($path, BASEPATH) === 0)
587589
{
@@ -597,7 +599,9 @@ function helper($filenames)
597599
// App-level helpers should override all others
598600
if (! empty($appHelper))
599601
{
602+
// @codeCoverageIgnoreStart
600603
$includes[] = $appHelper;
604+
// @codeCoverageIgnoreEnd
601605
}
602606

603607
// All namespaced files get added in next
@@ -688,9 +692,9 @@ function csrf_hash()
688692
*
689693
* @return string
690694
*/
691-
function csrf_field()
695+
function csrf_field(string $id = null)
692696
{
693-
return '<input type="hidden" name="' . csrf_token() . '" value="' . csrf_hash() . '">';
697+
return '<input type="hidden"' . (!empty($id) ? ' id="' . esc($id, 'attr') . '"' : '') . ' name="' . csrf_token() . '" value="' . csrf_hash() . '" />';
694698
}
695699
}
696700

system/Config/AutoloadConfig.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,14 @@ public function __construct()
157157
'CodeIgniter\HTTP\ResponseInterface' => BASEPATH . 'HTTP/ResponseInterface.php',
158158
'CodeIgniter\HTTP\URI' => BASEPATH . 'HTTP/URI.php',
159159
'CodeIgniter\Log\Logger' => BASEPATH . 'Log/Logger.php',
160+
'Psr\Log\AbstractLogger' => BASEPATH . 'ThirdParty/PSR/Log/AbstractLogger.php',
161+
'Psr\Log\InvalidArgumentException' => BASEPATH . 'ThirdParty/PSR/Log/InvalidArgumentException.php',
160162
'Psr\Log\LoggerAwareInterface' => BASEPATH . 'ThirdParty/PSR/Log/LoggerAwareInterface.php',
161163
'Psr\Log\LoggerAwareTrait' => BASEPATH . 'ThirdParty/PSR/Log/LoggerAwareTrait.php',
162164
'Psr\Log\LoggerInterface' => BASEPATH . 'ThirdParty/PSR/Log/LoggerInterface.php',
165+
'Psr\Log\LoggerTrait' => BASEPATH . 'ThirdParty/PSR/Log/LoggerTrait.php',
163166
'Psr\Log\LogLevel' => BASEPATH . 'ThirdParty/PSR/Log/LogLevel.php',
167+
'Psr\Log\NullLogger' => BASEPATH . 'ThirdParty/PSR/Log/NullLogger.php',
164168
'CodeIgniter\Log\Handlers\BaseHandler' => BASEPATH . 'Log/Handlers/BaseHandler.php',
165169
'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => BASEPATH . 'Log/Handlers/ChromeLoggerHandler.php',
166170
'CodeIgniter\Log\Handlers\FileHandler' => BASEPATH . 'Log/Handlers/FileHandler.php',

0 commit comments

Comments
 (0)