Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions system/Commands/Cache/ClearCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ protected function execute(array $arguments, array $options): int
$config->handler = $driver;

if (! service('cache', $config)->clean()) {
CLI::error('Error occurred while clearing the cache.');
CLI::error(sprintf('Error occurred while clearing the cache using the "%s" driver.', $driver));

return EXIT_ERROR;
}

CLI::write('Cache cleared.', 'green');
CLI::write(sprintf('Cache cleared using the "%s" driver.', $driver), 'green');

return EXIT_SUCCESS;
}
Expand Down
5 changes: 4 additions & 1 deletion system/Commands/Cache/InfoCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ protected function execute(array $arguments, array $options): int
$config = config(Cache::class);

if ($config->handler !== 'file') {
CLI::error('This command only supports the file cache handler.');
CLI::error(sprintf(
'This command only supports the file cache handler. The configured handler is "%s".',
$config->handler,
));

return EXIT_ERROR;
}
Expand Down
6 changes: 4 additions & 2 deletions system/Commands/Housekeeping/ClearDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ protected function execute(array $arguments, array $options): int
{
helper('filesystem');

$path = clean_path(WRITEPATH . 'debugbar');

if (! delete_files(WRITEPATH . 'debugbar', htdocs: true)) {
CLI::error('Error deleting the debugbar JSON files.');
CLI::error(sprintf('Error deleting the debugbar JSON files in "%s".', $path));

return EXIT_ERROR;
}

CLI::write('Debugbar cleared.', 'green');
CLI::write(sprintf('Cleared debugbar JSON files in "%s".', $path), 'green');

return EXIT_SUCCESS;
}
Expand Down
7 changes: 5 additions & 2 deletions tests/system/Commands/Cache/ClearCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ public function testClearCacheWorks(): void
command('cache:clear');

$this->assertNull(cache('foo'));
$this->assertStringContainsString('Cache cleared.', $this->getStreamFilterBuffer());
$this->assertStringContainsString(
sprintf('Cache cleared using the "%s" driver.', config('Cache')->handler),
$this->getStreamFilterBuffer(),
);
}

public function testClearCacheFails(): void
Expand All @@ -82,7 +85,7 @@ public function testClearCacheFails(): void
command('cache:clear');

$this->assertSame(
"\nError occurred while clearing the cache.\n",
sprintf("\nError occurred while clearing the cache using the \"%s\" driver.\n", config('Cache')->handler),
preg_replace('/\e\[[^m]+m/', '', $this->getStreamFilterBuffer()),
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Commands/Cache/InfoCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testInfoCacheErrorsOnInvalidHandler(): void
$this->assertSame(
<<<'EOT'

This command only supports the file cache handler.
This command only supports the file cache handler. The configured handler is "redis".

EOT,
$this->getUndecoratedBuffer(),
Expand Down
4 changes: 2 additions & 2 deletions tests/system/Commands/Housekeeping/ClearDebugbarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function testClearDebugbarWorks(): void
$this->assertFileDoesNotExist(WRITEPATH . 'debugbar' . DIRECTORY_SEPARATOR . "debugbar_{$this->time}.json");
$this->assertFileExists(WRITEPATH . 'debugbar' . DIRECTORY_SEPARATOR . 'index.html');
$this->assertSame(
"\nDebugbar cleared.\n",
sprintf("\nCleared debugbar JSON files in \"%s\".\n", clean_path(WRITEPATH . 'debugbar')),
preg_replace('/\e\[[^m]+m/', '', $this->getStreamFilterBuffer()),
);
}
Expand All @@ -95,7 +95,7 @@ public function testClearDebugbarWithError(): void

$this->assertFileExists($path);
$this->assertSame(
"\nError deleting the debugbar JSON files.\n",
sprintf("\nError deleting the debugbar JSON files in \"%s\".\n", clean_path(WRITEPATH . 'debugbar')),
preg_replace('/\e\[[^m]+m/', '', $this->getStreamFilterBuffer()),
);
}
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.8.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Behavior Changes
- **Commands:** The ``filter:check`` command now requires the HTTP method argument to be uppercase (e.g., ``spark filter:check GET /`` instead of ``spark filter:check get /``).
- **Commands:** Several built-in commands have been migrated from ``BaseCommand`` to the modern ``AbstractCommand`` style. Applications that extend a built-in command to override
behaviour may need to re-implement against the modern API (``configure()`` + ``execute()`` and the ``#[Command]`` attribute) once the class it extends is migrated, or, preferably, compose instead of extending. Invocations on the command line are unaffected.
- **Commands:** The success and error messages from ``debugbar:clear``, ``cache:clear``, and ``cache:info`` now include the affected path or cache driver/handler so the user can see which resource was acted on (or rejected). Scripts asserting on the prior literal text will need to be updated.
- **Database:** The Postgre driver's ``$db->error()['code']`` previously always returned ``''``. It now returns the 5-character SQLSTATE string for query and transaction failures (e.g., ``'42P01'``), or ``'08006'`` for connection-level failures. Code that relied on ``$db->error()['code'] === ''`` will need updating.
- **Filters:** HTTP method matching for method-based filters is now case-sensitive. The keys in ``Config\Filters::$methods`` must exactly match the request method
(e.g., ``GET``, ``POST``). Lowercase method names (e.g., ``post``) will no longer match.
Expand Down
Loading