Ticket #1368 (closed enhancement: fixed)

Opened 4 years ago

Last modified 2 years ago

Should apply "posts_where" filter in get_archives

Reported by: anonymousbugger Assigned to: westi
Priority: normal Milestone: 2.2
Component: Administration Version: 1.5.1
Severity: normal Keywords: has-patch
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

template_functions_general_1.5.1.2_mp001_hookup.patch (3.4 kB) - added by pejve on 06/14/05 13:46:21.
template_functions_general_1.5.1.2_mp001_hookup2.patch (3.4 kB) - added by pejve on 06/30/05 19:47:17.
1368.diff (3.8 kB) - added by westi on 03/07/07 21:22:54.
New filters
1368a.diff (3.9 kB) - added by westi on 03/08/07 08:48:51.
Fixed patch
test_plugin.php (454 bytes) - added by westi on 03/08/07 08:49:15.
Example plugin to test with just changes the WHERE

Change History

05/15/05 03:05:31 changed by anonymousbugger

  • Patch set to No.

05/30/05 20:48:34 changed by fil

  • severity changed from trivial to minor.

06/14/05 13:46:21 changed by pejve

  • attachment template_functions_general_1.5.1.2_mp001_hookup.patch added.

06/14/05 13:51:11 changed by pejve

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.

06/16/05 16:27:17 changed by pejve

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.

06/30/05 19:47:17 changed by pejve

  • attachment template_functions_general_1.5.1.2_mp001_hookup2.patch added.

06/30/05 19:54:05 changed by pejve

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

01/08/07 17:35:23 changed by coppit

  • 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.

01/08/07 21:07:45 changed by foolswisdom

  • milestone set to 2.1.

01/09/07 08:51:28 changed by ryan

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?

01/09/07 19:47:29 changed by fil

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

01/16/07 01:26:10 changed by ryan

  • owner changed from anonymous to ryan.

01/18/07 19:03:26 changed by ryan

  • milestone changed from 2.1 to 2.1.1.

01/23/07 05:49:59 changed by foolswisdom

  • milestone changed from 2.1.1 to 2.2.

03/07/07 21:22:35 changed by westi

  • keywords set to has-patch.
  • 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

03/07/07 21:22:54 changed by westi

  • attachment 1368.diff added.

New filters

(follow-up: ↓ 16 ) 03/07/07 22:06:09 changed by 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.

03/07/07 22:27:16 changed by foolswisdom

  • keywords changed from has-patch to needs-patch.

(in reply to: ↑ 14 ) 03/08/07 08:33:29 changed by westi

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!)

03/08/07 08:48:51 changed by westi

  • attachment 1368a.diff added.

Fixed patch

03/08/07 08:49:15 changed by westi

  • attachment test_plugin.php added.

Example plugin to test with just changes the WHERE

03/08/07 08:49:49 changed by westi

  • keywords changed from needs-patch to has-patch.

03/09/07 04:10:48 changed by ryan

  • status changed from assigned to closed.
  • resolution set to fixed.