diff --git a/deptrac.yaml b/deptrac.yaml index 3643d19f4118..594f0bba4605 100644 --- a/deptrac.yaml +++ b/deptrac.yaml @@ -158,6 +158,8 @@ parameters: Controller: - HTTP - Validation + Cookie: + - I18n Database: - Entity - Events diff --git a/system/Cookie/Cookie.php b/system/Cookie/Cookie.php index b0b49a0a0b7b..9362994329fd 100644 --- a/system/Cookie/Cookie.php +++ b/system/Cookie/Cookie.php @@ -13,6 +13,7 @@ use ArrayAccess; use CodeIgniter\Cookie\Exceptions\CookieException; +use CodeIgniter\I18n\Time; use Config\Cookie as CookieConfig; use DateTimeInterface; use InvalidArgumentException; @@ -206,7 +207,7 @@ final public function __construct(string $name, string $value = '', array $optio // If both `Expires` and `Max-Age` are set, `Max-Age` has precedence. if (isset($options['max-age']) && is_numeric($options['max-age'])) { - $options['expires'] = time() + (int) $options['max-age']; + $options['expires'] = Time::now()->getTimestamp() + (int) $options['max-age']; unset($options['max-age']); } @@ -314,7 +315,7 @@ public function getExpiresString(): string */ public function isExpired(): bool { - return $this->expires === 0 || $this->expires < time(); + return $this->expires === 0 || $this->expires < Time::now()->getTimestamp(); } /** @@ -322,7 +323,7 @@ public function isExpired(): bool */ public function getMaxAge(): int { - $maxAge = $this->expires - time(); + $maxAge = $this->expires - Time::now()->getTimestamp(); return $maxAge >= 0 ? $maxAge : 0; } @@ -466,7 +467,7 @@ public function withNeverExpiring() { $cookie = clone $this; - $cookie->expires = time() + 5 * YEAR; + $cookie->expires = Time::now()->getTimestamp() + 5 * YEAR; return $cookie; } diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index 5e70dbc437ff..b5bdcb9c38aa 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -22,6 +22,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\Response; use CodeIgniter\HTTP\ResponseInterface; +use CodeIgniter\I18n\Time; use Config\Services; use Config\Toolbar as ToolbarConfig; use Kint\Kint; @@ -380,7 +381,7 @@ public function prepare(?RequestInterface $request = null, ?ResponseInterface $r helper('filesystem'); // Updated to microtime() so we can get history - $time = sprintf('%.6f', microtime(true)); + $time = sprintf('%.6f', Time::now()->format('U.u')); if (! is_dir(WRITEPATH . 'debugbar')) { mkdir(WRITEPATH . 'debugbar', 0777); diff --git a/system/Debug/Toolbar/Collectors/Database.php b/system/Debug/Toolbar/Collectors/Database.php index 6a845ae51bf3..2991840c8de1 100644 --- a/system/Debug/Toolbar/Collectors/Database.php +++ b/system/Debug/Toolbar/Collectors/Database.php @@ -12,6 +12,7 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; use CodeIgniter\Database\Query; +use CodeIgniter\I18n\Time; /** * Collector for the Database tab of the Debug Toolbar. @@ -184,7 +185,7 @@ public function display(): array 'sql' => $query['query']->debugToolbarDisplay(), 'trace' => $query['trace'], 'trace-file' => $firstNonSystemLine, - 'qid' => md5($query['query'] . microtime()), + 'qid' => md5($query['query'] . Time::now()->format('0.u00 U')), ]; }, static::$queries);