Skip to content

Commit b669dc3

Browse files
authored
Merge branch 'develop' into views_hints
2 parents 95a75e2 + d305d5e commit b669dc3

Some content is hidden

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

82 files changed

+1687
-589
lines changed

application/Config/App.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,6 @@ class App extends BaseConfig
282282
'CodeIgniter\Debug\Toolbar\Collectors\Events',
283283
];
284284

285-
/*
286-
|--------------------------------------------------------------------------
287-
| Error Views Path
288-
|--------------------------------------------------------------------------
289-
| This is the path to the directory that contains the 'cli' and 'html'
290-
| directories that hold the views used to generate errors.
291-
|
292-
| Default: APPPATH.'Views/errors'
293-
*/
294-
public $errorViewPath = APPPATH.'Views/errors';
295-
296285
/*
297286
|--------------------------------------------------------------------------
298287
| Application Salt

application/Config/Exceptions.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php namespace Config;
2+
3+
/**
4+
* Setup how the exception handler works.
5+
*
6+
* @package Config
7+
*/
8+
class Exceptions
9+
{
10+
/*
11+
|--------------------------------------------------------------------------
12+
| LOG EXCEPTIONS?
13+
|--------------------------------------------------------------------------
14+
| If true, then exceptions will be logged
15+
| through Services::Log.
16+
|
17+
| Default: true
18+
*/
19+
public $log = true;
20+
21+
/*
22+
|--------------------------------------------------------------------------
23+
| DO NOT LOG STATUS CODES
24+
|--------------------------------------------------------------------------
25+
| Any status codes here will NOT be logged if logging is turned on.
26+
| By default, only 404 (Page Not Found) exceptions are ignored.
27+
*/
28+
public $ignoreCodes = [ 404 ];
29+
30+
/*
31+
|--------------------------------------------------------------------------
32+
| Error Views Path
33+
|--------------------------------------------------------------------------
34+
| This is the path to the directory that contains the 'cli' and 'html'
35+
| directories that hold the views used to generate errors.
36+
|
37+
| Default: APPPATH.'Views/errors'
38+
*/
39+
public $errorViewPath = APPPATH.'Views/errors';
40+
}

application/Config/Logger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Logger extends BaseConfig
3232
| your log files will fill up very fast.
3333
|
3434
*/
35-
public $threshold = 0;
35+
public $threshold = 3;
3636

