Skip to content

Commit

Permalink
Bump Cake to 4.6.0 and update associated dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Apr 18, 2025
1 parent c74c423 commit 532b63b
Show file tree
Hide file tree
Showing 301 changed files with 10,527 additions and 4,678 deletions.
2 changes: 1 addition & 1 deletion app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"require": {
"php": ">=8.0",
"cakephp/cakephp": "4.5.*",
"cakephp/cakephp": "4.6.*",
"cakephp/migrations": "^3.2",
"cakephp/plugin-installer": "^1.3",
"doctrine/dbal": "^3.3",
Expand Down
147 changes: 77 additions & 70 deletions app/composer.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/vendor/cakephp-plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
'DebugKit' => $baseDir . '/vendor/cakephp/debug_kit/',
'EnvSource' => $baseDir . '/plugins/EnvSource/',
'Migrations' => $baseDir . '/vendor/cakephp/migrations/',
'TestWidget' => $baseDir . '/plugins/TestWidget/',
],
];
2 changes: 1 addition & 1 deletion app/vendor/cakephp/cakephp/VERSION.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
// @license https://opensource.org/licenses/mit-license.php MIT License
// +--------------------------------------------------------------------------------------------+ //
////////////////////////////////////////////////////////////////////////////////////////////////////
4.5.4
4.6.0
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public function clear(): bool
}

