Ticket #5324 (closed defect: fixed)

Opened 1 year ago

Last modified 4 weeks ago

404 error on empty category page

Reported by: othellobloke Assigned to: technosailor
Priority: normal Milestone: 2.7
Component: General Version: 2.5
Severity: normal Keywords: has-patch dev-feedback
Cc:

Description

spoken to many people who believe this isn't good functionality and probably a bug. i'm not a coder so I might be wrong, but i hope not.

wordpress returns a 404 error when a category page is viewed that's empty.

Attachments

5324-classes.php.patch (0.8 kB) - added by pishmishy on 11/07/07 13:19:12.
Addresses this issue, if it needs fixing that is
5324-handle404.diff (1.0 kB) - added by technosailor on 07/24/08 04:52:15.
5324.diff (0.9 kB) - added by ryan on 08/27/08 01:09:39.
archive.diff (3.6 kB) - added by caesarsgrunt on 09/01/08 08:11:14.
Empty archive fix for default template, first try.
5324.2.diff (1.2 kB) - added by DD32 on 11/08/08 00:28:57.

Change History

11/07/07 10:34:20 changed by Viper007Bond

  • keywords set to needs-patch.
  • version set to 2.4.
  • milestone changed from 2.5 to 2.4.

Confirmed on trunk. Displays the error 404 page and sends a 404 header for the archive view of an empty but existing category.

It should display as normal and when the template check for have_posts() or whatever fails, the "no matching posts" error will be shown.

(follow-up: ↓ 4 ) 11/07/07 11:04:08 changed by pishmishy

Question...

Does this occur only when you manually construct the URL itself, or is WordPress automatically generating a link to the page for the empty category which results in a 404?

11/07/07 13:19:12 changed by pishmishy

  • attachment 5324-classes.php.patch added.

Addresses this issue, if it needs fixing that is

11/07/07 13:25:22 changed by pishmishy

  • keywords changed from needs-patch to has-patch.
  • owner changed from anonymous to pishmishy.
  • status changed from new to assigned.

Sorry, ignore that file. It's not complete.

(in reply to: ↑ 2 ) 11/07/07 13:45:17 changed by Viper007Bond

Replying to pishmishy:

Question... Does this occur only when you manually construct the URL itself, or is WordPress automatically generating a link to the page for the empty category which results in a 404?

Well, it's the same URL, so... ;)

11/07/07 15:11:08 changed by pishmishy

  • owner changed from pishmishy to anonymous.
  • status changed from assigned to new.

Actually I think this one is beyond me to fix cleanly.

11/08/07 02:28:59 changed by Viper007Bond

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

07/24/08 04:44:03 changed by technosailor

Patch attached. Fixes WP::handle_404() to ensure that emoty archives are not treated as 404 and instead serves a 200 allowing the Loop to take over.

07/24/08 04:44:23 changed by technosailor

  • keywords changed from needs-patch to has-patch.
  • owner changed from anonymous to technosailor.
  • status changed from new to assigned.

07/24/08 04:52:15 changed by technosailor

  • attachment 5324-handle404.diff added.

08/12/08 00:37:48 changed by technosailor

  • keywords changed from has-patch to has-patch dev-feedback.

08/12/08 00:38:05 changed by technosailor

  • milestone changed from 2.9 to 2.7.

hopefully, one of the devs can look at this and maybe get it in.

08/12/08 21:48:00 changed by ryan

My only concern is that some templates assume that there are posts when there is not a 404. I think that's probably a small number of templates, however. The patch seems worth a shot for 2.7.

08/12/08 22:51:16 changed by AaronCampbell

On my first few test, the latest patch seems to be working perfectly. I'd REALLY like to see this in 2.7.

08/17/08 22:52:12 changed by AaronCampbell

I applied the patch by technosailor to my 2.6.1 install and it's working great. I'd still like to see this submitted to trunk. What do we still need to do to make that happen?

08/18/08 21:49:17 changed by technosailor

Yeah, let's get it in and beat on it so I know if it needs any further changes.

08/18/08 22:42:02 changed by ryan

For taxonomy and author queries, shouldn't we be checking to see if the queried object is empty and 404 if so.

08/26/08 12:10:39 changed by caesarsgrunt

I've always been frustrated by this bug. The page should exist, and say there are no articles by that author (etc). It shouldn't return a 404!

Get it into trunk!!!

08/27/08 01:09:39 changed by ryan

  • attachment 5324.diff added.

08/27/08 01:10:36 changed by ryan

