Skip to content

Commit

Permalink
try to set zlib.output_compression to avoid showing the technical err…
Browse files Browse the repository at this point in the history
…or to users when we can change the setting ourselves (#1223)
  • Loading branch information
diosmosis authored Nov 28, 2024
1 parent fdd39ab commit 5bf6151
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<exclude name="PHPCompatibility.Classes.NewAnonymousClasses.Found"/>
<exclude name="PHPCompatibility.InitialValue.NewConstantScalarExpressions.constFound"/>
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
<exclude name="WordPress.PHP.IniSet.Risky"/>
</rule>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
Expand Down
6 changes: 6 additions & 0 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?php

// if we're loading Matomo directly, rather than bootstrapping from within WordPress,
// try to set some INI config values Matomo needs
if ( ! defined( 'ABSPATH' ) ) {
@ini_set( 'zlib.output_compression', false );
}

// see plugins/WordPress/WordPress.php for more info
$GLOBALS['MATOMO_WP_ORIGINAL_ERROR_REPORTING'] = error_reporting();

Expand Down
3 changes: 3 additions & 0 deletions classes/WpMatomo/Admin/SystemReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,9 @@ private function get_server_info() {
'comment' => ! empty( $disabled_functions ) ? $disabled_functions : '',
];

// try to set it before checking, since we try to set it in /app/bootstrap.php
@ini_set( 'zlib.output_compression', false );

$zlib_compression = ini_get( 'zlib.output_compression' );
$row = [
'name' => 'zlib.output_compression is off',
Expand Down

0 comments on commit 5bf6151

Please sign in to comment.