Opened 11 years ago
Last modified 6 months ago
#30184 new defect (bug)
Author page and category
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.1 |
| Component: | Query | Keywords: | has-patch needs-unit-tests needs-test-info close |
| Focuses: | Cc: |
Description
Got errors like next in debug.log
PHP Notice: Undefined property: stdClass::$ID in /www/test1/wp-includes/query.php on line 4074
PHP Notice: Undefined property: stdClass::$nickname in /www/test1/wp-includes/query.php on line 4076
PHP Notice: Undefined property: stdClass::$user_nicename in /www/test1/wp-includes/query.php on line 4078
In wp-includes/query.php we have the method
public function is_author( $author = '' ) {
if ( !$this->is_author )
return false;
if ( empty($author) )
return true;
$author_obj = $this->get_queried_object();
$author = (array) $author;
if ( in_array( $author_obj->ID, $author ) )
return true;
elseif ( in_array( $author_obj->nickname, $author ) )
return true;
elseif ( in_array( $author_obj->user_nicename, $author ) )
return true;
return false;
}
But if we query a author page with category param queried_object actually will be the category term object, so next patch prevent such problems
public function is_author( $author = '' ) {
if ( !$this->is_author )
return false;
if ( empty($author) )
return true;
$author_obj = $this->get_queried_object();
if ( ! is_a( $author_obj, 'WP_User' ) )
return false;
$author = (array) $author;
if ( in_array( $author_obj->ID, $author ) )
return true;
elseif ( in_array( $author_obj->nickname, $author ) )
return true;
elseif ( in_array( $author_obj->user_nicename, $author ) )
return true;
return false;
}
Attachments (1)
Change History (8)
#4
in reply to:
↑ 2
@
11 years ago
Replying to boonebgorges:
But if we query a author page with category param
How do you do this?
example.com/author/boone?cat=foo?
yes
#5
@
11 years ago
- Component changed from General to Query
- Keywords needs-unit-tests added; reporter-feedback removed
- Milestone changed from Awaiting Review to Future Release
- Version changed from trunk to 3.1
Let's get a unit test in here please.
#6
@
11 years ago
- Keywords needs-testing added
Also I'm not sure the current patch is correct.
is_author() on example.com/author/boone?cat=foo should return true. The problem is that the queried object for a query such as this could be either a user or a term. Which should it be?
#7
@
6 months ago
- Keywords needs-test-info close added; needs-testing removed
Reproduction Report
Description
❌ This report can't validate that the issue can be reproduced.
Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.28
- Server: nginx/1.27.5
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
- Browser: Chrome 137.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty-One 2.5
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
Reproduction Instructions
- According to this comment it should be reproduced by issuing something as
/author/admin/?cat=foo - ❌ I can't see any errors in the logs
- I've created another user just in case
/author/harry/?cat=foo - ❌ Still can't see any errors in the logs
- Tried triggering the double query with a real cat query
author/harry/?cat=3 - ❌ Nothing in the logs.
Actual Results
- ❌ Error condition doesn't occur.
Additional Notes
- More information is needed to reproduce this error.
needs-test-info - Maybe it has been solved over time, so a
closeforworksformecould be the case now.
How do you do this?
example.com/author/boone?cat=foo?