Skip to content

Commit 3c0b45e

Browse files
authored
Merge pull request #1 from bcit-ci/develop
Update From Branch
2 parents 1a24ff5 + 315574e commit 3c0b45e

File tree

85 files changed

+5186
-2592
lines changed

Some content is hidden

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

85 files changed

+5186
-2592
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ if you want to take the lead for one of them.
6363

6464
We are not looking for out-of-scope contributions, only those that would be considered part of our controlled evolution!
6565

66-
Please read the *Contributing to CodeIgniter* section in the user guide
66+
Please read the [*Contributing to CodeIgniter*](https://github.com/bcit-ci/CodeIgniter4/blob/develop/contributing.md) section in the user guide
6767

6868
## Server Requirements
6969
PHP version 7.0.15 or higher is required, with the following extensions installed:

application/Config/App.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ class App extends BaseConfig
292292
| and can be of any length, though the more random the characters
293293
| the better.
294294
|
295-
| If you use the Model class' hashedID methods, this must be filled out.
296295
*/
297296
public $salt = '';
298297

application/Config/Events.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,7 @@
3030
if (ENVIRONMENT != 'production')
3131
{
3232
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
33+
34+
// Handles the display of the toolbar itself. MUST remain here for toolbar to be displayed.
35+
Events::on('pre_system', 'CodeIgniter\Debug\Toolbar::eventHandler');
3336
}

application/Config/Mimes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class Mimes
280280
/**
281281
* Attempts to determine the best mime type for the given file extension.
282282
*
283-
* @param string $ext
283+
* @param string $extension
284284
*
285285
* @return string|null The mime type found, or none if unable to determine.
286286
*/

application/Config/View.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class View extends \CodeIgniter\Config\View
1010
* calls so that it is available to all views. If that is the case,
1111
* set $saveData to true.
1212
*/
13-
public $saveData = false;
13+
public $saveData = true;
1414

1515
/**
1616
* Parser Filters map a filter name with any PHP callable. When the

application/Filters/DebugToolbar.php

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,39 @@ public function after(RequestInterface $request, ResponseInterface $response)
4141

4242
$toolbar = Services::toolbar(new App());
4343
$stats = $app->getPerformanceStats();
44-
45-
return $response->appendBody(
46-
$toolbar->run(
47-
$stats['startTime'],
48-
$stats['totalTime'],
49-
$stats['startMemory'],
50-
$request,
51-
$response
52-
)
44+
$output = $toolbar->run(
45+
$stats['startTime'],
46+
$stats['totalTime'],
47+
$stats['startMemory'],
48+
$request,
49+
$response
5350
);
51+
52+
helper(['filesystem', 'url']);
53+
54+
// Updated to time() so we can get history
55+
$time = time();
56+
57+
if (! is_dir(WRITEPATH.'debugbar'))
58+
{
59+
mkdir(WRITEPATH.'debugbar', 0777);
60+
}
61+
62+
write_file(WRITEPATH .'debugbar/'.'debugbar_' . $time, $output, 'w+');
63+
64+
$script = PHP_EOL
65+
. '<script type="text/javascript" id="debugbar_loader" '
66+
. 'data-time="' . $time . '" '
67+
. 'src="' . rtrim(site_url(), '/') . '?debugbar"></script>'
68+
. PHP_EOL;
69+
70+
if (strpos($response->getBody(), '</body>') !== false)
71+
{
72+
return $response->setBody(str_replace('</body>', $script . '</body>',
73+
$response->getBody()));
74+
}
75+
76+
return $response->appendBody($script);
5477
}
5578
}
5679

rewrite.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
* functionality so the site will operate as normal.
99
*/
1010

11+
// If we're serving the site locally, then we need
12+
// to let the application know that we're in development mode
13+
$_SERVER['CI_ENVIRONMENT'] = 'development';
14+
1115
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
1216

1317
$path = __DIR__.'/public/'.ltrim($uri,'/');
@@ -21,9 +25,4 @@
2125

2226
// Otherwise, we'll load the index file and let
2327
// the framework handle the request from here.
24-
25-
// If we're serving the site locally, then we need
26-
// to let the application know that we're in development mode
27-
$_SERVER['CI_ENVIRONMENT'] = 'development';
28-
2928
require_once __DIR__.'/public/index.php';

system/API/ResponseTrait.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function fail($messages, int $status = 400, string $code = null, string $
140140
{
141141
if ( ! is_array($messages))
142142
{
143-
$messages = [$messages];
143+
$messages = ['error' => $messages];
144144
}
145145

146146
$response = [
@@ -198,7 +198,7 @@ public function respondDeleted($data = null, string $message = '')
198198
*
199199
* @return mixed
200200
*/
201-
public function failUnauthorized(string $description, string $code = null, string $message = '')
201+
public function failUnauthorized(string $description = 'Unauthorized', string $code = null, string $message = '')
202202
{
203203
return $this->fail($description, $this->codes['unauthorized'], $code, $message);
204204
}
@@ -215,7 +215,7 @@ public function failUnauthorized(string $description, string $code = null, strin
215215
*
216216
* @return mixed
217217
*/
218-
public function failForbidden(string $description, string $code = null, string $message = '')
218+
public function failForbidden(string $description = 'Forbidden', string $code = null, string $message = '')
219219
{
220220
return $this->fail($description, $this->codes['forbidden'], $code, $message);
221221
}
@@ -231,7 +231,7 @@ public function failForbidden(string $description, string $code = null, string $
231231
*
232232
* @return mixed
233233
*/
234-
public function failNotFound(string $description, string $code = null, string $message = '')
234+
public function failNotFound(string $description = 'Not Found', string $code = null, string $message = '')
235235
{
236236
return $this->fail($description, $this->codes['resource_not_found'], $code, $message);
237237
}
@@ -247,7 +247,7 @@ public function failNotFound(string $description, string $code = null, string $m
247247
*
248248
* @return mixed
249249
*/
250-
public function failValidationError(string $description, string $code = null, string $message = '')
250+
public function failValidationError(string $description = 'Bad Request', string $code = null, string $message = '')
251251
{
252252
return $this->fail($description, $this->codes['invalid_data'], $code, $message);
253253
}
@@ -263,7 +263,7 @@ public function failValidationError(string $description, string $code = null, st
263263
*
264264
* @return mixed
265265
*/
266-
public function failResourceExists(string $description, string $code = null, string $message = '')
266+
public function failResourceExists(string $description = 'Conflict', string $code = null, string $message = '')
267267
{
268268
return $this->fail($description, $this->codes['resource_exists'], $code, $message);
269269
}
@@ -281,7 +281,7 @@ public function failResourceExists(string $description, string $code = null, str
281281
*
282282
* @return mixed
283283
*/
284-
public function failResourceGone(string $description, string $code = null, string $message = '')
284+
public function failResourceGone(string $description = 'Gone', string $code = null, string $message = '')
285285
{
286286
return $this->fail($description, $this->codes['resource_gone'], $code, $message);
287287
}
@@ -297,7 +297,7 @@ public function failResourceGone(string $description, string $code = null, strin
297297
*
298298
* @return mixed
299299
*/
300-
public function failTooManyRequests(string $description, string $code = null, string $message = '')
300+
public function failTooManyRequests(string $description = 'Too Many Requests', string $code = null, string $message = '')
301301
{
302302
return $this->fail($description, $this->codes['too_many_requests'], $code, $message);
303303
}
@@ -313,7 +313,7 @@ public function failTooManyRequests(string $description, string $code = null, st
313313
*
314314
* @return Response The value of the Response's send() method.
315315
*/
316-
public function failServerError(string $description, string $code = null, string $message = ''): Response
316+
public function failServerError(string $description = 'Internal Server Error', string $code = null, string $message = ''): Response
317317
{
318318
return $this->fail($description, $this->codes['server_error'], $code, $message);
319319
}

0 commit comments

Comments
 (0)