File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -286,6 +286,45 @@ Feature: Manage WordPress options
286286 on
287287 """
288288
289+ Scenario: Report an error when the autoload value cannot be stored
290+ Given a WP install
291+ And a wp-content/mu-plugins/fail-autoload-update.php file:
292+ """
293+ <?php
294+ add_filter(
295+ 'query',
296+ static function ( $query ) {
297+ if ( false !== strpos( $query, 'SET `autoload` =' ) && false !== strpos( $query, "`option_name` = 'hello'" ) ) {
298+ return 'UPDATE wp_cli_missing_table SET autoload = 1';
299+ }
300+ return $query;
301+ }
302+ );
303+ """
304+ And I run `wp option add hello world --autoload=on`
305+
306+ When I try `wp option update hello world --autoload=off`
307+ Then STDERR should contain:
308+ """
309+ Error: Could not update autoload value for 'hello' option.
310+ """
311+ And STDOUT should not contain:
312+ """
313+ Success:
314+ """
315+ And the return code should be 1
316+
317+ When I try `wp option set-autoload hello off`
318+ Then STDERR should contain:
319+ """
320+ Error: Could not update autoload value for 'hello' option.
321+ """
322+ And STDOUT should not contain:
323+ """
324+ Success:
325+ """
326+ And the return code should be 1
327+
289328 @require-wp-4.2
290329 @less-than-wp-6.6
291330 Scenario: Managed autoloaded options
Original file line number Diff line number Diff line change @@ -564,12 +564,16 @@ public function set_autoload( $args ) {
564564 return ;
565565 }
566566
567- $ wpdb ->update (
567+ $ updated = $ wpdb ->update (
568568 $ wpdb ->options ,
569569 array ( 'autoload ' => $ autoload ),
570570 array ( 'option_name ' => $ option )
571571 );
572572
573+ if ( false === $ updated ) {
574+ WP_CLI ::error ( "Could not update autoload value for ' {$ option }' option. " );
575+ }
576+
573577 // Recreate cache refreshing from update_option().
574578 $ notoptions = wp_cache_get ( 'notoptions ' , 'options ' );
575579
You can’t perform that action at this time.
0 commit comments