Skip to content

Commit dcd149a

Browse files
Code Quality: Remove an always-true check when scheduling a Customizer changeset.
In `WP_Customize_Manager::save_changeset_post()`, a changeset with a `date_gmt` that is not in the future is rejected with a `not_future_date` error. The check that follows can therefore only be reached with `$is_future_dated` set to `true`, so the `'future' === $args['status'] || $is_future_dated` part of its condition always evaluates to `true`. The condition is reduced to the `is_theme_active()` check that actually decides it. There is no change in behavior. This resolves the only error in the `booleanOr.rightAlwaysTrue` PHPStan baseline, which is deleted. Follow-up to r39409. Props Soean, mukesh27. See #65817. git-svn-id: https://develop.svn.wordpress.org/trunk@64082 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 66d4890 commit dcd149a

3 files changed

Lines changed: 1 addition & 27 deletions

File tree

‎phpstan.neon.dist‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ includes:
3434
- tests/phpstan/baselines/booleanNot.alwaysTrue.neon
3535
- tests/phpstan/baselines/booleanOr.alwaysFalse.neon
3636
- tests/phpstan/baselines/booleanOr.alwaysTrue.neon
37-
- tests/phpstan/baselines/booleanOr.rightAlwaysTrue.neon
3837
- tests/phpstan/baselines/catch.neverThrown.neon
3938
- tests/phpstan/baselines/class.notFound.neon
4039
- tests/phpstan/baselines/deadCode.unreachable.neon

‎src/wp-includes/class-wp-customize-manager.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2687,7 +2687,7 @@ public function save_changeset_post( $args = array() ) {
26872687
return new WP_Error( 'not_future_date', __( 'You must supply a future date to schedule.' ) ); // Only future dates are allowed.
26882688
}
26892689

2690-
if ( ! $this->is_theme_active() && ( 'future' === $args['status'] || $is_future_dated ) ) {
2690+
if ( ! $this->is_theme_active() ) {
26912691
return new WP_Error( 'cannot_schedule_theme_switches' ); // This should be allowed in the future, when theme is a regular setting.
26922692
}
26932693
$will_remain_auto_draft = ( ! $args['status'] && ( ! $changeset_post_id || 'auto-draft' === get_post_status( $changeset_post_id ) ) );

‎tests/phpstan/baselines/booleanOr.rightAlwaysTrue.neon‎

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)