Skip to content

Commit

Permalink
Merge pull request #138 from stellarwp/1.1.5
Browse files Browse the repository at this point in the history
1.1.5
  • Loading branch information
lucatume authored Nov 29, 2022
2 parents 5e9a970 + 0274811 commit 88afe33
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/slic-wordpress-php7.3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:
type=ref,event=tag
type=semver,pattern={{raw}}
- name: Change Dockerfile to php8.0
run: "sed -i 's/7.4/7.3/g' containers/slic/Dockerfile"
- name: Change Dockerfile to php7.3
run: "sed -i 's/7.4/7.3/g' containers/wordpress/Dockerfile"

- name: Build and push slic-wordpress Docker image
uses: docker/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/slic-wordpress-php8.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
type=semver,pattern={{raw}}
- name: Change Dockerfile to php8.0
run: "sed -i 's/7.4/8.0/g' containers/slic/Dockerfile"
run: "sed -i 's/7.4/8.0/g' containers/wordpress/Dockerfile"

- name: Build and push slic-wordpress Docker image
uses: docker/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/slic-wordpress-php8.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:
type=ref,event=tag
type=semver,pattern={{raw}}
- name: Change Dockerfile to php8.0
run: "sed -i 's/7.4/8.1/g' containers/slic/Dockerfile"
- name: Change Dockerfile to php8.1
run: "sed -i 's/7.4/8.1/g' containers/wordpress/Dockerfile"

- name: Build and push slic-wordpress Docker image
uses: docker/[email protected]
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ 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).

## [1.1.5] - 2022-11-29

* Fix - Enable and disable XDebug correctly in WorPress and slic container removing restart requirement.
* Fix - Avoid issues with missing `/usr/sbin/sendmail` during WordPress installation. [#134]

## [1.1.4] - 2022-10-27

* Fix - Simplify the `restart_all_services()` code so that containers are all shut down and _then_ all started.
Expand Down
5 changes: 3 additions & 2 deletions containers/slic/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM composer:1 AS composer1
FROM composer:2 AS composer2

# Use a fixed PHP version as base!
FROM php:7.4.29
FROM php:7.4.33

# Install and make wp-cli binary available and executable by all users.
ADD https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar /usr/local/bin/wp
Expand Down Expand Up @@ -33,7 +33,8 @@ RUN chmod a+x /usr/local/bin/xdebug-on && \

# Make the PHP configuration directory recursively readable and writable to allow all users to activate and deactivate XDebug.
RUN chmod -R a+rwx /usr/local/etc/php/conf.d
RUN echo "xdebug.mode=develop,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini#A command that will keep the container running and alive.
RUN echo "xdebug.mode=develop,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN xdebug-off

# Install Composer 1 and 2 from the respective images and make them world-executable.
Expand Down
3 changes: 0 additions & 3 deletions containers/slic/xdebug-off.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@
xdebug_config_file=$(php --ini | grep xdebug | cut -d, -f1)
sed -i '/^zend_extension/ s/zend_extension/;zend_extension/g' "$xdebug_config_file"
php -v
echo ""
echo "XDebug is \033[31moff\033[0m."
echo ""
3 changes: 0 additions & 3 deletions containers/slic/xdebug-on.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@
xdebug_config_file=$(php --ini | grep xdebug | cut -d, -f1)
sed -i '/^;zend_extension/ s/;zend_extension/zend_extension/g' "$xdebug_config_file"
php -v
echo ""
echo "XDebug is \033[32mon\033[0m."
echo ""
7 changes: 3 additions & 4 deletions containers/wordpress/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ COPY xdebug-on.sh /usr/local/bin/xdebug-on
COPY xdebug-off.sh /usr/local/bin/xdebug-off
RUN chmod a+x /usr/local/bin/xdebug-on && \
chmod a+x /usr/local/bin/xdebug-off && \
xdebug-off \
echo "xdebug.mode=develop,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
chmod -R a+rwx /usr/local/etc/php/conf.d

#@todo restart apache on xdebug on off
echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
xdebug-off
RUN chmod -R a+rwx /usr/local/etc/php/conf.d
5 changes: 5 additions & 0 deletions containers/wordpress/xdebug-off.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
xdebug_config_file=$(php --ini | grep xdebug | cut -d, -f1)
sed -i '/^zend_extension/ s/zend_extension/;zend_extension/g' "$xdebug_config_file"
php -v
# Kill the oldest php-fpm process, the manager.
pkill -o -USR2 php-fpm
# Restart the php-fpm server and php-fpm when used as a module, ignore errors if not running.
/etc/init.d/apache2 reload > /dev/null 2>&1
exit 0
5 changes: 5 additions & 0 deletions containers/wordpress/xdebug-on.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
xdebug_config_file=$(php --ini | grep xdebug | cut -d, -f1)
sed -i '/^;zend_extension/ s/;zend_extension/zend_extension/g' "$xdebug_config_file"
php -v
# Kill the oldest php-fpm process, the manager.
pkill -o -USR2 php-fpm
# Restart the php-fpm server and php-fpm when used as a module, ignore errors if not running.
/etc/init.d/apache2 reload > /dev/null 2>&1
exit 0
2 changes: 1 addition & 1 deletion slic.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
] );