3737
/*
3838
|--------------------------------------------------------------------------

application/Controllers/Checks.php

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,140 @@ public function index()
1515
{
1616
session()->start();
1717
}
18+
19+
public function forge()
20+
{
21+
echo '<h1>MySQL</h1>';
22+
23+
log_message('debug', 'MYSQL TEST');
24+
25+
$forge_mysql = \Config\Database::forge();
26+
27+
$forge_mysql->getConnection()->query('SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;');
28+
29+
$forge_mysql->dropTable('users', true);
30+
31+
$forge_mysql->getConnection()->query('SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;');
32+
33+
$forge_mysql->addField([
34+
'id' => [
35+
'type' => 'INTEGER',
36+
'constraint' => 11
37+
],
38+
'name' => [
39+
'type' => 'VARCHAR',
40+
'constraint' => 50,
41+
]
42+
]);
43+
$forge_mysql->addKey('id', true);
44+
$attributes = array('ENGINE' => 'InnoDB');
45+
$forge_mysql->createTable('users', true, $attributes);
46+
47+
$data_insert = array(
48+
'id' => 1,
49+
'name' => 'User 1',
50+
);
51+
$forge_mysql->getConnection()->table('users')->insert($data_insert);
52+
53+
$drop = $forge_mysql->dropTable('invoices', true);
54+
55+
$forge_mysql->addField([
56+
'id' => [
57+
'type' => 'INTEGER',
58+
'constraint' => 11,
59+
],
60+
'users_id' => [
61+
'type' => 'INTEGER',
62+
'constraint' => 11
63+
],
64+
'other_id' => [
65+
'type' => 'INTEGER',
66+
'constraint' => 11
67+
]
68+
]);
69+
$forge_mysql->addKey('id', true);
70+
71+
$forge_mysql->addForeignKey('users_id','users','id','CASCADE','CASCADE');
72+
$forge_mysql->addForeignKey('other_id','users','id','CASCADE','CASCADE');
73+
74+
$attributes = array('ENGINE' => 'InnoDB');
75+
$res = $forge_mysql->createTable('invoices', true,$attributes);
76+
77+
if(!$res){
78+
var_dump($forge_mysql->getConnection()->mysqli);
79+
}else{
80+
echo '<br><br>OK';
81+
82+
var_dump($forge_mysql->getConnection()->getForeignKeyData('invoices'));
83+
}
84+
85+
$res = $forge_mysql->dropForeignKey('invoices','invoices_other_id_foreign');
86+
87+
88+
echo '<h1>PostgreSQL</h1>';
89+
90+
$forge_pgsql = \Config\Database::forge('pgsql');
91+
92+
$forge_pgsql->dropTable('users',true, true);
93+
94+
$forge_pgsql->addField([
95+
'id' => [
96+
'type' => 'INTEGER',
97+
'constraint' => 11,
98+
'auto_increment' => true,
99+
],
100+
'name' => [
101+
'type' => 'VARCHAR',
102+
'constraint' => 50,
103+
]
104+
]);
105+
$forge_pgsql->addKey('id', true);
106+
$forge_pgsql->createTable('users', true);
107+
108+
109+
$data_insert = array(
110+
'id' => 1,
111+
'name' => 'User 1',
112+
);
113+
$forge_pgsql->getConnection()->table('users')->insert($data_insert);
114+
115+
$forge_pgsql->dropTable('invoices',true);
116+
$forge_pgsql->addField([
117+
'id' => [
118+
'type' => 'INTEGER',
119+
'constraint' => 11,
120+
'auto_increment' => true,
121+
],
122+
'users_id' => [
123+
'type' => 'INTEGER',
124+
'constraint' => 11
125+
],
126+
'other_id' => [
127+
'type' => 'INTEGER',
128+
'constraint' => 11
129+
],
130+
'another_id' => [
131+
'type' => 'INTEGER',
132+
'constraint' => 11
133+
]
134+
]);
135+
$forge_pgsql->addKey('id', true);
136+
137+
$forge_pgsql->addForeignKey('users_id','users','id','CASCADE','CASCADE');
138+
$forge_pgsql->addForeignKey('other_id','users','id');
139+
140+
$res = $forge_pgsql->createTable('invoices', true);
141+
142+
if(!$res){
143+
var_dump($forge_pgsql->getConnection()->mysqli);
144+
}else{
145+
echo '<br><br>OK';
146+
var_dump($forge_pgsql->getConnection()->getForeignKeyData('invoices'));
147+
}
148+
149+
//$res = $forge_pgsql->dropForeignKey('invoices','invoices_other_id_foreign');
150+
151+
}
18152

19153

20154
public function escape()
@@ -306,4 +440,9 @@ public function parser()
306440
$this->parser = Services::parser();
307441
}
308442

443+
public function error()
444+
{
445+
throw new \RuntimeException('Oops!', 403);
446+
}
447+
309448
}

system/CodeIgniter.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function initialize()
157157
date_default_timezone_set($this->config->appTimezone ?? 'UTC');
158158

159159
// Setup Exception Handling
160-
Services::exceptions($this->config, true)
160+
Services::exceptions()
161161
->initialize();
162162

163163
$this->loadEnvironment();
@@ -788,29 +788,7 @@ protected function display404errors(PageNotFoundException $e)
788788
}
789789
}
790790

791-
ob_start();
792-
793-
// These might show as unused here - but don't delete!
794-
// They are used within the view files.
795-
$heading = 'Page Not Found';
796-
$message = $e->getMessage();
797-
798-
// Show the 404 error page
799-
if (is_cli())
800-
{
801-
require $this->config->errorViewPath . '/cli/error_404.php';
802-
}
803-
else
804-
{
805-
require $this->config->errorViewPath . '/html/error_404.php';
806-
}
807-
808-
$buffer = ob_get_contents();
809-
ob_end_clean();
810-
811-
$this->response->setBody($buffer);
812-
$this->response->send();
813-
$this->callExit(EXIT_UNKNOWN_FILE); // Unknown file
791+
throw new PageNotFoundException(lang('HTTP.pageNotFound'));
814792
}
815793

816794
//--------------------------------------------------------------------

system/Common.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*/
3838
use CodeIgniter\HTTP\RequestInterface;
3939
use CodeIgniter\HTTP\ResponseInterface;
40-
use CodeIgniter\Config\Services;
40+
use Config\Services;
4141

