Skip to content

Commit 6ef59bc

Browse files
authored
chore(capabilities): drop the unreachable duplicates in denial_reason() (#152)
The function ended with verbatim copies of two branches it had already run. Both conditions are character-identical to the earlier ones, the earlier ones always return, and nothing between them touches $required, $gate, or any state either condition reads — so the copies could never execute. Worth deleting rather than ignoring, because the duplicate tier block is a WORSE version of the one that runs: it omits the saddle_insufficient_scope branch. If it ever became reachable it would send an OAuth-scope-limited agent to raise the site's access level, which is the wrong screen — the exact bug #108 fixed. A stale copy of a corrected code path sitting next to the corrected one is how that comes back. No behaviour change and no new test: unreachable code cannot change behaviour, and the proof nothing moved is capabilities-test.php's existing gate-ordering coverage staying green. 612 tests, 0 lint errors. Closes #151
1 parent dc552e0 commit 6ef59bc

1 file changed

Lines changed: 0 additions & 19 deletions

File tree

includes/class-saddle-capabilities.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -506,25 +506,6 @@ public static function denial_reason( $ability_name ) {
506506
);
507507
}
508508

509-
if ( 'read' !== $required && '' !== $required && self::is_domain_enforced() && ! self::domain_matches_recorded() ) {
510-
return array(
511-
'code' => 'saddle_domain_drift',
512-
'message' => __( 'This site\'s domain changed since write access was granted, and the owner has domain enforcement on — write tools are refused until they re-confirm the access level (Saddle → Permissions). Do not retry; tell the user.', 'saddle' ),
513-
);
514-
}
515-
516-
if ( '' !== $required && ! self::tier_allows( $required ) ) {
517-
return array(
518-
'code' => 'saddle_tier_denied',
519-
'message' => sprintf(
520-
/* translators: 1: required access level, 2: current access level. */
521-
__( 'This tool needs the "%1$s" access level, but this site allows "%2$s". Only the site owner can raise it (Saddle → Permissions). Do not retry — ask the user to change the level if they want this done.', 'saddle' ),
522-
$required,
523-
self::get_tier()
524-
),
525-
);
526-
}
527-
528509
return null;
529510
}
530511

0 commit comments

Comments
 (0)