Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve the output and some checks on the debug switching script #2702

Merged
merged 3 commits into from
Feb 14, 2024
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ permalink: /docs/en-US/changelog/
* Better error messages with links to docs when trying to use a PHP version that isn't installed ( #2689 )
* Opted out of Dotnet package telemetry ( #2689 )
* Replace references to the Squizlab PHPCS with that from the PHPCS Standards org ( #2692 )
* Better PHP Debug mod switching outputs and checks ( #2702 )
* PHP Info and Xdebug info pages now state their versions ( #2702 )

### Bug Fixes

Expand Down
54 changes: 40 additions & 14 deletions config/homebin/switch_php_debugmod
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,21 @@ disable_phpmods() {
for phpv in $(phpquery -V)
do
if is_module_enabled_fpm "${phpv}" "${i}"; then
vvv_info " ✘ Disabling active PHP <b>v${phpv}</b><info> debug mod: </info><b>'${i}'</b>"
sudo phpdismod -q -s fpm -v "${phpv}" "${i}"
sudo phpdismod -q -s cli -v "${phpv}" "${i}"
#vvv_info " ✘ Disabling active PHP <b>v${phpv}</b><info> debug mod: </info><b>'${i}'</b>"
#sudo phpdismod -q -s fpm -v "${phpv}" "${i}"
#sudo phpdismod -q -s cli -v "${phpv}" "${i}"

if sudo phpdismod -q -v "${phpv}" -s fpm "${i}"; then
vvv_success " - ✔ Disabled ${i} for PHP <b>v${phpv} FPM</b>"
else
vvv_error " - x Could not disable ${i} for PHP <b>v${phpv} FPM</b>"
fi

if sudo phpdismod -q -v "${phpv}" -s cli "${i}"; then
vvv_success " - ✔ Disabled ${i} for PHP <b>v${phpv} CLI</b>"
else
vvv_error " - x Could not disable ${i} for PHP <b>v${phpv} CLI</b>"
fi
fi
done
done
Expand All @@ -40,11 +52,19 @@ enable_phpmod() {
for phpv in $(phpquery -V)
do
if is_module_installed_fpm "${phpv}" "${1}"; then
vvv_info " * Enabling <b>'${1}'</b><info> for PHP <b>v${phpv}</b>"
sudo phpenmod -q -v "${phpv}" -s fpm "${1}"
sudo phpenmod -q -v "${phpv}" -s cli "${1}"
if sudo phpenmod -q -v "${phpv}" -s fpm "${1}"; then
vvv_success " - ✔ Enabled ${1} for PHP <b>v${phpv} FPM</b>"
else
vvv_error " - x Could not enable ${1} for PHP <b>v${phpv} FPM</b>"
fi

if sudo phpenmod -q -v "${phpv}" -s cli "${1}"; then
vvv_success " - ✔ Enabled ${1} for PHP <b>v${phpv} CLI</b>"
else
vvv_error " - x Could not enable ${1} for PHP <b>v${phpv} CLI</b>"
fi
else
vvv_info " * Skipped enabling ${1} in PHP <b>v${phpv}</b><info>, module isn't installed for this version"
vvv_info " - ? Skipped enabling ${1} in PHP <b>v${phpv}</b><info>, module isn't installed for this version"
fi
done
}
Expand All @@ -65,9 +85,19 @@ is_module_installed_fpm() {

restart_phpfpm() {
vvv_info " * Restarting PHP FPM services so that the change takes effect"
find /etc/init.d/ -name "php*-fpm" -exec bash -c 'sudo service "$(basename "$0")" restart' {} \;
if find /etc/init.d/ -name "php*-fpm" -exec bash -c 'sudo service "$(basename "$0")" restart' {} \;; then
vvv_success " ✔ Completed restart sequence"
else
vvv_error " x One of the PHP services failed to restart, changes may not take effect."
fi
}


vvv_info "Attempting to disable PHP debug mods and switch to <b>${mod}</b><info>:"
if [[ "${mod}" == "pcov" ]]; then
vvv_info " * pcov supports PHP 7.1 and above, it is not available for 5.6 and 7.0"
fi

disable_phpmods phpmods[@]

if [[ "${mod}" == "none" ]]; then
Expand All @@ -76,10 +106,6 @@ if [[ "${mod}" == "none" ]]; then
exit 0
fi

if [[ "${mod}" == "pcov" ]]; then
vvv_info " * pcov supports PHP 7.1 and above, it is not available for 5.6 and 7.0"
fi

# Tideways needs 2 mods enabling
if [[ "${mod}" == "tideways" ]]; then
enable_phpmod "xhgui"
Expand All @@ -91,11 +117,11 @@ fi

if [[ "${mod}" == "xdebug" ]]; then
# Ensure the log file for xdebug is group writeable.
vvv_info " * Making sure log/php/xdebug-remote.log is readable and present"
vvv_info " * Making sure <b>log/php/xdebug-remote.log</b><info> is readable and present"
sudo touch /var/log/php/xdebug-remote.log
sudo chmod 664 /var/log/php/xdebug-remote.log
fi

enable_phpmod "${mod}"
restart_phpfpm
vvv_success " ✔ PHP Debug mod switch to <b>${mod}</b><success> on all available PHP versions complete.</success>"
vvv_info " ✔ PHP Debug mod switch to <b>${mod}</b><success> on all available PHP versions complete.</success>"
4 changes: 2 additions & 2 deletions www/default/phpinfo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
*/
?>
<nav class="center">
<a href="//vvv.test/phpinfo/">PHP Info</a>
<a href="//vvv.test/phpinfo/">PHP Info (v<?php echo phpversion(); ?>)</a>
<?php
if ( function_exists( 'xdebug_info' ) ) {
?>&middot; <a href="//vvv.test/xdebuginfo/">Xdebug Info</a><?php
?>&middot; <a href="//vvv.test/xdebuginfo/">Xdebug Info (v<?php echo phpversion('xdebug'); ?>)</a><?php
}
?>
</nav>
Expand Down
5 changes: 2 additions & 3 deletions www/default/xdebuginfo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
?>
<style type="text/css">
body {
color: #222;
font-family: sans-serif;
}

Expand All @@ -25,10 +24,10 @@
}
</style>
<nav class="center">
<a href="//vvv.test/phpinfo/">PHP Info</a>
<a href="//vvv.test/phpinfo/">PHP Info (v<?php echo phpversion(); ?>)</a>
<?php
if ( function_exists( 'xdebug_info' ) ) {
?>&middot; <a href="//vvv.test/xdebuginfo/">Xdebug Info</a><?php
?>&middot; <a href="//vvv.test/xdebuginfo/">Xdebug Info (v<?php echo phpversion('xdebug'); ?>)</a><?php
}
?>
</nav>
Expand Down
Loading