#57775 closed defect (bug) (fixed)
wp_create_file_in_uploads Called as Action Hook
Reported by: | Howdy_McGee | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 6.4 | Priority: | normal |
Severity: | trivial | Version: | 2.5 |
Component: | General | Keywords: | has-patch needs-testing has-testing-info |
Focuses: | Cc: |
Description
The wp_create_file_in_uploads hook is labeled as an Action Hook in the docs but is actually called multiple times as a Filter Hook.
As an Action Hook: class-custom-image-header.php
As a Filter Hook: ajax-actions.php, class-custom-image-header.php (and more)
To keep the docs accurate, this do_action
should be switched to an apply_filters
even though, in this case, nothing will be done with the returned value.
Attachments (1)
Change History (13)
#1
@
16 months ago
- Focuses docs removed
- Keywords has-patch added
- Milestone changed from Awaiting Review to 6.4
- Owner set to johnbillion
- Status changed from new to reviewing
#2
follow-up:
↓ 3
@
16 months ago
- Keywords needs-refresh 2nd-opinion added
Notes:
- This hook is called as a filter five times and an action twice.
- Its developer reference page documents it as an action.
- There are very few plugins that actually hook into this filter/action, although quite a few that call the hook either as an action or a filter (having mostly copied and pasted from core by the looks of things).
- I also think this should be converted to always be a filter. Converting it to always be an action will break existing filters. I'd like a second opinion though.
- The patch needs to be updated to account for both places in core where this is called as an action:
#3
in reply to:
↑ 2
@
16 months ago
- Version changed from 6.1.1 to 2.5
Replying to johnbillion:
I also think this should be converted to always be a filter. Converting it to always be an action will break existing filters. I'd like a second opinion though.
That makes sense to me too.
Introduced in [6551] / #5418, setting the version accordingly.
#4
@
15 months ago
If we change the existing action hook to a filter hook as like this https://core.trac.wordpress.org/attachment/ticket/57775/57775.diff , then what's the point of using filter hooks if we don't use the modified $file
variable?
This ticket was mentioned in PR #5408 on WordPress/wordpress-develop by @nicolefurlan.
14 months ago
#5
- Keywords needs-refresh removed
Changes instances of wp_create_file_in_uploads
from action hooks to filter hooks.
Trac ticket: https://core.trac.wordpress.org/ticket/57775
#6
follow-up:
↓ 11
@
14 months ago
- Keywords needs-testing needs-testing-info added
I just added a PR that changes both instances of wp_create_file_in_uploads
from action hooks to filter hooks.
I also created a docs issue (https://github.com/WordPress/Documentation-Issue-Tracker/issues/1139) so that https://developer.wordpress.org/reference/hooks/wp_create_file_in_uploads/ can get updated to match this change. Please do let me know if that was the incorrect thing to do. I'd love to know how we can coordinate with the docs team on timing to make sure the code and documentation changes happen at the same time.
#7
@
14 months ago
- Keywords has-testing-info added; needs-testing-info removed
Testing Instructions
These steps define how to test the feature or enhancement, and indicates the expected behavior or results.
Steps to Test
- Install and activate theme Twenty Fifteen or older.
- Upload a custom header image on
Appearance > Header
.- To ensure we're encountering the code we changed, the uploaded image should be the exact dimensions (954x1300) e.g. https://i0.wp.com/www.ciderschool.com/wp-content/uploads/2015/01/cropped-apple_closeup-1024x683.jpg?fit=954%2C1300&ssl=1
- Upload an custom background image on
Appearance > Background
.
Expected Results
Lists each expected result or behavior, i.e. what should happen when running the test(s):
- ✅ Uploading a custom header image on
Appearance > Header
continues to work as expected (the selected image is uploaded to the Media Library and displays properly on the frontend) - ✅ Uploading a custom background image on
Appearance > Background
continues to work as expected (the selected image is uploaded to the Media Library and displays properly on the frontend)
Supplemental Artifacts
#8
@
14 months ago
- Keywords 2nd-opinion removed
Removing 2nd-opinion
since @SergeyBiryukov weighed in an provided an opinion.
This PR just needs testing. It would be great to get this wrapped up in 6.4.
@SergeyBiryukov commented on PR #5408:
14 months ago
#10
Thanks for the PR! Merged in r56929.
#11
in reply to:
↑ 6
@
14 months ago
Replying to nicolefurlan:
I also created a docs issue (https://github.com/WordPress/Documentation-Issue-Tracker/issues/1139) so that https://developer.wordpress.org/reference/hooks/wp_create_file_in_uploads/ can get updated to match this change. Please do let me know if that was the incorrect thing to do. I'd love to know how we can coordinate with the docs team on timing to make sure the code and documentation changes happen at the same time.
Thanks! As far as I can tell, the docs issue is not necessary here, the documentation will be updated automatically as soon as 6.4 is released and the DevHub code reference parser is run as part of the post-release tasks.
Action Hook switched to Filter Hook.