From c82753415a6090af7e2d330922b1dcf3e961f2d0 Mon Sep 17 00:00:00 2001 From: Danish Shakeel Date: Mon, 27 Sep 2021 15:32:55 +0530 Subject: [PATCH 1/3] Add notice for auth create/delete When calling ee auth create or ee auth delete, a deprecation warning will be shown. create/delete is add/remove now. --- php/EE/Runner.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/php/EE/Runner.php b/php/EE/Runner.php index 8e608b315..193bd1c93 100644 --- a/php/EE/Runner.php +++ b/php/EE/Runner.php @@ -777,6 +777,17 @@ public function start() { $this->arguments[] = 'help'; } + // Print a deprecation warning if 'create' or 'delete' is being used (ee auth). + if ( 'auth' === $this->arguments[0] && ( 'create' === $this->arguments[1] || 'delete' === $this->arguments[1] ) ) { + $deprecation_warn = sprintf( + '`%1$s` is deprecated and will be replaced with `%2$s` instead. See: `ee auth %2$s`', + $this->arguments[1], + ( 'create' === $this->arguments[1] ? 'add' : 'remove' ) + ); + + EE::warning( $deprecation_warn ); + } + // Protect 'cli info' from most of the runtime, // except when the command will be run over SSH if ( ! empty( $this->arguments[0] ) && 'cli' === $this->arguments[0] && ! empty( $this->arguments[1] ) && 'info' === $this->arguments[1] ) { From 97e5f5da13649856278344aec3edf766c226d434 Mon Sep 17 00:00:00 2001 From: Danish Shakeel Date: Mon, 27 Sep 2021 15:40:30 +0530 Subject: [PATCH 2/3] Fix typo --- php/EE/Runner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/EE/Runner.php b/php/EE/Runner.php index 193bd1c93..154c0b1bd 100644 --- a/php/EE/Runner.php +++ b/php/EE/Runner.php @@ -780,7 +780,7 @@ public function start() { // Print a deprecation warning if 'create' or 'delete' is being used (ee auth). if ( 'auth' === $this->arguments[0] && ( 'create' === $this->arguments[1] || 'delete' === $this->arguments[1] ) ) { $deprecation_warn = sprintf( - '`%1$s` is deprecated and will be replaced with `%2$s` instead. See: `ee auth %2$s`', + '`%1$s` is deprecated and will be replaced with `%2$s`. See: `ee auth %2$s`', $this->arguments[1], ( 'create' === $this->arguments[1] ? 'add' : 'remove' ) ); From daf49a8520140dae299ca217a0f21a51e05effd9 Mon Sep 17 00:00:00 2001 From: Danish Shakeel Date: Mon, 27 Sep 2021 16:53:44 +0530 Subject: [PATCH 3/3] Add support for notices Instead of using EE::warning(), EE::notice() can be used to print (deprecation) notices. Prints a message prefixed with "Notice: " in yellow. --- php/EE/Loggers/Regular.php | 11 ++++++++++- php/EE/Runner.php | 2 +- php/class-ee.php | 11 +++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/php/EE/Loggers/Regular.php b/php/EE/Loggers/Regular.php index 168e8fbc8..5c06a91ca 100644 --- a/php/EE/Loggers/Regular.php +++ b/php/EE/Loggers/Regular.php @@ -42,7 +42,7 @@ public function warning( $message ) { } /** - * Write an message to STDERR, prefixed with "Error: ". + * Write a message to STDERR, prefixed with "Error: ". * * @param string $message Message to write. */ @@ -50,6 +50,15 @@ public function error( $message ) { $this->_line( $message, 'Error', '%R', STDERR ); } + /** + * Write a message, prefixed with "Notice: ". + * + * @param string $message Message to write. + */ + public function notice( $message ) { + $this->_line( $message, 'Notice', '%y' ); + } + /** * Similar to error( $message ), but outputs $message in a red box * diff --git a/php/EE/Runner.php b/php/EE/Runner.php index 154c0b1bd..f0c647b95 100644 --- a/php/EE/Runner.php +++ b/php/EE/Runner.php @@ -785,7 +785,7 @@ public function start() { ( 'create' === $this->arguments[1] ? 'add' : 'remove' ) ); - EE::warning( $deprecation_warn ); + EE::notice( $deprecation_warn ); } // Protect 'cli info' from most of the runtime, diff --git a/php/class-ee.php b/php/class-ee.php index e9dc1b0d3..a4b9cfc4d 100644 --- a/php/class-ee.php +++ b/php/class-ee.php @@ -572,6 +572,17 @@ public static function warning( $message ) { self::$file_logger->warning( $message ); } + /** + * Display notice message prefixed with "Notice: ". + * + * @param string $message Message to write. + * + * @return null + */ + public static function notice( $message ) { + self::$logger->notice( self::error_to_string( $message ) ); + } + /** * Display error message prefixed with "Error: " and exit script. *