diff --git a/changelog.md b/changelog.md index 37d63af..f4aef1f 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# [2.5.1] - 2026-10-02 + +- Fixed - `slic composer-cache set` and `unset` save their settings without starting a stopped stack. When confirmed, only running PHP services are recreated to apply the cache mount, leaving stopped services and dependencies alone. CI can configure the cache before selecting a project's PHP version without starting containers prematurely. + # [2.5.0] - 2026-09-28 - Breaking Change - Playwright suites that launch browsers directly must use built-in fixtures or explicitly connect to the remote browser. Browser-facing `localhost` URLs and `download.path()` calls may also need changes. See the [migration guidance](docs/playwright.md#update-setup-code-that-launches-a-browser-directly) before upgrading. diff --git a/slic.php b/slic.php index fc05577..204c607 100644 --- a/slic.php +++ b/slic.php @@ -57,7 +57,7 @@ ] ); $cli_name = 'slic'; -const CLI_VERSION = '2.5.0'; +const CLI_VERSION = '2.5.1'; // If the run-time option `-q`, for "quiet", is specified, then do not print the header. if ( in_array( '-q', $argv, true ) || ( in_array( 'exec', $argv, true ) && ! in_array( 'help', $argv, true ) ) ) { diff --git a/src/slic.php b/src/slic.php index b541c75..208cbbc 100644 --- a/src/slic.php +++ b/src/slic.php @@ -1256,18 +1256,35 @@ function slic_handle_composer_cache( callable $args ) { echo PHP_EOL . PHP_EOL; + // Setting the cache before `slic use` must not start containers with the default PHP version. + $running_services = array_values( array_filter( array_keys( php_services() ), static function ( string $service ): bool { + return service_running( $service ); + } ) ); + + if ( ! $running_services ) { + echo 'The cache setting will apply when the PHP services next start.' . PHP_EOL; + + return; + } + $restart_services = ask( - 'Would you like to restart the WordPress (NOT the database) and Codeception services now?', + 'Would you like to recreate the running PHP services (' . implode( ', ', $running_services ) . ') to apply the cache setting now?', 'yes' ); + if ( $restart_services ) { putenv( "COMPOSER_CACHE_DIR={$value}" ); - // Call for a hard restart to make sure the web-server will restart its php-fpm connection. - restart_php_services( true ); + // Bind mount changes require recreation. Leave stopped services and dependencies alone. + $status = slic_realtime()( array_merge( [ 'up', '--wait', '--no-deps', '--force-recreate' ], $running_services ) ); + + if ( $status !== 0 ) { + echo magenta( 'Could not recreate the PHP services with the new Composer cache directory.' . PHP_EOL ); + exit( $status ); + } } else { echo colorize( - PHP_EOL . PHP_EOL . "Tear down the stack with down and restart it to apply the new settings!" . PHP_EOL + PHP_EOL . 'The cache setting is saved. Recreate the PHP services to apply it.' . PHP_EOL ); } }