Make WordPress Core

Opened 20 years ago

Closed 18 years ago

#1368 closed enhancement (fixed)

Should apply "posts_where" filter in get_archives

Reported by: anonymousbugger's profile anonymousbugger Owned by: westi's profile westi
Milestone: 2.2 Priority: normal
Severity: normal Version: 1.5.1
Component: Administration Keywords: has-patch
Focuses: Cc:

Description

There is currently no hook for plugins wishing to modify the SQL queries for archives (i.e. like posts_where or post_join)

Attachments (5)

template_functions_general_1.5.1.2_mp001_hookup.patch (3.4 KB) - added by pejve 20 years ago.
template_functions_general_1.5.1.2_mp001_hookup2.patch (3.4 KB) - added by pejve 20 years ago.
1368.diff (3.8 KB) - added by westi 18 years ago.
New filters
1368a.diff (3.9 KB) - added by westi 18 years ago.
Fixed patch
test_plugin.php (454 bytes) - added by westi 18 years ago.
Example plugin to test with just changes the WHERE

Download all attachments as: .zip

Change History (23)

#1 @anonymousbugger
20 years ago

  • Patch set to No

#2 @fil
20 years ago

  • Severity changed from trivial to minor

#3 @pejve
20 years ago

I had a patch for this laying around.
Well, it's for 1.5.1.2 and it applies both "posts_where" and "posts_join". I hope you don't mind.
Please be gentle, I'm new here.

#4 @pejve
20 years ago

I just realised the patch above is flawed. The names "posts_join" and "posts_where" should not be reused as there would be no good way to tell from where the handler was called, and thus what context to filter for.

#5 @pejve
20 years ago

I renamed the filters to "archive_join" and "archive_where" and submitted an updated patch.

#6 @coppit
18 years ago

  • Severity changed from minor to normal

I think that the severity is not "minor". Without this fix, plugins like my category access plugin cannot properly filter posts. In my case, as a result of this problem protected posts cannot be properly excluded from lists returned by get_archives.

Hm... I seem to have the power to up the severity to "normal", so I guess I'll do so. Sorry if I'm overstepping my authority.

#7 @foolswisdom
18 years ago

  • Milestone set to 2.1

#8 @ryan
18 years ago

coppit, will something like this suffice:

$query = "SELECT blah blah blah";
$query = apply_filters('get_archives_query', $query, $args);

If so, want to cook up a patch?

#9 @fil
18 years ago

Would work for my plugin (I'm hooking into the query filter and relying on matching the exact sql)

#10 @ryan
18 years ago

  • Owner changed from anonymous to ryan

#11 @ryan
18 years ago

  • Milestone changed from 2.1 to 2.1.1

#12 @foolswisdom
18 years ago

  • Milestone changed from 2.1.1 to 2.2

#13 @westi
18 years ago

  • Keywords has-patch added
  • Owner changed from ryan to westi
  • Status changed from new to assigned
  • Type changed from defect to enhancement

I have updated the patch to apply to current trunk.

Rather than a single query filter I prefer the WHERE and JOIN filters like we have elsewhere to make sure people don't break the required filtering dependant on the type of archive links being displayed

@westi
18 years ago

New filters

#14 follow-up: @ryan
18 years ago

WHERE needs to come after JOIN. There's a comma missing in one of the apply_filters calls. Let's pass $r to the filters.

#15 @foolswisdom
18 years ago

  • Keywords needs-patch added; has-patch removed

#16 in reply to: ↑ 14 @westi
18 years ago

Replying to ryan:

WHERE needs to come after JOIN. There's a comma missing in one of the apply_filters calls. Let's pass $r to the filters.

That'll teach me for trying to cook up a patch just before I went to bed!

Fixed patch incoming (and I'll have time to testing this time too!)

@westi
18 years ago

Fixed patch

@westi
18 years ago

Example plugin to test with just changes the WHERE

#17 @westi
18 years ago

  • Keywords has-patch added; needs-patch removed

#18 @ryan
18 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.