Automattic / Automattic/jetpack

Pages with id 404 do not obey widget visibility rules

Open
#2,542 6 comments 0 reactions 0 assignees View on GitHub
[Feature] Widget Visibility [Pri] Normal [Status] Stale Bug
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

Repro:
1. Find or contrive to set up a site that has a page with the id 404.
2. Create a widget and update its visibility settings so that it should display on this page.

You'd expect the widget to display, but it doesn't because it's possible also to designate rules for the 404 error page. The code that interprets the rules checks for the major condition of 'page' and the minor of '404', which is satisfied for both the 404 page and the page with the id 404. The logic goes something like this:
1. Is the current major condition we're checking a page condition? (Yes.)
2. Is the minor condition '404'? (Yes for both the error page and the page with id 404.)
3. Is the current page the 404 error page? (Yes for the error page, no for the page with id 404 that you intended to show the widget on.)
4. Don't show the widget on the page with id 404 because it is not the 404 error page.

The proper fix for this is probably to use something other than a numeric value when saving/checking the 404 error page condition, but there may be cases in the wild in which people have defined conditions for the 404 page, and it'd be lousy to break those, so I'm not really sure what the proper fix is if we want to avoid such breakage.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the widget visibility case with a real page whose id is 404 and compare it with the 404 error page. Trace the visibility-rule logic for the page major condition and 404 minor condition; done means the widget follows its configured visibility on both cases without breaking existing saved 404 conditions. The payload names no files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.