Make WordPress Core

Opened 3 weeks ago

Closed 7 days ago

#65658 closed defect (bug) (fixed)

The On This Day Widget should handle untitled posts more nicely

Reported by: alshakero Owned by: joedolson
Priority: normal Milestone: 7.1
Component: Widgets Version: trunk
Severity: minor Keywords: has-patch has-unit-tests has-test-info has-screenshots commit
Cc: Focuses: administration

Description

All details can be seen here: https://wordpress.org/support/topic/on-this-day-widget/

To summarize, when a post has no title, the widget should show a few words from the post's body instead of "(no title)".

Attachments (9)

65658-trunk-before.png (407.4 KB ) - added by softglaze 3 weeks ago.
65658-pr-after.png (412.2 KB ) - added by softglaze 3 weeks ago.
65658-pr-secret-leak-check.png (1.1 MB ) - added by softglaze 3 weeks ago.
before-the -patch.png (538.3 KB ) - added by iamraju 12 days ago.
before applying the patch
after-applying-the-patch.png (584.8 KB ) - added by iamraju 12 days ago.
After applying the patch
after-applying-the-patch-with-password-protected-post.png (571.2 KB ) - added by iamraju 12 days ago.
After applying the patch with password protected untitled post
image.png (830.3 KB ) - added by mirmpro 12 days ago.
before-patch.png (27.0 KB ) - added by shailu25 8 days ago.
Before Patch
after-patch.png (27.3 KB ) - added by shailu25 8 days ago.
After Patch

Change History (26)

This ticket was mentioned in PR #12581 on WordPress/wordpress-develop by @alshakero.


3 weeks ago
#1

  • Keywords has-patch has-unit-tests added; needs-patch removed

## Summary

Trac: https://core.trac.wordpress.org/ticket/65658
See: https://wordpress.org/support/topic/on-this-day-widget/

This adds the same untitled-post fallback used in the posts list table to the On This Day dashboard widget. When a matching post has no title, the widget now appends a trimmed excerpt after (no title) when the current user can read the post and the post is not password protected.

The change keeps protected post excerpts hidden and adds PHPUnit coverage for the trimmed excerpt and password-protected cases.

## Testing

  • Checkout this PR locally and run npm run env:start, then npm run env:install.
  • Go to Dashboard (admin:password), you should see the widget.
  • Insepect its empty state.
  • Import this file to create backdated posts: filexml
  • Use the widget.
  • Update the post to get rid of the title.
  • It should render (no title) 15 word excerpt.

@bph commented on PR #12581:


3 weeks ago
#2

Thank you @alshakero for jumping right on it!

#3 @joedolson
3 weeks ago

  • Milestone7.1
  • Owner set to joedolson
  • Status newaccepted
  • Type enhancementdefect (bug)
  • Versiontrunk

I'm switching this to a bug, on the grounds that it's an inconsistency in how posts are represented between these two cases, and the content will be significantly more relevant in cases where it applies.

#4 @softglaze
3 weeks ago

  • Keywords has-test-info has-screenshots added

Test report for PR 12581 against current trunk (7.1-beta3-src).

Environment: Windows host, wordpress-develop Docker environment, Chrome. Test data created via WP-CLI: a titled post and an untitled post backdated to today's date in 2024, plus a password-protected untitled post backdated to 2025.

Unit tests:

  • --filter OnThisDay: OK (15 tests, 36 assertions) — includes the PR's new coverage for the trimmed-excerpt and password-protected cases.
  • --filter dashboard: OK (4 tests, 7 assertions). PHPUnit 9.6.35, no failures or errors.

Manual verification (trunk → PR 12581):

Case Trunk With PR 12581
Untitled post bare "(no title)" "(no title)" + trimmed ~15-word excerpt, matching the posts list table ✅
Password-protected untitled post bare "(no title)" still bare "(no title)" — no excerpt ✅
Titled post normal unchanged ✅


Password-protection guard, verified at output level: searched the rendered dashboard HTML via view-source — the protected post's content appears zero times anywhere in the page, so the guard holds in real rendering, not only in the unit tests.


Result: the fallback works as described and the protection guard holds. Tests well.

One observation for consideration (not a blocker): the Activity → Recently Published widget on the same dashboard still shows bare "(no title)" for the same untitled posts. If the rationale in comment:3 is consistency of untitled-post representation, Activity may be worth the same treatment in a follow-up.

This ticket was mentioned in Slack in #core-test by huzaifaalmesbah. View the logs.


3 weeks ago

@alshakero commented on PR #12581:


2 weeks ago
#6

Addressed all!

@alshakero commented on PR #12581:


13 days ago
#7

Hi @peterwilsoncc! Can we have this merged? I think it's good to go.

#8 @iamraju
12 days ago

Test Report

Patch tested: https://github.com/WordPress/wordpress-develop/pull/12581

Environment

  • WordPress: 7.1-beta3-20260727.223424
  • Subdirectory: No
  • PHP: 8.3.32
  • Server: PHP.wasm
  • Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.51.0)
  • Browser: Chrome 150.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.5
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.3.0