Here's a version that makes sure the various archive queries matched an object. If not, 404.

08/27/08 01:21:31 changed by caesarsgrunt

Um... What's an object? If I visit the page http://www.example.com/author/fred/, but author Fred hasn't yet written anything, does your patch stop the 404 from being returned? If so, what is returned?

08/27/08 01:44:59 changed by ryan

If the user Fred doesn't exist, we should 404. If he does exist but has not written anything, we should not 404.

08/27/08 02:03:48 changed by AaronCampbell

Ryan: That's working better. It 404 for things like invalid categories, but not for empty categories.

08/28/08 19:58:57 changed by ryan

(In [8761]) Don't 404 for categories, tags, and authors that exist but have no posts. see #5324

(follow-up: ↓ 23 ) 08/31/08 09:49:07 changed by mrmist

It still doesn't look quite right to me - Now instead of a 404 you get "Not found", which doesn't really seem any better from the viewer's perspective. "Not found" does not really explain the situation - does it mean "author not found" or "no posts found", etc..

If the author exists (with posts), you get a page heading of "Author Archive" (with posts below.). It seems that if the author exists (without posts) it should still say "Author Archive" and simply not list any posts, rather than saying "Not found".

(This may be a templating issue which distincts it from the coding issue, I suppose, in which case it needs a change to the behaviour of the default template.)

(in reply to: ↑ 22 ) 08/31/08 09:55:09 changed by caesarsgrunt

Replying to mrmist:

Yes, I absolutely agree. Basically the only change so far is the error code, which whilst it is an improvement hardly affects the visitor. The solution isn't very user-friendly solution yet.
Yes, it may be a templating issue. I can't remember. But if it is then, as you say, it should be changed in the default template.

+1 for "Author Archive" heading with no posts. Perhaps a message below saying "there are no posts by this author", or similar.

09/01/08 05:06:20 changed by caesarsgrunt

See also #3345. There are some patches for this issue there, though I haven't looked at them...

09/01/08 05:22:19 changed by ryan

It is a templating issue. The language in archive.php can be changed.

09/01/08 07:15:17 changed by caesarsgrunt

OK; I'll make a patch for the default template.

I don't think a 404 should be returned for date archives with no posts either, this should be fixed in the same way.

09/01/08 08:11:14 changed by caesarsgrunt

  • attachment archive.diff added.

Empty archive fix for default template, first try.

09/01/08 08:54:59 changed by caesarsgrunt

Oh sorry, I've jut realised that diff contains some other fixes as well (tidying up the page title)... I'll clean it up later or tomorrow and try again, but have a look at the relevant part anyway!

10/02/08 13:46:39 changed by AaronCampbell

Bump

10/02/08 13:51:54 changed by pishmishy

If you have a comment to make regarding a fix for this issue, or your need for a fix, please make it, but please don't 'bump' tickets. The lack of action is not because we aren't aware of the ticket's existence.

10/02/08 14:37:15 changed by AaronCampbell

That's fair. I should have asked my question rather than bumping the topic. Where do we stand on this? I've been using the patch successfully for quite a while now, on a few different sites. I think we're just waiting on the default theme to be updated to handle this? If this is the case I'll update that and upload a patch.

10/17/08 17:00:58 changed by ryan

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

(In [9226]) Better not found messages. Props caesarsgrunt. fixes #5324

10/18/08 12:23:37 changed by AaronCampbell

Am I mistaken, or did we add the changes to archive.php but not make technosailor's changes to classes.php that made it necessary?

10/18/08 12:30:26 changed by DD32

Am I mistaken, or did we add the changes to archive.php but not make technosailor's changes to classes.php that made it necessary?

There was this comment furthur up that touched classes.php, not sure if its the one you're after though..

08/28/08 19:58:57 changed by ryan

(In [8761]) Don't 404 for categories, tags, and authors that exist but have no posts. see #5324

10/18/08 12:33:03 changed by AaronCampbell

My bad, thanks.

11/08/08 00:27:48 changed by DD32

get_userdatabylogin(get_query_var('author_name'))->display_name

I dont think thats PHP4 compatible, as you cant use the return value of a function as a object reference, on the back of [wp-testers] Tag error in default theme i'll attach a patch for that.

11/08/08 00:28:57 changed by DD32

  • attachment 5324.2.diff added.

11/08/08 23:27:49 changed by ryan

(In [9577]) Eliminate chaining for php 4 compat. Props DD32. fixes #5324