foreach ($keys as $key) {
if (strpos($key, $this->_config['prefix']) === 0) {
if ($this->_config['prefix'] === '' || strpos($key, $this->_config['prefix']) === 0) {
$this->_Memcached->delete($key);
}
}
Expand Down
104 changes: 91 additions & 13 deletions app/vendor/cakephp/cakephp/src/Cache/Engine/RedisEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class RedisEngine extends CacheEngine
* - `password` Redis server password.
* - `persistent` Connect to the Redis server with a persistent connection
* - `port` port number to the Redis server.
* - `tls` connect to the Redis server using TLS.
* - `prefix` Prefix appended to all entries. Good for when you need to share a keyspace
* with either another cache config or another application.
* - `scanCount` Number of keys to ask for each scan (default: 10)
Expand All @@ -61,6 +62,7 @@ class RedisEngine extends CacheEngine
'password' => false,
'persistent' => true,
'port' => 6379,
'tls' => false,
'prefix' => 'cake_',
'host' => null,
'server' => '127.0.0.1',
Expand Down Expand Up @@ -99,24 +101,29 @@ public function init(array $config = []): bool
*/
protected function _connect(): bool
{
$tls = $this->_config['tls'] === true ? 'tls://' : '';

$map = [
'ssl_ca' => 'cafile',
'ssl_key' => 'local_pk',
'ssl_cert' => 'local_cert',
];

$ssl = [];
foreach ($map as $key => $context) {
if (!empty($this->_config[$key])) {
$ssl[$context] = $this->_config[$key];
}
}

try {
$this->_Redis = new Redis();
$this->_Redis = $this->_createRedisInstance();
if (!empty($this->_config['unix_socket'])) {
$return = $this->_Redis->connect($this->_config['unix_socket']);
} elseif (empty($this->_config['persistent'])) {
$return = $this->_Redis->connect(
$this->_config['server'],
(int)$this->_config['port'],
(int)$this->_config['timeout']
);
$return = $this->_connectTransient($tls . $this->_config['server'], $ssl);
} else {
$persistentId = $this->_config['port'] . $this->_config['timeout'] . $this->_config['database'];
$return = $this->_Redis->pconnect(
$this->_config['server'],
(int)$this->_config['port'],
(int)$this->_config['timeout'],
$persistentId
);
$return = $this->_connectPersistent($tls . $this->_config['server'], $ssl);
}
} catch (RedisException $e) {
if (class_exists(Log::class)) {
Expand All @@ -135,6 +142,67 @@ protected function _connect(): bool
return $return;
}

/**
* Connects to a Redis server using a new connection.
*
* @param string $server Server to connect to.
* @param array $ssl SSL context options.
* @throws \RedisException
* @return bool True if Redis server was connected
*/
protected function _connectTransient($server, array $ssl): bool
{
if (empty($ssl)) {
return $this->_Redis->connect(
$server,
(int)$this->_config['port'],
(int)$this->_config['timeout']
);
}

return $this->_Redis->connect(
$server,
(int)$this->_config['port'],
(int)$this->_config['timeout'],
null,
0,
0.0,
['ssl' => $ssl]
);
}

/**
* Connects to a Redis server using a persistent connection.
*
* @param string $server Server to connect to.
* @param array $ssl SSL context options.
* @throws \RedisException
* @return bool True if Redis server was connected
*/
protected function _connectPersistent($server, array $ssl): bool
{
$persistentId = $this->_config['port'] . $this->_config['timeout'] . $this->_config['database'];

if (empty($ssl)) {
return $this->_Redis->pconnect(
$server,
(int)$this->_config['port'],
(int)$this->_config['timeout'],
$persistentId
);
}

return $this->_Redis->pconnect(
$server,
(int)$this->_config['port'],
(int)$this->_config['timeout'],
$persistentId,
0,
0.0,
['ssl' => $ssl]
);
}

/**
* Write data for key into cache.
*
Expand Down Expand Up @@ -394,6 +462,16 @@ protected function unserialize(string $value)
return unserialize($value);
}

/**
* Create new Redis instance.
*
* @return \Redis
*/
protected function _createRedisInstance(): Redis
{
return new Redis();
}

/**
* Disconnects from the redis server
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
));
$this->abort();
} else {
$io->success(sprintf('Group "%s" was cleared.', $group));
$io->success(sprintf('Cache "%s" was cleared.', $groupConfig));
}
}

Expand Down
27 changes: 26 additions & 1 deletion app/vendor/cakephp/cakephp/src/Console/ConsoleInputArgument.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,23 @@ class ConsoleInputArgument
*/
protected $_choices;

/**
* Default value for the argument.
*
* @var string|null
*/
protected $_default;

/**
* Make a new Input Argument
*
* @param array<string, mixed>|string $name The long name of the option, or an array with all the properties.
* @param string $help The help text for this option
* @param bool $required Whether this argument is required. Missing required args will trigger exceptions
* @param array<string> $choices Valid choices for this option.
* @param string|null $default The default value for this argument.
*/
public function __construct($name, $help = '', $required = false, $choices = [])
public function __construct($name, $help = '', $required = false, $choices = [], $default = null)
{
if (is_array($name) && isset($name['name'])) {
foreach ($name as $key => $value) {
Expand All @@ -75,6 +83,7 @@ public function __construct($name, $help = '', $required = false, $choices = [])
$this->_help = $help;
$this->_required = $required;
$this->_choices = $choices;
$this->_default = $default;
}
}

Expand Down Expand Up @@ -119,6 +128,9 @@ public function help(int $width = 0): string
if ($this->_choices) {
$optional .= sprintf(' <comment>(choices: %s)</comment>', implode('|', $this->_choices));
}
if ($this->_default !== null) {
$optional .= sprintf(' <comment>default: "%s"</comment>', $this->_default);
}

return sprintf('%s%s%s', $name, $this->_help, $optional);
}
Expand All @@ -142,6 +154,16 @@ public function usage(): string
return $name;
}

/**
* Get the default value for this argument
*
* @return string|null
*/
public function defaultValue()
{
return $this->_default;
}

/**
* Check if this argument is a required argument
*
Expand Down Expand Up @@ -194,6 +216,9 @@ public function xml(SimpleXMLElement $parent): SimpleXMLElement
foreach ($this->_choices as $valid) {
$choices->addChild('choice', $valid);
}
if ($this->_default !== null) {
$option->addAttribute('default', $this->_default);
}

return $parent;
}
Expand Down
13 changes: 9 additions & 4 deletions app/vendor/cakephp/cakephp/src/Console/ConsoleOptionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,15 @@ public function parse(array $argv, ?ConsoleIo $io = null): array
}

foreach ($this->_args as $i => $arg) {
if ($arg->isRequired() && !isset($args[$i])) {
throw new ConsoleException(
sprintf('Missing required argument. The `%s` argument is required.', $arg->name())
);
if (!isset($args[$i])) {
if ($arg->isRequired()) {
throw new ConsoleException(
sprintf('Missing required argument. The `%s` argument is required.', $arg->name())
);
}
if ($arg->defaultValue() !== null) {
$args[$i] = $arg->defaultValue();
}
}
}
foreach ($this->_options as $option) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ public function toArray(): array;
*
* @param \Cake\Datasource\RepositoryInterface $repository The default repository object to use
* @return $this
* @deprecated
*/
public function repository(RepositoryInterface $repository);

Expand Down
31 changes: 15 additions & 16 deletions app/vendor/cakephp/cakephp/src/Http/ServerRequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,7 @@ protected static function marshalUriFromSapi(array $server, array $headers): Uri
$uri = marshalUriFromSapi($server, $headers);
[$base, $webroot] = static::getBase($uri, $server);

// Look in PATH_INFO first, as this is the exact value we need prepared
// by PHP.
$pathInfo = Hash::get($server, 'PATH_INFO');
if ($pathInfo) {
$uri = $uri->withPath($pathInfo);
} else {
$uri = static::updatePath($base, $uri);
}
$uri = static::updatePath($base, $uri);

if (!$uri->getHost()) {
$uri = $uri->withHost('localhost');
Expand Down Expand Up @@ -282,12 +275,18 @@ protected static function updatePath(string $base, UriInterface $uri): UriInterf
if (empty($path) || $path === '/' || $path === '//' || $path === '/index.php') {
$path = '/';
}
$endsWithIndex = '/' . (Configure::read('App.webroot') ?: 'webroot') . '/index.php';
$endsWithLength = strlen($endsWithIndex);
if (
strlen($path) >= $endsWithLength &&
substr($path, -$endsWithLength) === $endsWithIndex
) {
// Check for $webroot/index.php at the start and end of the path.
$search = '';
if ($path[0] === '/') {
$search .= '/';
}
$search .= (Configure::read('App.webroot') ?: 'webroot') . '/index.php';
if (strpos($path, $search) === 0) {
$path = substr($path, strlen($search));
} elseif (substr($path, -strlen($search)) === $search) {
$path = '/';
}
if (!$path) {
$path = '/';
}

Expand Down Expand Up @@ -321,9 +320,9 @@ protected static function getBase(UriInterface $uri, array $server): array
// Clean up additional / which cause following code to fail..
$base = preg_replace('#/+#', '/', $base);

$indexPos = strpos($base, '/' . $webroot . '/index.php');
$indexPos = strpos($base, '/index.php');
if ($indexPos !== false) {
$base = substr($base, 0, $indexPos) . '/' . $webroot;
$base = substr($base, 0, $indexPos);
}
if ($webroot === basename($base)) {
$base = dirname($base);
Expand Down
2 changes: 1 addition & 1 deletion app/vendor/cakephp/cakephp/src/I18n/DateFormatTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ protected function _formatObject($date, $format, ?string $locale): string
static::$_formatters[$key] = $formatter;
}

return static::$_formatters[$key]->format($date->format('U'));
return static::$_formatters[$key]->format($date);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions app/vendor/cakephp/cakephp/src/I18n/MessagesFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,17 @@ public function translationsFolders(): array
foreach ($localePaths as $path) {
foreach ($folders as $folder) {
$searchPaths[] = $path . $folder . DIRECTORY_SEPARATOR;
// gettext compatible paths, see https://www.php.net/manual/en/function.gettext.php
$searchPaths[] = $path . $folder . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR;
}
}

if ($this->_plugin && Plugin::isLoaded($this->_plugin)) {
$basePath = App::path('locales', $this->_plugin)[0];
foreach ($folders as $folder) {
$searchPaths[] = $basePath . $folder . DIRECTORY_SEPARATOR;
// gettext compatible paths, see https://www.php.net/manual/en/function.gettext.php
$searchPaths[] = $basePath . $folder . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR;
}
}

Expand Down
9 changes: 9 additions & 0 deletions app/vendor/cakephp/cakephp/src/I18n/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ public static function formatDelta($value, array $options = []): string
* - `zero` - The text to use for zero values, can be a string or a number. e.g. 0, 'Free!'
* - `places` - Number of decimal places to use. e.g. 2
* - `precision` - Maximum Number of decimal places to use, e.g. 2
* - `roundingMode` - Rounding mode to use. e.g. NumberFormatter::ROUND_HALF_UP.
* When not set locale default will be used
* - `pattern` - An ICU number pattern to use for formatting the number. e.g #,##0.00
* - `useIntlCode` - Whether to replace the currency symbol with the international
* currency code.
Expand Down Expand Up @@ -365,6 +367,8 @@ public static function setDefaultCurrencyFormat($currencyFormat = null): void
* numbers representing money or a NumberFormatter constant.
* - `places` - Number of decimal places to use. e.g. 2
* - `precision` - Maximum Number of decimal places to use, e.g. 2
* - `roundingMode` - Rounding mode to use. e.g. NumberFormatter::ROUND_HALF_UP.
* When not set locale default will be used
* - `pattern` - An ICU number pattern to use for formatting the number. e.g #,##0.00
* - `useIntlCode` - Whether to replace the currency symbol with the international
* currency code.
Expand Down Expand Up @@ -406,6 +410,7 @@ public static function formatter(array $options = []): NumberFormatter
$options = array_intersect_key($options, [
'places' => null,
'precision' => null,
'roundingMode' => null,
'pattern' => null,
'useIntlCode' => null,
]);
Expand Down Expand Up @@ -452,6 +457,10 @@ protected static function _setAttributes(NumberFormatter $formatter, array $opti
$formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, $options['precision']);
}

if (isset($options['roundingMode'])) {
$formatter->setAttribute(NumberFormatter::ROUNDING_MODE, $options['roundingMode']);
}

if (!empty($options['pattern'])) {
$formatter->setPattern($options['pattern']);
}
Expand Down
Loading

0 comments on commit 532b63b

Please sign in to comment.