Opened 16 years ago
Closed 16 years ago
#9059 closed defect (bug) (wontfix)
category with name '0' gets ignored
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | low | |
Severity: | minor | Version: | 2.7 |
Component: | Optimization | Keywords: | needs-patch potential-wontfix |
Focuses: | Cc: |
Description
I have a category called 0 (zero) for all posts starting with 0, <?php single_cat_title(); ?> doesnt show 0 when inside that category, it works fine for all the other numbered categorys and all individual lettered categorys also work fine its just 0 thats giving me problems.
If i add something before or after the 0 it will then show but shouldnt it work ok with just 0?
Thanks in advance
Attachments (1)
Change History (12)
#1
@
16 years ago
- Component changed from Themes to Template
- Keywords needs-patch added; single_cat_title numbered category 0 removed
- Owner set to anonymous
#2
@
16 years ago
- Component changed from Template to Optimization
- Keywords dev-feedback added
- Milestone set to 2.8
- Summary changed from single_cat_title wont show category called 0 to Why is WP using empty()?
On a more general note, why in the bloody hell is empty() used throughout WP.
I did a few tests on my end while wondering whether empty() or casting to boolean works fastest, and the latter beats the former by a landslide.
if ( !empty($foo) ) ...
is slower than:
if ( !$foo ) ...
#4
@
16 years ago
- Keywords dev-feedback removed
Yep, the !empty avoids the PHP Notice: Undefined variable: foo
Back to the original patch - the change doesn't work for me. But then on IIS the
index.php/category/0/
Displays just like the front page, its almost as if the cat is not redirected at all, so the fact that the category name isn't displayed is the least of the issue.
Removing dev-feedback since Ryan replied.
#5
@
16 years ago
- Keywords has-patch added; needs-patch removed
Changed keyword from needs-patch to has-patch. Did not test patch.
#6
@
16 years ago
- Keywords needs-patch added; has-patch removed
- Summary changed from Why is WP using empty()? to category with name '0' gets ignored
patch is no good. as highlighted by mist, the real issue is that such a category gets ignored entirely by WP, due to the fact that, well... empty('0') returns true.
wontfix imo
The problem comes from the usage of
if ( !empty($variable) )
.And actually there's two problems going on here. Viewing the archive for a category with the stub of
0
doesn't load thearchive.php
template -- it usesindex.php
. I've made a separate ticket for that though: #9352