Skip to content

Commit e392123

Browse files
committed
Release v4.3.6
1 parent b41bca4 commit e392123

29 files changed

+280
-188
lines changed

system/Autoloader/FileLocator.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@ public function __construct(Autoloader $autoloader)
3333
* Attempts to locate a file by examining the name for a namespace
3434
* and looking through the PSR-4 namespaced files that we know about.
3535
*
36-
* @param string $file The namespaced file to locate
37-
* @param string|null $folder The folder within the namespace that we should look for the file.
36+
* @param string $file The relative file path or namespaced file to
37+
* locate. If not namespaced, search in the app
38+
* folder.
39+
* @param string|null $folder The folder within the namespace that we should
40+
* look for the file. If $file does not contain
41+
* this value, it will be appended to the namespace
42+
* folder.
3843
* @param string $ext The file extension the file should have.
3944
*
4045
* @return false|string The path to the file, or false if not found.

system/CodeIgniter.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CodeIgniter
4747
/**
4848
* The current version of CodeIgniter Framework
4949
*/
50-
public const CI_VERSION = '4.3.5';
50+
public const CI_VERSION = '4.3.6';
5151

5252
/**
5353
* App startup time.
@@ -310,8 +310,6 @@ private function configureKint(): void
310310
* makes all of the pieces work together.
311311
*
312312
* @return ResponseInterface|void
313-
*
314-
* @throws RedirectException
315313
*/
316314
public function run(?RouteCollectionInterface $routes = null, bool $returnResponse = false)
317315
{

system/Common.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -744,11 +744,7 @@ function is_windows(?bool $mock = null): bool
744744
$mocked = $mock;
745745
}
746746

747-
if (isset($mocked)) {
748-
return $mocked;
749-
}
750-
751-
return DIRECTORY_SEPARATOR === '\\';
747+
return $mocked ?? DIRECTORY_SEPARATOR === '\\';
752748
}
753749
}
754750

system/Config/BaseConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function __construct()
8686
/**
8787
* Initialization an environment-specific configuration setting
8888
*
89-
* @param mixed $property
89+
* @param array|bool|float|int|string|null $property
9090
*
9191
* @return void
9292
*/

system/Config/Factories.php

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* instantiation checks.
2525
*
2626
* @method static BaseConfig|null config(...$arguments)
27+
* @method static Model|null models(string $name, array $options = [], ?ConnectionInterface &$conn = null)
2728
*/
2829
class Factories
2930
{
@@ -69,23 +70,6 @@ class Factories
6970
*/
7071
protected static $instances = [];
7172

72-
/**
73-
* This method is only to prevent PHPStan error.
74-
* If we have a solution, we can remove this method.
75-
* See https://github.com/codeigniter4/CodeIgniter4/pull/5358
76-
*
77-
* @template T of Model
78-
*
79-
* @phpstan-param class-string<T> $name
80-
*
81-
* @return Model
82-
* @phpstan-return T
83-
*/
84-
public static function models(string $name, array $options = [], ?ConnectionInterface &$conn = null)
85-
{
86-
return self::__callStatic('models', [$name, $options, $conn]);
87-
}
88-
8973
/**
9074
* Loads instances based on the method component name. Either
9175
* creates a new instance or returns an existing shared instance.

system/Database/BaseBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1997,7 +1997,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
19971997
}
19981998

19991999
if (isset($this->QBOptions['setQueryAsData'])) {
2000-
$data = $this->QBOptions['setQueryAsData'];
2000+
$data = $this->QBOptions['setQueryAsData'] . "\n";
20012001
} else {
20022002
$data = 'VALUES ' . implode(', ', $this->formatValues($values)) . "\n";
20032003
}

system/Database/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Config extends BaseConfig
3737
protected static $factory;
3838

3939
/**
40-
* Creates the default
40+
* Returns the database connection
4141
*
4242
* @param array|BaseConnection|string|null $group The name of the connection group to use,
4343
* or an array of configuration settings.

system/Database/Database.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* Database Connection Factory
1818
*
19-
* Creates and returns an instance of the appropriate DatabaseConnection
19+
* Creates and returns an instance of the appropriate Database Connection.
2020
*/
2121
class Database
2222
{
@@ -32,8 +32,7 @@ class Database
3232
protected $connections = [];
3333

3434
/**
35-
* Parses the connection binds and returns an instance of the driver
36-
* ready to go.
35+
* Parses the connection binds and creates a Database Connection instance.
3736
*
3837
* @return BaseConnection
3938
*
@@ -83,7 +82,7 @@ public function loadUtils(ConnectionInterface $db): BaseUtils
8382
}
8483

8584
/**
86-
* Parse universal DSN string
85+
* Parses universal DSN string
8786
*
8887
* @throws InvalidArgumentException
8988
*/
@@ -121,21 +120,20 @@ protected function parseDSN(array $params): array
121120
}
122121

123122
/**
124-
* Initialize database driver.
123+
* Creates a database object.
125124
*
126125
* @param string $driver Driver name. FQCN can be used.
127-
* @param array|object $argument
126+
* @param string $class 'Connection'|'Forge'|'Utils'
127+
* @param array|object $argument The constructor parameter.
128128
*
129129
* @return BaseConnection|BaseUtils|Forge
130130
*/
131131
protected function initDriver(string $driver, string $class, $argument): object
132132
{
133-
$class = $driver . '\\' . $class;
133+
$classname = (strpos($driver, '\\') === false)
134+
? "CodeIgniter\\Database\\{$driver}\\{$class}"
135+
: $driver . '\\' . $class;
134136

135-
if (strpos($driver, '\\') === false) {
136-
$class = "CodeIgniter\\Database\\{$class}";
137-
}
138-
139-
return new $class($argument);
137+
return new $classname($argument);
140138
}
141139
}

