[wp-trac] [WordPress Trac] #57262: force_ssl_admin can be set to return a string
WordPress Trac
noreply at wordpress.org
Sat Dec 3 04:23:35 UTC 2022
#57262: force_ssl_admin can be set to return a string
-------------------------------------------------+-------------------------
Reporter: pbearne | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests dev- | Focuses:
feedback |
-------------------------------------------------+-------------------------
Changes (by costdev):
* keywords: has-patch has-unit-tests => has-patch has-unit-tests dev-
feedback
Comment:
`force_ssl_admin( $force = null )` is documented to accept `string|bool
$force` and to return `bool`.
[https://github.com/WordPress/wordpress-develop/pull/3719 PR 3719] breaks
BC by hard deprecating the `string` type for `$force`.
IMO, the only "BC break" as such, should be that undocumented return types
are no longer supported.
-----
Currently:
- If no value is passed, it returns the stored value.
- If a value is passed, it updates the stored value, and returns the old
value.
As the function "Determines whether to force SSL used for the
Administration Screens.", it doesn't make sense for it to return anything
other than `bool`, so I'd suggest we don't look at altering documented
return types, and instead focus on fixing the code.
-----
From what I can tell at the moment (I'm on mobile - makes it a little
difficult), this should be sufficient to ensure the function's signature
remains intact, and the return value is of type `bool` as documented:
{{{#!php
<?php
// Change this:
$forced = $force;
// To this:
$forced = (bool) $force;
}}}
Here's some tests: https://3v4l.org/ml1fn
-----
Adding `dev-feedback` to gather thoughts on the preferred approach here.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57262#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list