Skip to content

Commit

Permalink
do not display php cli issues as errors if async archiving is not sup…
Browse files Browse the repository at this point in the history
…ported (#1140)

* do not display php cli issues as errors if async archiving is not supported

* bump version
  • Loading branch information
diosmosis authored Jun 9, 2024
1 parent 0cbddae commit dc00dfd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
== Changelog ===

= 5.0.8 =
* Improve PHP CLI diagnostic change: avoid reporting issues when a hosting provider does not support CLI archiving.

= 5.0.7 =
* Bug fix: setting an email report's segment to "All Visits" did not work properly.
* Update core Matomo to version 5.0.3.
Expand Down
42 changes: 21 additions & 21 deletions classes/WpMatomo/Admin/SystemReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,16 +387,32 @@ private function get_phpcli_info() {
$rows = [];

if ( $this->shell_exec_available ) {
try {
$cli_multi = new CliMulti();

// phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
$supports_async = $cli_multi->supportsAsync;
} catch ( \Exception $ex ) {
$rows[] = [
'name' => esc_html__( 'PHP CLI configuration', 'matomo' ),
'value' => esc_html__( 'Unexpected error', 'matomo' ),
'is_warning' => true,
'comment' => sprintf( esc_html__( 'Could not detect whether async archiving is enabled: %s', 'matomo' ), $ex->getMessage() ),
];
}

$phpcli_version = $this->get_phpcli_output( '-r "echo phpversion();"' );

$is_warning = false;
$comment = '';

$advanced_settings_url = home_url( '/wp-admin/admin.php?page=matomo-settings&tab=advanced#matomo[disable_async_archiving]' );

$is_using_cli_archiving = ! \WpMatomo::is_async_archiving_manually_disabled() && $supports_async;

// phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
if ( version_compare( $phpcli_version, PHP_VERSION ) < 0 ) {
if ( ! \WpMatomo::is_async_archiving_manually_disabled() ) {
if ( $is_using_cli_archiving ) {
$is_warning = true;
}

Expand Down Expand Up @@ -429,10 +445,12 @@ private function get_phpcli_info() {
'name' => esc_html__( 'MySQLi support', 'matomo' ),
'value' => $value,
'comment' => $comment,
'is_error' => $is_error,
'is_error' => $is_using_cli_archiving ? $is_error : false,
];

$this->check_wp_can_be_loaded_in_php_cli( $rows );
if ( $supports_async ) {
$this->check_wp_can_be_loaded_in_php_cli( $rows );
}
}

return $rows;
Expand All @@ -448,24 +466,6 @@ private function check_wp_can_be_loaded_in_php_cli( &$rows ) {
return;
}

try {
$cli_multi = new CliMulti();

// phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
$supports_async = $cli_multi->supportsAsync;
} catch ( \Exception $ex ) {
$rows[] = [
'name' => esc_html__( 'PHP CLI configuration', 'matomo' ),
'value' => esc_html__( 'Unexpected error', 'matomo' ),
'is_warning' => true,
'comment' => sprintf( esc_html__( 'Could not detect whether async archiving is enabled: %s', 'matomo' ), $ex->getMessage() ),
];
}

if ( ! $supports_async ) {
return;
}

$command = "-r 'require_once( \"$wp_load_path\" );'";
$output = $this->get_phpcli_output( $command );
if ( empty( $output ) ) {
Expand Down
2 changes: 1 addition & 1 deletion matomo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Privacy friendly, GDPR compliant and self-hosted. Matomo is the #1 Google Analytics alternative that gives you control of your data. Free and secure.
* Author: Matomo
* Author URI: https://matomo.org
* Version: 5.0.7
* Version: 5.0.8
* Domain Path: /languages
* WC requires at least: 2.4.0
* WC tested up to: 8.8.3
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: matomoteam
Tags: matomo,analytics,statistics,stats,ecommerce
Requires at least: 4.8
Tested up to: 6.5.4
Stable tag: 5.0.7
Stable tag: 5.0.8
Requires PHP: 7.2.5
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Expand Down

0 comments on commit dc00dfd

Please sign in to comment.