Skip to content

Commit 2ad6f51

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.3
Conflicts: phpstan-baseline.neon.dist
2 parents e2c4a3b + 96e996a commit 2ad6f51

11 files changed

Lines changed: 27 additions & 29 deletions

File tree

deptrac.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ parameters:
165165
Database:
166166
- Entity
167167
- Events
168+
- I18n
168169
Email:
169170
- I18n
170171
- Events

phpstan-baseline.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ parameters:
2626
path: system/Autoloader/Autoloader.php
2727

2828
-
29-
message: "#^Comparison operation \"\\>\" between int\\<1, max\\> and \\(array\\|float\\|int\\) results in an error\\.$#"
29+
message: "#^Comparison operation \"\\>\" between int and \\(array\\|float\\|int\\) results in an error\\.$#"
3030
count: 1
3131
path: system/Cache/Handlers/FileHandler.php
3232

system/Cache/Handlers/FileHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ protected function getItem(string $filename)
242242
return false;
243243
}
244244

245-
if ($data['ttl'] > 0 && time() > $data['time'] + $data['ttl']) {
245+
if ($data['ttl'] > 0 && Time::now()->getTimestamp() > $data['time'] + $data['ttl']) {
246246
// If the file is still there then try to remove it
247247
if (is_file($this->path . $filename)) {
248248
@unlink($this->path . $filename);

system/Database/MigrationRunner.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use CodeIgniter\CLI\CLI;
1515
use CodeIgniter\Events\Events;
1616
use CodeIgniter\Exceptions\ConfigException;
17+
use CodeIgniter\I18n\Time;
1718
use Config\Database;
1819
use Config\Migrations as MigrationsConfig;
1920
use Config\Services;
@@ -596,7 +597,7 @@ protected function addHistory($migration, int $batch)
596597
'class' => $migration->class,
597598
'group' => $this->group,
598599
'namespace' => $migration->namespace,
599-
'time' => time(),
600+
'time' => Time::now()->getTimestamp(),
600601
'batch' => $batch,
601602
]);
602603

system/Test/Fabricator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter\Test;
1313

1414
use CodeIgniter\Exceptions\FrameworkException;
15+
use CodeIgniter\I18n\Time;
1516
use CodeIgniter\Model;
1617
use Faker\Factory;
1718
use Faker\Generator;
@@ -503,7 +504,7 @@ protected function createMock(?int $count = null)
503504
break;
504505

505506
default:
506-
$datetime = time();
507+
$datetime = Time::now()->getTimestamp();
507508
}
508509

509510
// Determine which fields we will need

system/Test/Mock/MockCache.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Closure;
1515
use CodeIgniter\Cache\CacheInterface;
1616
use CodeIgniter\Cache\Handlers\BaseHandler;
17+
use CodeIgniter\I18n\Time;
1718
use PHPUnit\Framework\Assert;
1819

1920
class MockCache extends BaseHandler implements CacheInterface
@@ -100,7 +101,7 @@ public function save(string $key, $value, int $ttl = 60, bool $raw = false)
100101
$key = static::validateKey($key, $this->prefix);
101102

102103
$this->cache[$key] = $value;
103-
$this->expirations[$key] = $ttl > 0 ? time() + $ttl : null;
104+
$this->expirations[$key] = $ttl > 0 ? Time::now()->getTimestamp() + $ttl : null;
104105

105106
return true;
106107
}
@@ -221,7 +222,7 @@ public function getMetaData(string $key)
221222
}
222223