4242
/**
4343
* Common Functions
@@ -339,7 +339,7 @@ function timer(string $name = null)
339339
*
340340
* These are equal:
341341
* - $timer = service('timer')
342-
* - $timer = \CodeIgniter\Congif\Services::timer();
342+
* - $timer = \CodeIgniter\Config\Services::timer();
343343
*
344344
* @param string $name
345345
* @param array ...$params

system/Config/ForeignCharacters.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ class ForeignCharacters
9595
'/ț|ţ|ť|ŧ|т/' => 't',
9696
'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U',
9797
'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u',
98-
'/Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y',
99-
'/ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й/' => 'y',
98+
'/Ƴ|Ɏ|Ỵ|Ẏ|Ӳ|Ӯ|Ў|Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y',
99+
'/ẙ|ʏ|ƴ|ɏ|ỵ|ẏ|ӳ|ӯ|ў|ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й/' => 'y',
100100
'/В/' => 'V',
101101
'/в/' => 'v',
102102
'/Ŵ/' => 'W',

system/Config/Services.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ public static function curlrequest(array $options = [], $response = null, \Confi
192192
* - set_error_handler
193193
* - register_shutdown_function
194194
*
195-
* @param \Config\App $config
196-
* @param bool $getShared
195+
* @param \Config\Exceptions $config
196+
* @param bool $getShared
197197
*
198198
* @return \CodeIgniter\Debug\Exceptions
199199
*/
200-
public static function exceptions(\Config\App $config = null, $getShared = true)
200+
public static function exceptions(\Config\Exceptions $config = null, $getShared = true)
201201
{
202202
if ($getShared)
203203
{
@@ -206,10 +206,10 @@ public static function exceptions(\Config\App $config = null, $getShared = true)
206206

207207
if (empty($config))
208208
{
209-
$config = new \Config\App();
209+
$config = new \Config\Exceptions();
210210
}
211211

212-
return new \CodeIgniter\Debug\Exceptions($config);
212+
return (new \CodeIgniter\Debug\Exceptions($config));
213213
}
214214

215215
//--------------------------------------------------------------------

system/Database/BaseBuilder.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @since Version 3.0.0
3636
* @filesource
3737
*/
38-
use CodeIgniter\DatabaseException;
38+
use \CodeIgniter\Database\Exceptions\DatabaseException;
3939

4040
/**
4141
* Class BaseBuilder
@@ -357,7 +357,7 @@ public function selectSum($select = '', $alias = '')
357357
* @param string $type
358358
*
359359
* @return BaseBuilder
360-
* @throws \CodeIgniter\DatabaseException
360+
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
361361
*/
362362
protected function maxMinAvgSum($select = '', $alias = '', $type = 'MAX')
363363
{
@@ -1936,7 +1936,7 @@ protected function _update($table, $values)
19361936
*
19371937
*
19381938
* @return bool
1939-
* @throws \CodeIgniter\DatabaseException
1939+
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
19401940
*/
19411941
protected function validateUpdate()
19421942
{
@@ -1966,7 +1966,7 @@ protected function validateUpdate()
19661966
* @param bool $returnSQL True means SQL is returned, false will execute the query
19671967
*
19681968
* @return mixed Number of rows affected or FALSE on failure
1969-
* @throws \CodeIgniter\DatabaseException
1969+
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
19701970
*/
19711971
public function updateBatch($set = null, $index = null, $batch_size = 100, $returnSQL = false)
19721972
{
@@ -2085,7 +2085,7 @@ protected function _updateBatch($table, $values, $index)
20852085
* @param bool $escape
20862086
*
20872087
* @return BaseBuilder
2088-
* @throws \CodeIgniter\DatabaseException
2088+
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
20892089
*/
20902090
public function setUpdateBatch($key, $index = '', $escape = null)
20912091
{
@@ -2234,7 +2234,7 @@ public function getCompiledDelete($reset = true)
22342234
* @param bool $returnSQL
22352235
*
22362236
* @return mixed
2237-
* @throws \CodeIgniter\DatabaseException
2237+
* @throws \CodeIgniter\Database\Exceptions\DatabaseException
22382238
*/
22392239
public function delete($where = '', $limit = null, $reset_data = true, $returnSQL = false)
22402240
{

0 commit comments

Comments
 (0)