Make WordPress Core

Opened 7 years ago

Closed 4 years ago

#43787 closed defect (bug) (invalid)

sql error in wp_get_post_terms

Reported by: d1sabled's profile d1sabled Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: close reporter-feedback
Focuses: Cc:

Description

hi guys,

i create new plugin, and when i try to fetch all custom taxonomies of the post, i give an error :

my code:

 [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM wp_terms AS t  INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id ' at line 1]

SELECT   FROM wp_terms AS t  INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('olympic_games_tax') AND tr.object_id IN (15950) ORDER BY t.name ASC 
<?php
$term_list = wp_get_post_terms(get_the_ID(), 'olympic_games_tax', array("fields" => "slug"));

Have a nice day.

Change History (3)

#1 follow-up: @SergeyBiryukov
7 years ago

  • Component changed from General to Taxonomy
  • Keywords close reporter-feedback added

Hi @d1sabled, welcome to WordPress Trac! Thanks for the report.

slug is not a supported value for the fields argument, try id=>slug instead.

#2 in reply to: ↑ 1 @d1sabled
7 years ago

Hi @SergeyBiryukov ,

Yes, I know, but I don't think it's okay to appear sql error on incorect param.

Replying to SergeyBiryukov:

Hi @d1sabled, welcome to WordPress Trac! Thanks for the report.

slug is not a supported value for the fields argument, try id=>slug instead.

#3 @hellofromTonya
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hello @d1sabled,

I don't think it's okay to appear sql error on incorect param.

The error exists to alert you that there's a syntax problem. Else, it would silently fail with potentially unexpected behavior(s).

I'm closing this ticket as it is marked for close 3 years ago. However, if this is still an issue for you, please provide feedback.

Note: See TracTickets for help on using tickets.