$cli_name = 'slic';
const CLI_VERSION = '1.1.4';
const CLI_VERSION = '1.1.5';

// 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 ) ) ) {
Expand Down
36 changes: 17 additions & 19 deletions src/slic.php
Original file line number Diff line number Diff line change
Expand Up @@ -959,31 +959,29 @@ function slic_handle_xdebug( callable $args ) {
}

$value = 'on' === $toggle ? 1 : 0;
echo 'XDebug status: ' . ( $value ? light_cyan( 'on' ) : magenta( 'off' ) );
echo 'XDebug status: ' . ( $value ? light_cyan( 'on' ) : magenta( 'off' ) ) . PHP_EOL;

if ( $value === (int) getenv( 'XDE' ) ) {
return;
if ( $value !== (int) getenv( 'XDE' ) ) {
$xdebug_env_vars = [ 'XDE' => $value, 'XDEBUG_DISABLE' => 1 === $value ? 0 : 1 ];
write_env_file( $run_settings_file, $xdebug_env_vars, true );
}

$xdebug_env_vars = [ 'XDE' => $value, 'XDEBUG_DISABLE' => 1 === $value ? 0 : 1 ];
write_env_file( $run_settings_file, $xdebug_env_vars, true );
foreach ( [ 'slic', 'wordpress' ] as $service ) {
if ( ! service_running( $service ) ) {
continue;
}

echo PHP_EOL . PHP_EOL;
echo PHP_EOL;

$restart_services = ask(
'Would you like to restart the WordPress (NOT the database) services now?',
'yes'
);
if ( $restart_services ) {
foreach ( $xdebug_env_vars as $key => $value ) {
putenv( "{$key}={$value}" );
if ( $value === 1 ) {
// Enable XDebug in the service.
echo colorize( "Enabling XDebug in <light_cyan>{$service}</light_cyan>..." );
slic_realtime()( [ 'exec', $service, 'xdebug-on' ] );
} else {
echo colorize( "Disabling XDebug in <light_cyan>{$service}</light_cyan>..." );
// Disable XDebug in the service.
slic_realtime()( [ 'exec', $service, 'xdebug-off' ] );
}
// Call for a hard restart to make sure the web-server will restart its php-fpm connection.
restart_php_services( true );
} else {
echo colorize(
PHP_EOL . PHP_EOL . "Tear down the stack with <light_cyan>down</light_cyan> and restar it to apply the new settings!" . PHP_EOL
);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ function ensure_wordpress_installed(): bool {
'$_POST["admin_password2"] = "password"; ' .
'$_POST["admin_email"] = "[email protected]"; ' .
'$_POST["blog_public"] = 1; ' .
'function wp_mail(){ return true; } ' . // It's pluggable, this will mute it.
'include "' . $install_file . '";';

$command = escapeshellarg( PHP_BINARY ) . ' -r \'' . $code . '\'';
Expand Down

0 comments on commit 88afe33

Please sign in to comment.