223224
// Count expired items as a miss
224-
if (is_int($this->expirations[$key]) && $this->expirations[$key] > time()) {
225+
if (is_int($this->expirations[$key]) && $this->expirations[$key] > Time::now()->getTimestamp()) {
225226
return null;
226227
}
227228

system/Test/Mock/MockSession.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter\Test\Mock;
1313

1414
use CodeIgniter\Cookie\Cookie;
15+
use CodeIgniter\I18n\Time;
1516
use CodeIgniter\Session\Session;
1617

1718
/**
@@ -56,7 +57,7 @@ protected function startSession()
5657
*/
5758
protected function setCookie()
5859
{
59-
$expiration = $this->sessionExpiration === 0 ? 0 : time() + $this->sessionExpiration;
60+
$expiration = $this->sessionExpiration === 0 ? 0 : Time::now()->getTimestamp() + $this->sessionExpiration;
6061
$this->cookie = $this->cookie->withValue(session_id())->withExpires($expiration);
6162

6263
$this->cookies[] = $this->cookie;
@@ -65,6 +66,6 @@ protected function setCookie()
6566
public function regenerate(bool $destroy = false)
6667
{
6768
$this->didRegenerate = true;
68-
$_SESSION['__ci_last_regenerate'] = time();
69+
$_SESSION['__ci_last_regenerate'] = Time::now()->getTimestamp();
6970
}
7071
}

system/Test/TestResponse.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use CodeIgniter\HTTP\RedirectResponse;
1515
use CodeIgniter\HTTP\RequestInterface;
1616
use CodeIgniter\HTTP\ResponseInterface;
17+
use CodeIgniter\I18n\Time;
1718
use Config\Services;
1819
use Exception;
1920
use PHPUnit\Framework\Constraint\IsEqual;
@@ -339,7 +340,7 @@ public function assertCookieMissing(string $key)
339340
public function assertCookieExpired(string $key, string $prefix = '')
340341
{
341342
$this->assertTrue($this->response->hasCookie($key, null, $prefix));
342-
$this->assertGreaterThan(time(), $this->response->getCookie($key, $prefix)->getExpiresTimestamp());
343+
$this->assertGreaterThan(Time::now()->getTimestamp(), $this->response->getCookie($key, $prefix)->getExpiresTimestamp());
343344
}
344345

345346
// --------------------------------------------------------------------

user_guide_src/source/changelogs/v4.2.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Database
9393
- Added the class ``CodeIgniter\Database\RawSql`` which expresses raw SQL strings.
9494
- :ref:`select() <query-builder-select-rawsql>`, :ref:`where() <query-builder-where-rawsql>`, :ref:`like() <query-builder-like-rawsql>`, :ref:`join() <query-builder-join-rawsql>` accept the ``CodeIgniter\Database\RawSql`` instance.
9595
- ``DBForge::addField()`` default value raw SQL string support. See :ref:`forge-addfield-default-value-rawsql`.
96+
- SQLite3 has a new Config property ``$foreignKeys`` that enables foreign key constraints.
9697

9798
Helpers and Functions
9899
=====================

user_guide_src/source/database/configuration.rst

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ Explanation of Values:
113113
=============== ===========================================================================================================
114114
**dsn** The DSN connect string (an all-in-one configuration sequence).
115115
**hostname** The hostname of your database server. Often this is 'localhost'.
116-
**username** The username used to connect to the database.
117-
**password** The password used to connect to the database.
116+
**username** The username used to connect to the database. (``SQLite3`` does not use this.)
117+
**password** The password used to connect to the database. (``SQLite3`` does not use this.)
118118
**database** The name of the database you want to connect to.
119119

120120
.. note:: CodeIgniter doesn't support dots (``.``) in the database, table, and column names.
121-
**DBDriver** The database type. e.g.,: ``MySQLi``, ``Postgres``, etc. The case must match the driver name
121+
**DBDriver** The database driver name. e.g.,: ``MySQLi``, ``Postgres``, etc. The case must match the driver name
122122
**DBPrefix** An optional table prefix which will added to the table name when running
123123
:doc:`Query Builder <query_builder>` queries. This permits multiple CodeIgniter
124124
installations to share one database.
@@ -129,10 +129,10 @@ Explanation of Values:
129129
**swapPre** A default table prefix that should be swapped with ``DBPrefix``. This is useful for distributed
130130
applications where you might run manually written queries, and need the prefix to still be
131131
customizable by the end user.
132-
**schema** The database schema, default value varies by driver. Used by ``Postgres`` and ``SQLSRV`` drivers.
132+
**schema** The database schema, default value varies by driver. (Used by ``Postgres`` and ``SQLSRV``.)
133133
**encrypt** Whether or not to use an encrypted connection.
134-
``SQLSRV`` drivers accept true/false
135-
``MySQLi`` drivers accept an array with the following options:
134+
``SQLSRV`` driver accepts true/false
135+
``MySQLi`` driver accepts an array with the following options:
136136
* ``ssl_key`` - Path to the private key file
137137
* ``ssl_cert`` - Path to the public key certificate file
138138
* ``ssl_ca`` - Path to the certificate authority file
@@ -141,19 +141,16 @@ Explanation of Values:
141141
* ``ssl_verify`` - true/false; Whether to verify the server certificate or not (``MySQLi`` only)
142142
**compress** Whether or not to use client compression (``MySQLi`` only).
143143
**strictOn** true/false (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL
144-
while developing an application.
145-
**port** The database port number. To use this value you have to add a line to the database config array.
146-
147-
.. literalinclude:: configuration/009.php
144+
while developing an application (``MySQLi`` only).
145+
**port** The database port number.
148146
**foreignKeys** true/false (boolean) - Whether or not to enable Foreign Key constraint (``SQLite3`` only).
149147

150148
.. important:: SQLite3 Foreign Key constraint is disabled by default.
151149
See `SQLite documentation <https://www.sqlite.org/pragma.html#pragma_foreign_keys>`_.
152150
To enforce Foreign Key constraint, set this config item to true.
153151
=============== ===========================================================================================================
154152

155-
.. note:: Depending on what database platform you are using (MySQL, PostgreSQL,
156-
etc.) not all values will be needed. For example, when using SQLite you
153+
.. note:: Depending on what database driver you are using (``MySQLi``, ``Postgres``,
154+
etc.) not all values will be needed. For example, when using ``SQLite3`` you
157155
will not need to supply a username or password, and the database name
158-
will be the path to your database file. The information above assumes
159-
you are using MySQL.
156+
will be the path to your database file.

0 commit comments

Comments
 (0)