#62913 closed defect (bug) (fixed)
Prevent empty author links in list tables
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | has-patch has-testing-info commit |
Focuses: | accessibility, administration | Cc: |
Description (last modified by )
/wp-admin/upload.php?mode=list
In some cases when there is no image author for whatever reason (unrelated), there is an empty "a" element, which causes unexpected behavior in e.g. keyboard navigation or for accessibility tools
<td class="author column-author" data-colname="Author"><a href="upload.php?author"></a></td>
In that case the "a" should not be output either?
Attachments (3)
Change History (22)
#1
@
6 weeks ago
- Component changed from Upload to Administration
- Description modified (diff)
- Focuses accessibility administration added
- Keywords needs-patch added
- Summary changed from "a" without text in uploads to Prevent empty author links in list tables
This ticket was mentioned in PR #8271 on WordPress/wordpress-develop by @snehapatil02.
6 weeks ago
#2
- Keywords has-patch has-unit-tests added; needs-patch removed
Trac ticket: https://core.trac.wordpress.org/ticket/62913
## Description
This PR fixes the issue where empty author links appear in the media list table when no author is assigned. Currently, an empty <a>
element is rendered which causes issues with keyboard navigation and accessibility tools.
## Changes proposed in this Pull Request:
- Added empty author check before rendering author links
- Added fallback display with em dash (—) for visual indication
- Added screen reader text "(no author)" for better accessibility
- Added unit tests to verify both empty and valid author scenarios
- Maintains consistency with how empty values are handled in other columns
This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.
5 weeks ago
#4
@
5 weeks ago
- Milestone changed from Awaiting Review to 6.8
- Owner set to joedolson
- Status changed from new to accepted
#5
@
5 weeks ago
This is good, and I think it's generally ready to go - but if we're going to do it for media tables, we should also extend the same logic to the other list tables, which all have the same issue if there's no author string returned.
It may be a rare circumstance to occur, but it certainly can occur. Given that get_the_author()
returns an empty string if there's no valid author object and is filterable, the use case is reasonable in all the similar contexts.
@snehapatil02 If you can extend your PR to cover the other list tables, I think this will be in good shape.
This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.
2 weeks ago
This ticket was mentioned in PR #8488 on WordPress/wordpress-develop by @faisal03.
10 days ago
#7
Trac ticket: https://core.trac.wordpress.org/ticket/62913
## Description:
This PR addresses an issue in the Posts List Table where posts without an assigned author display an empty author column. A similar fix is already applied to the Media List Table (https://github.com/WordPress/wordpress-develop/pull/8271), but the issue also affects other list tables.
Changes Made
- Added a fallback text (— no author) when
get_the_author()
returns an empty string. - Ensured get_the_author_meta( 'ID' ) is only used when
get_the_author()
is not empty, preventing invalid author links. - Mirrors the approach taken in the Media List Table fix for consistency.
## Testing Instructions
- Create a post and assign it an author.
- Delete the author or change the post’s author field to an invalid value in the database.
- Visit the Posts List Table.
- The author column should now show — no author instead of being blank.
This aligns with feedback from @joedolson on https://core.trac.wordpress.org/ticket/62913#comment:5, where he suggested extending the fix to all list tables, not just the Media List Table.
@faisal03 commented on PR #8488:
10 days ago
#8
## Testing Instructions
- Log in to the WordPress admin panel.
- Navigate to Posts → Add New and create a new post.
- Assign an existing user as the post’s author.
- Publish the post.
- Go to Posts → All Posts.
- Verify that the Author column displays the correct author name.
- Click on the author name and ensure it links to the correct author archive.
- Create a new post and assign it to a test user.
- Navigate to Users → All Users and delete the test user.
- Choose the option that removes the user but keeps their posts.
- Go to Posts → All Posts.
- Verify that the Author column shows — no author instead of being empty.
#9
@
10 days ago
Test Report
Patch Tested: https://github.com/WordPress/wordpress-develop/pull/8488
Environment:
WordPress - 6.8-beta1
OS - Linux
Browser - Chrome
Theme: Twenty Twenty-Five (1.1)
PHP - 8.1.23
Active Plugin: None
Actual Results:
Issues resolved with this patch
Screenshot:
Added Attachment
#10
@
10 days ago
Test Report
PR tested: https://github.com/WordPress/wordpress-develop/pull/8488
Test Environment [Playground]
- WordPress Version: 6.8beta1
- OS: macOS
- Browser Google Chrome
- WordPress Active Theme: Twenty Twenty-Five
- Active Plugin: None
- PHP version: 7.4.31-dev
- Database Client Version: 3.40.1
- Database Server Version: 5.5
Observed Test Results:-
- After deleting the specific author, the author section of related content is not empty and the reference gets changed to the particular user to which we have specified while deleting the particular WP site user.
Reference Screen Recording: https://drive.google.com/file/d/1QIkwtKqU3Ie_4n_DRawRaErilq1vlltr/view?usp=sharing
@sumitbagthariya16 commented on PR #8488:
10 days ago
#11
QA Test Report
---
I tested this PR using the following query to reset the author:
UPDATE wp_posts SET post_author = 0 WHERE post_type = 'post' LIMIT 1;
After running the query and removing the author from the post, I noticed that a dash (-) sign appears in place of the author name.
Testing Environment
<Details>
- WordPress: WordPress 6.8-beta1
- PHP: 8.2.
- Web Server: Nginx 1.20.2
- Browser: Chrome
- OS: macOS 15.2
</Details>
#13
@
9 days ago
Test Report
Patch Tested: https://github.com/WordPress/wordpress-develop/pull/8488
Environment:
WordPress - 6.8-beta2
OS - Windows
Browser - Firefox
Theme: Twenty Twenty Five
PHP - 8.2.12
Active Plugin: Beta Tester
Actual Results:
- Issue Resolved With Patch.✅
Screenshots:
- Added Attachment
This ticket was mentioned in PR #8523 on WordPress/wordpress-develop by @sabernhardt.
4 days ago
#14
Combines list table changes from pull requests by snehapatil02 and faisal03 (but removes the new unit tests, which were failing).
Both those PRs
- Added
esc_html()
for author display names when they are known and linked. - Added fallback of a visible em dash and the visually hidden "(no author)" text when the post author's name is unknown.
Additional changes in this PR:
- Consistently uses the existing '(no author)' text string, which is already translated.
- Updates the
since
notes to reflect that the author's name is _unknown_, as the documentation inget_the_author()
says.
#15
@
4 days ago
- Keywords has-unit-tests removed
I was unable to fix the test_column_author_with_valid_author()
unit tests, so I removed the tests from the combined PR. If someone else can solve that, the unit tests could be added later on another ticket.
#16
@
4 days ago
Yeah, I couldn't solve it either. I feel like it must have something to do with a cache, because I tested the generated $post
array and it definitely has an author that matches.
I think that this is fine to go in without the tests; they are nice thing, but ultimately this isn't a behavior that crucially requires testing, in my opinion.
Will test the updated PR and, most likely, commit.
#17
@
4 days ago
- Keywords commit added
Code looks good, tests well. The only change from the above screenshots is the consistent usage of the (no author)
text string; I'm not going to generate new screenshots for that.
Can't help but feel that we all spent way more time on those tests than was really justified, but ah well!
@mukesh27 commented on PR #8523:
4 days ago
#19
Committed at https://core.trac.wordpress.org/changeset/60032
I'm curious how an attachment would have no author, but both
wp_prepare_attachment_for_js()
andattachment_submitbox_metadata()
have a "(no author)" text string for that possibility.A quick way to reproduce an empty link in the list table would be to add a filter:
if ( ! empty( get_the_author() ) ) { }
could wrap the code incolumn_author()
methods:printf()
function in media list tables$args
and theecho
line in general post tablesThe methods could also have an
else
condition to print "(no author)" instead of an empty cell, either as visible text or by showing an em dash (as it does for posts with no comments or no tags):