Steps taken

  1. Opened the WordPress Playground preview for PR #12581 and logged in to the admin dashboard.
  2. Created a new post with content and set its publication date to match the current month and day so it would appear in the On This Day dashboard widget.
  3. Removed the post title and published the post.
  4. Verified that, before applying the patch, the widget displayed only "(no title)" for the untitled post.
  5. Repeated the same steps with the patch applied.
  6. Confirmed that the widget displayed "(no title)" followed by a trimmed excerpt of the post content.
  7. Created another untitled post with password protection enabled and confirmed that only "(no title)" was displayed, with no excerpt exposed.
  8. Verified that posts with titles continued to display normally.

Result: ✅ Patch is solving the problem.

Expected result

  • Untitled posts in the On This Day dashboard widget should display "(no title)" followed by a trimmed excerpt when the current user can read the post and the post is not password protected.
  • Password-protected untitled posts should continue to display only "(no title)", without exposing any excerpt.
  • Posts with titles should remain unchanged.

Additional Notes

Comparison of behavior before and after applying the patch:

  • Untitled post
  • Trunk: Displays only "(no title)".
  • With PR #12581: Displays "(no title)" followed by a trimmed (~15-word) excerpt, matching the behavior of the Posts list table. ✅
  • Password-protected untitled post
  • Trunk: Displays only "(no title)".
  • With PR #12581: Continues to display only "(no title)", with no excerpt exposed. ✅
  • Titled post
  • Trunk: Displays normally.
  • With PR #12581: No change in behavior. ✅

No regressions or unexpected behavior were observed during testing.

Screenshots/Screencast with results

  • Screenshot before applying the patch.
  • Screenshot after applying the patch.
  • Screenshot of the password-protected untitled post (optional).

Support Content

  1. WordPress Playground preview for PR #12581.
  2. Before/after screenshots demonstrating the fix.

@iamraju
12 days ago

before applying the patch

@iamraju
12 days ago

After applying the patch

@iamraju
12 days ago

After applying the patch with password protected untitled post

#9 @mirmpro
12 days ago

Test Report

Patch tested: https://patch-diff.githubusercontent.com/raw/WordPress/wordpress-develop/pull/12581.diff

Environment

  • WordPress: 7.1-beta3-62828-src
  • Subdirectory: No
  • PHP: 8.3.31
  • Server: nginx/1.31.2
  • Database: mysqli (Server: 9.7.2 / Client: mysqlnd 8.3.31)
  • Browser: Chrome 150.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.5
  • MU Plugins: None activated
  • Plugins:
    • WordPress Importer 0.9.5
    • Test Reports 1.3.0

Steps taken

  1. Launched the WordPress environment via both Playground and Docker and verified the "On This Day" dashboard widget.
  2. Imported backdated test posts using the XML file.
  3. Edited a post to remove its title and returned to the dashboard to confirm it correctly renders as (no title) followed by the 15-word excerpt fallback.
  4. Created an untitled post with password protection enabled and verified that only (no title) is displayed with no excerpt exposed.
  • ✅ Patch is solving the problem

Expected result

  • When a matching post in the "On This Day" widget has no title, it should display a (no title) fallback followed by a trimmed excerpt (for readable, non-password-protected posts), matching the posts list table behavior.

Additional Notes

  • Successfully tested and verified the patch.

Screenshots/Screencast with results

  • Yes

Support Content

  • Patch URL: https://patch-diff.githubusercontent.com/raw/WordPress/wordpress-develop/pull/12581.diff

@mirmpro
12 days ago

#10 @nazmulasif
12 days ago

✅ After pulling the PR the on This Day widget is working as expected with protected posts as well.

Last edited 12 days ago by nazmulasif (previous) (diff)

@alshakero commented on PR #12581:


10 days ago
#11

@joedolson @t-hamano thanks for the reviews! Addressed.

@annezazu commented on PR #12581:


8 days ago
#12

Thanks so much for jumping right on this. I just managed to test this today and opened a trac issue prematurely only to find you all are all over it. It's looking great to me, UI wise.

#13 @joedolson
8 days ago

#65784 was marked as a duplicate.

#14 @shailu25
8 days ago

Test Report

This Report Validates that the indicated patch address the issue.✅

Patch Tested: https://github.com/WordPress/wordpress-develop/pull/12581

Environment:

WordPress - 7.1-beta4-20260731.072215
OS - Windows
Browser - Chrome
Theme: Twenty Twenty Five
PHP - 8.2
Plugin - None

Actual Results:

  • Issue Resolved with Patch ✅

Additional Notes

  • With this PR, the issue is resolved. The only remaining item is to address the review feedback by adding the two requested test cases.

Supplemental Artifacts

  • Attached

@shailu25
8 days ago

Before Patch

@shailu25
8 days ago

After Patch

@alshakero commented on PR #12581:


8 days ago
#15

Hi @t-hamano! Addressed. Thank you so much for the review.

#16 @joedolson
7 days ago

  • Keywords commit added

#17 @joedolson
7 days ago

  • Resolutionfixed
  • Status acceptedclosed

In 62968:

Widgets: Show post excerpts in On This Day widget if no title.

Match the behavior of posts in list tables by showing a short excerpt in the On This Day widget when the post does not have a saved title.

Developed in https://github.com/WordPress/wordpress-develop/pull/12581

Props alshakero, softglaze, iamraju, mirmpro, shailu25, bph, nazmulasif, wildworks, annezazu, mukesh27, peterwilsoncc, joedolson.
Fixes #65658.

Note: See TracTickets for help on using tickets.