Opened 2 years ago
Last modified 3 months ago
#43658 assigned defect (bug)
Media attachment filter drop-down mime types in grid mode is not properly filtered by available mime types
Reported by: | itzmekhokan | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 4.9.4 |
Component: | Media | Keywords: | has-screenshots |
Focuses: | Cc: |
Description
In Gird mode media attachment filter is not properly filtered by available mime types, it shows all mime types by default via -
get_post_mime_types()
But in List mode its already filtered by checking
if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) { continue; }
Attachments (7)
Change History (31)
#3
@
2 years ago
- Keywords needs-testing needs-unit-tests added
- Milestone changed from Awaiting Review to 5.0
- Owner set to adamsilverstein
- Status changed from new to assigned
@itzmekhokan thanks for the bug report and patch!
Overall your patch looks good and I see the issue you are trying to resolve. Can you please provide the code snippet you are using to alter the dropdown for testing? Also, it would be nice to add a a unit test confirming the filter works as expected and changes the return from wp_enqueue_media
.
One small coding standards correction, this line is missing some whitespace before/after brackets: unset($mimeTypes[$mime_type]);
#4
@
2 years ago
I have tested the flow thoroughly with the 43658.1.patch and it is working properly, as expected and changes the return from wp_enqueue_media
.
However, I faced an issue with unit testing. Can you please guide me with the flow, i need to follow for the same.
Looking for your co-operation dearly.
#6
@
15 months ago
- Milestone changed from 5.1 to 5.2
This one needs some more attention before its ready. Punting to 5.2.
#7
@
13 months ago
43658.diff includes unit tests that verify the correct mime types are available to the grid. these tests fail before the patch and succeed after it.
@itzmekhokan can you take a look at what I did for the unit tests - let me know if you have any questions - and also verify this resolves the issue you were seeing.
#8
@
13 months ago
Noting in travis I'm seeing phpcs errors that can't be fixed automatically: https://travis-ci.org/adamsilverstein/wordpress-develop-fork/jobs/500433986. I'm assuming I need to fix these before committing.
This ticket was mentioned in Slack in #core-committers by adamsilverstein. View the logs.
13 months ago
#10
@
13 months ago
Travis was failing (https://travis-ci.org/adamsilverstein/wordpress-develop-fork/jobs/500433986) because the linting errors in wp-includes/media.php
could not be fixed automatically.
I ran phpcs --standard=phpcs.xml.dist src/wp-includes/media.php
and manually addressed all errors. Errors fixed included "Assignments must be the first block of code on a line" and "Use Yoda Condition checks, you must" as well as "Use placeholders and $wpdb->prepare(); found $sql"
43658.3.diff includes code fixes in response to phpcs
travis build started: https://travis-ci.org/adamsilverstein/wordpress-develop-fork/builds/501627830
#12
@
13 months ago
- Keywords commit added
43658.diff is ready: not going to worry about the phpcs errors for unchanged code.
#14
@
11 months ago
- Resolution fixed deleted
- Status changed from closed to reopened
It seems the use of get_available_post_mime_types
here is potentially an issue for sites with many posts - in testing we saw the query scan the whole posts table and for sites with > 1 million rows, that's measured in seconds - the query here could possibly benefit from some caching.
SELECT DISTINCT post_mime_type FROM wp_posts WHERE post_type = 'attachment'
I reopened #44675 because it appeared to be related, but it's likely this ticket is the nexus of that change, can it be reconsidered or tested for larger sites before including in 5.2?
This ticket was mentioned in Slack in #core by pento. View the logs.
11 months ago
#17
@
11 months ago
+1 on reverting for now and adding this after the way get_available_post_mime_types()
works is fixed/improved.
#18
@
11 months ago
- Owner changed from adamsilverstein to pento
- Status changed from reopened to assigned
Grid view attachments filters drop-down