Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the bug related to mime_type on ajax request #4

Merged
merged 2 commits into from Feb 17, 2024

Conversation

larodiel
Copy link
Contributor

@larodiel larodiel commented Nov 9, 2023

  • Added the languages pt_BR and es_ES
  • Fixed the bug where the library on AJAX requests was broking because it was expecting a string and the server was returning an array

@yoren yoren self-requested a review November 10, 2023 05:39
Copy link
Member

@yoren yoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @larodiel - please find my feedback from the comment.

Comment on lines 164 to 172
$mime_types = is_array( $vars['post_mime_type'] ) ? $vars['post_mime_type'] : [ $vars['post_mime_type'] ];
$like_clauses = array();

foreach( $mime_types as $mime_type ) {
$mime_type_like = '%' . $wpdb->esc_like( $mime_type ) . '%';
$like_clauses[] = "$wpdb->posts.post_mime_type LIKE '$mime_type_like'";
}

$pieces['where'] .= " AND (" . implode( ' OR ', $like_clauses ) . ")";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the indents here a bit off?

Also, mind if changing $like_clauses[] = "$wpdb->posts.post_mime_type LIKE '$mime_type_like'"; to use $wpdb->prepare()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yoren
prepare has been added and indentation fixed.
Would be great if we had a .editorconfig or prettier file to keep the pattern .prettierrc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I'll do some test and merge if no further issues + do the release to wp.org over the weekend.

@yoren yoren self-requested a review November 14, 2023 10:22
Copy link
Member

@yoren yoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@larodiel Thanks! Can you give me an example that when will the post_mime_type be an array? The default Media Library doesn't seem to have an UI to make it so. I wanted to make it clear in the change log or also add some information in README.

@larodiel
Copy link
Contributor Author

@larodiel Thanks! Can you give me an example that when will the post_mime_type be an array? The default Media Library doesn't seem to have an UI to make it so. I wanted to make it clear in the change log or also add some information in README.

@yoren When the user add an image using the Gutenberg block image and they try to search for an image on the library, the ajax request was returning error 500, because on this section, the mime type is requested using array instead of string

@yoren
Copy link
Member

yoren commented Nov 14, 2023

@larodiel Thanks - that information was very valuable! If you have a wp.org account, feel free to add yourself to the "Contributors" list in README. I'll release 0.8.2 soon

@yoren yoren merged commit cf4feab into 1fixdotio:master Feb 17, 2024
@yoren
Copy link
Member

yoren commented Feb 17, 2024

Hey @larodiel - It's been a while but I finally published the new release today. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants