Make WordPress Core

Opened 16 years ago

Closed 14 years ago

Last modified 14 years ago

#13782 closed feature request (maybelater)

query_posts and strict boolean

Reported by: arena Owned by: ryan
Priority: normal Milestone:
Component: Query Version:
Severity: normal Keywords:
Cc: Focuses:

Description

when querying posts, wordpress discards any other filtering such as cat : for example, retrieve post p in category c => "?post=p&cat=c" is converted in "?post=p".

Adding a 'strict' boolean argument like "?post=p&cat=c&strict=1" to avoid any convertion of the query. strict default value would be 0 of course.

what do you think ?

Attachments (1)

#13782.patch​ (1.8 KB ) - added by arena 16 years ago.

Download all attachments as: .zip

Change History (11)

#1 @dd32
16 years ago

  • Component General → Query
  • Milestone 3.0 → Future Release
  • Owner set to ryan

Feature Request combined with no patch leads to Future Release

#2 @filosofo
16 years ago

The underlying issue is that WP parses query values eclectically. To make "strict" really work, you would first have to rewrite the query parsing algorithms into something that actually is strict in the sense of being general and consistent across query arguments. At that point you'd have a new, backwards-incompatible query parser.

"strict" might actually be a good way of transitioning to an improved query parsing engine while stepping around backwards-compatibility issues: those queries that don't specify it would use the old system.

#3 follow-up: @arena
16 years ago

@filosofo,

i attached a sample patch

@arena
16 years ago

#4 in reply to: ↑ 3 @filosofo
16 years ago

Replying to arena:

@filosofo,

i attached a sample patch

What I was trying to get at is that we shouldn't call it "strict" unless it's actually strict in a general, meaningful sense. If you just want an ad hoc solution to the particular problem, better to call it something more specific. Let's reserve "strict" for when we can actually make it strict.

So a more specific ad hoc solution would be, for example, to create a new query var called something like mandatory_cat which if called the given singular post must have.

query_posts(
   array(
      'p' => 123,
      'mandatory_cat' => 456,
   )
);

#5 @arena
16 years ago

strange ?! revision 15239 integrates the sample patch above (that is still a sample)

#6 @filosofo
16 years ago

arena, perhaps you didn't revert your patch?

#7 @arena
16 years ago

@filosofo, hum ! you are right, need some sleep !! ;-)

#8 @arena
14 years ago

  • Resolution → maybelater
  • Status new → closed

#9 @scribu
14 years ago

  • Milestone Future Release

"?post=p&cat=c" doesn't work because ?cat expects a category ID, not a slug.

#10 @scribu
14 years ago

Nevermind, I get that they were placeholders.

Note: See TracTickets for help on using tickets.