[3.0] Stop drawing an empty tab menu with an unresolved label - #9407
Conversation
Admin and moderation pages whose menu has no title of its own drew a mobile
tab menu containing nothing, labelled with the literal text "{label} Menu".
The block is guarded on Utils::$context['tabs'] but draws
$tab_context['tabs']. Those are not the same list.
Utils::$context['tabs'] is set as a side effect of drawing the menu itself,
from the selected area's subsections, while $tab_context['tabs'] is only
assembled from it inside the "does this menu have a title" branch above. On a
page with subsections but no tab title - Scheduled Tasks, for one - the first
is full and the second was never built, so the guard passed and the loop had
nothing to iterate.
The label came out raw for the same reason: $tab_context['title'] was never
set, and Localization\MessageFormatter drops non-scalar arguments before
formatting, so a null one leaves its placeholder in the output rather than
resolving to an empty string.
The guard now names the list that gets drawn, and the label falls back to an
empty string. Pages that do have tabs are untouched: Manage Members, Features
and Options and Reported Members all still get their menus.
Signed-off-by: Mathias Papenbrock <mathiaspapealbert@hotmail.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
|
Pushed a second commit. Sweeping the admin area with the first commit applied turned up an An unlabelled tab cannot be drawn, so it should not count towards there being anything to draw either. Filtering first, then guarding on the result, handles both: pages with real tabs are unaffected, Verified on |
An area with no subsections of its own leaves $tab_context['tabs'] entries unlabelled, because the loop that fills labels in only walks the areas the menu knows about. Drawing one is an undefined key notice and an empty link, so filter them out first, the way the areas above already are. Filtering before the guard keeps the wrapper from being drawn for nothing. Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
de51d24 to
4d2a93a
Compare
Description
Admin and moderation pages whose menu has no title of its own drew a mobile tab menu containing nothing, labelled with the literal text
{label} Menu. Straight off Admin → Scheduled Tasks:Two lists with the same name
The block is guarded on
Utils::$context['tabs']but draws$tab_context['tabs']:They are not the same list.
Utils::$context['tabs']is set as a side effect of drawing the menu itself, from whichever area is selected:$tab_context['tabs']is only assembled from it inside theif (!empty($tab_context['title']))branch further up. So on a page that has subsections but no tab title, the first is full and the second was never built — the guard passes, the loop finds nothing.And why the label stayed raw
$tab_context['title']was never set either, so the call passes['label' => null].Localization\MessageFormatter::formatMessage()filters its arguments before handing them over:is_scalar(null)is false, so the argument is dropped, and ICU leaves an unmatched placeholder in the output rather than substituting an empty string. Reproduced directly —['label' => null]through intl gives" Menu", but with the argument filtered out it gives"{label} Menu".The guard now names the list that actually gets drawn, and the label falls back to
''so the same thing cannot happen if a menu ever gets tabs without a title.Checked
Four pages on the running forum.
{label}no longer appears anywhere, Scheduled Tasks draws no#adm_submenusat all, and the pages that do have tabs are untouched:Found by sweeping every rendered page of a stock forum for unsubstituted
{placeholders}. This is one of the three the sweep turned up.GenericMenu.template.phpis also touched by #9392, which makes this element anavlandmark; the two do not overlap.Issues References (Fixes|Related|Closes)
Related to #7933