Opened 4 years ago
Closed 4 years ago
#9059 closed defect (bug) (wontfix)
category with name '0' gets ignored
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | Optimization | Version: | 2.7 |
| Severity: | minor | Keywords: | needs-patch potential-wontfix |
| 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)
comment:1
Viper007Bond — 4 years ago
- Component changed from Themes to Template
- Keywords needs-patch added; single_cat_title numbered category 0 removed
- Owner set to anonymous
- 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 ) ...
- 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.
comment:5
simonwheatley — 4 years ago
- Keywords has-patch added; needs-patch removed
Changed keyword from needs-patch to has-patch. Did not test patch.
- 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
See also #7507
and #9352
- Milestone changed from 2.8 to 2.9
moving to 2.9, from lack of valid patch
comment:10
hakre — 4 years ago
- Keywords potential-wontfix added
-1My Opinion: You will never get this patched. There are way tooo much IFs verywhere that check for false or empty and this category name. I just would comment "forget it".
- Milestone 2.9 deleted
- Resolution set to wontfix
- Status changed from new to closed
let's close this, then.

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 the archive.php template -- it uses index.php. I've made a separate ticket for that though: #9352