system/Database/Postgre/Connection.php

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,11 @@ public function connect(bool $persistent = false)
6464
$this->buildDSN();
6565
}
6666

67-
// Strip pgsql if exists
67+
// Convert DSN string
6868
if (mb_strpos($this->DSN, 'pgsql:') === 0) {
69-
$this->DSN = mb_substr($this->DSN, 6);
69+
$this->convertDSN();
7070
}
7171

72-
// Convert semicolons to spaces.
73-
$this->DSN = str_replace(';', ' ', $this->DSN);
74-
7572
$this->connID = $persistent === true ? pg_pconnect($this->DSN) : pg_connect($this->DSN);
7673

7774
if ($this->connID !== false) {
@@ -92,6 +89,44 @@ public function connect(bool $persistent = false)
9289
return $this->connID;
9390
}
9491

92+
/**
93+
* Converts the DSN with semicolon syntax.
94+
*/
95+
private function convertDSN()
96+
{
97+
// Strip pgsql
98+
$this->DSN = mb_substr($this->DSN, 6);
99+
100+
// Convert semicolons to spaces in DSN format like:
101+
// pgsql:host=localhost;port=5432;dbname=database_name
102+
// https://www.php.net/manual/en/function.pg-connect.php
103+
$allowedParams = ['host', 'port', 'dbname', 'user', 'password', 'connect_timeout', 'options', 'sslmode', 'service'];
104+
105+
$parameters = explode(';', $this->DSN);
106+
107+
$output = '';
108+
$previousParameter = '';
109+
110+
foreach ($parameters as $parameter) {
111+
[$key, $value] = explode('=', $parameter, 2);
112+
if (in_array($key, $allowedParams, true)) {
113+
if ($previousParameter !== '') {
114+
if (array_search($key, $allowedParams, true) < array_search($previousParameter, $allowedParams, true)) {
115+
$output .= ';';
116+
} else {
117+
$output .= ' ';
118+
}
119+
}
120+
$output .= $parameter;
121+
$previousParameter = $key;
122+
} else {
123+
$output .= ';' . $parameter;
124+
}
125+
}
126+
127+
$this->DSN = $output;
128+
}
129+
95130
/**
96131
* Keep or establish the connection if no queries have been sent for
97132
* a length of time exceeding the server's idle timeout.

system/Encryption/Encryption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public static function createKey($length = 32)
149149
*
150150
* @param string $key Property name
151151
*
152-
* @return mixed
152+
* @return array|string|null
153153
*/
154154
public function __get($key)
155155
{

0 commit comments

Comments
 (0)