class-cache.php
1 year ago
class-cookiestate.php
3 years ago
class-errors.php
1 year ago
class-files.php
1 year ago
class-host.php
1 year ago
class-modules.php
1 year ago
class-paths.php
1 year ago
class-status.php
1 year ago
class-visitor.php
1 year ago
class-errors.php
50 lines
| 1 | <?php |
| 2 | /** |
| 3 | * An errors utility class for Jetpack. |
| 4 | * |
| 5 | * @package automattic/jetpack-status |
| 6 | */ |
| 7 | |
| 8 | // phpcs:disable WordPress.PHP.IniSet.display_errors_Disallowed |
| 9 | // phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged |
| 10 | // phpcs:disable WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure_error_reporting |
| 11 | // phpcs:disable WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting |
| 12 | |
| 13 | namespace Automattic\Jetpack; |
| 14 | |
| 15 | /** |
| 16 | * Erros class. |
| 17 | * |
| 18 | * @deprecated since 3.2.0 |
| 19 | */ |
| 20 | class Errors { |
| 21 | /** |
| 22 | * Catches PHP errors. Must be used in conjunction with output buffering. |
| 23 | * |
| 24 | * @deprecated since 3.2.0 |
| 25 | * @param bool $catch True to start catching, False to stop. |
| 26 | * |
| 27 | * @static |
| 28 | */ |
| 29 | public function catch_errors( $catch ) { |
| 30 | _deprecated_function( __METHOD__, '3.2.0' ); |
| 31 | static $display_errors, $error_reporting; |
| 32 | |
| 33 | if ( $catch ) { |
| 34 | // Force error reporting and output, store original values. |
| 35 | $display_errors = @ini_set( 'display_errors', 1 ); |
| 36 | $error_reporting = @error_reporting( E_ALL ); |
| 37 | if ( class_exists( 'Jetpack' ) ) { |
| 38 | add_action( 'shutdown', array( 'Jetpack', 'catch_errors_on_shutdown' ), 0 ); |
| 39 | } |
| 40 | } else { |
| 41 | // Restore the original values for error reporting and output. |
| 42 | @ini_set( 'display_errors', $display_errors ); |
| 43 | @error_reporting( $error_reporting ); |
| 44 | if ( class_exists( 'Jetpack' ) ) { |
| 45 | remove_action( 'shutdown', array( 'Jetpack', 'catch_errors_on_shutdown' ), 0 ); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 |