[wp-trac] [WordPress Trac] #37893: Implementation of is_registered_sidebar() doesn't match its documented signature
WordPress Trac
noreply at wordpress.org
Tue May 23 09:11:15 UTC 2017
#37893: Implementation of is_registered_sidebar() doesn't match its documented
signature
--------------------------+------------------------------
Reporter: mdgl | Owner: welcher
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version: 4.4
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
--------------------------+------------------------------
Changes (by mdgl):
* keywords: needs-patch reporter-feedback => needs-patch
Comment:
It's not clear what question is being asked of the reporter here. The
"bug" was raised to try and make the widget functions a bit more
consistent and correspond to the documentation. But this may not be
possible due to backwards compatibility concerns. From a development
perspective, however I think there are two questions:
'''Should global `wp_registered_sidebars` be part of the public interface
of the widgets "module"?'''
This ticket was really a response to #24878 which added a new function to
try and hide the global `wp_registered_sidebars` from the rest of the
codebase. At the same time, a few references to the global were updated
to use the new function, but unfortunately this was left incomplete and
parts of the admin tool, customizer and unit tests were not updated. The
principles of good design would suggest we try and eliminate external
dependencies on global variables such as this, but full backwards
compatibility may prevent us from doing so.
'''Should the `id` referencing each widget be of mixed `int`/`string` type
or just `string`?'''
The codebase is inconsistent as to the treatment of the `id` parameter for
widgets. The code for many widget functions along with the unit tests all
assume that the `id` can be either `int` or `string`, although this is
often not matched by the accompanying documentation. Functions
`dynamic_sidebar` and `is_active_sidebar` on the other hand purport to
allow either `int` or `string` but in practice these are not compatible
with the other functions and if an `int` is passed, this is converted
immediately into a `string` of the form "sidebar-$id". In effect, these
two functions only allow the widget `id` to be a `string`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37893#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list