Skip to content

Commit b24a773

Browse files
committed
Add an error when an unknown option is requested
1 parent eb4bff0 commit b24a773

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/CoreOptions.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,12 @@ public static function getValue( string $name ): string {
434434
$opt_spec = self::optionSpecs()[ $name ];
435435

436436
if ( ! $opt_spec ) {
437-
WsLog::w( 'Attempt to getValue of unknown option $name' );
438-
return '';
437+
WsLog::l(
438+
"Unknown option: $name",
439+
$level = 'error',
440+
$option_lookups = $option_lookups,
441+
);
442+
throw new WP2StaticException( "Unknown option: $name" );
439443
}
440444

441445
$table_name = self::getTableName();

src/WsLog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ public static function l(
7777
self::$debug_logging = CoreOptions::getValue( 'debugLogging' );
7878
}
7979

80-
if ( ! isset( self::$debug_logging )
81-
|| ( ! self::$debug_logging && defined( 'WP_CLI' ) ) ) {
80+
if ( ( ! isset( self::$debug_logging )
81+
|| ! self::$debug_logging ) && defined( 'WP_CLI' ) ) {
8282
$date = current_time( 'c' );
8383
$colorized = \WP_CLI::colorize( "%W[$date] %n$text" );
8484
// --debug will show debug messages even if

0 commit comments

Comments
 (0)