Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 2 years ago

#41171 closed defect (bug) (invalid)

Incorrect (query?) fetching of Pages

Reported by: hyperized's profile hyperized Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8
Component: Rewrite Rules Keywords: has-patch
Focuses: Cc:

Description (last modified by SergeyBiryukov)

So, this occurs on 4.8 and 4.7 (even down to 3.x) alike, so it's most likely a compatibility bug between the versions of software in use and WordPress. Versions are listed below.

The effects are pretty bad as I can no longer open Posts ('Invalid post type.') and no longer use Pages ('No pages found') however there are three items correctly listed in the 'All' count on Pages, so the count queries work correctly.

I tried figuring out what happens, but I have not managed to nail it down to the exact error. I also tried Googling this issue and the 'fixes' did not go beyond: nail this down to a plugin. I can reproduce this error with each clean install (no plugins, nothing beyond the default theme) over and over again, so that's not going to fix it.

To fetch the content of 'Pages' the following query is executed (courtesy of Query Monitor):

SELECT wp_posts.*
FROM wp_posts 
WHERE 1=1 
AND wp_posts.post_name = 'edit-php'
AND wp_posts.post_type = 'page' 
ORDER BY wp_posts.post_title ASC	

Which is odd since no pages have the name edit-php.
This explains why it shows 'No Pages found', the query returns none.

The page however itself is called edit.php. I'm supposing something is going wrong with the query input here. It seems mixed up.

I'm at the same time provided with a (because of debug on):

Notice: Undefined offset: 1 in /home/mydomain/public_html/wp-includes/vars.php on line 31

This file relies on $_SERVER['PHP_SELF'] to obtain the page information. If I slip in a phpinfo() in the line above the 'if' to assert wheter it's filled with the correct information I get: $_SERVER['PHP_SELF'] /edit.php . This seems correct, so it's kind of odd that offset 1 is undefined on $self_matches .

When debugging $self_matches on line 31, I get: array(0) { } .

Server environment as reported by Query Monitor:

Property	Value
version	7.0.19
sapi	fpm-fcgi
user	wantsone
max_execution_time	30
memory_limit	1G
upload_max_filesize	64M
post_max_size	64M
Property	Value
extension	mysqli
server version	5.5.5
client version	50012 (5.0.12)
user	mysite_wp1
host	localhost
database	mysite_wp1
key_buffer_size	134217728
~128 MB
max_allowed_packet	4194304
~4 MB
max_connections	151
query_cache_limit	1048576
~1 MB
query_cache_size	1048576
~1 MB
query_cache_type	OFF (Help)

Database is in fact: MariaDB 10.1.24

Property	Value
version	4.8
WP_CACHE	false
COMPRESS_CSS	undefined
WP_LOCAL_DEV	undefined
Property	Value
software	Apache
version	2

Apache is in fact: Server version: Apache/2.4.26 (Unix) 64bit MPM event

Attachments (3)

41171.patch (626 bytes) - added by Dency 7 years ago.
check for isset $self_matches[1] for pagenow
41171-2.patch (654 bytes) - added by Dency 7 years ago.
check for empty and isset $self_matches[1] for pagenow
41171.2.patch (627 bytes) - added by umangvaghela123 7 years ago.
Fix #41171 issue

Download all attachments as: .zip

Change History (13)

7 years ago

check for isset $self_matches[1] for pagenow

This ticket was mentioned in Slack in #core by dixita. View the logs.

7 years ago

#2 @Dency
7 years ago

  • Keywords has-patch added

7 years ago

check for empty and isset $self_matches[1] for pagenow

7 years ago

Fix #41171 issue

#3 @hyperized
7 years ago

Those patches successfully get rid of the 'notice', however the original problem (incorrect query) still persists.

#4 @donutz
7 years ago

Just ran into this problem after upgrading homebrew packages. Adding ProxyFCGIBackendType GENERIC to httpd.conf resolves the issue, cf.

#5 @hyperized
7 years ago

  • Keywords close added

@donutz you are my hero! That fixed the issue for me.
I guess there isn't too much WordPress itself can do about it, since this is a bug in Apache.

Thanks for the WP folks fixing the notice :).

#6 @DrewAPicture
7 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

#7 @SergeyBiryukov
7 years ago

  • Component changed from General to Rewrite Rules

This ticket was mentioned in Slack in #forums by zodiac1978. View the logs.

7 years ago

#9 @rogerlos
7 years ago

Just noting for the record that I get a notice that index [1] of $self_matches is not defined when running phpunit tests (using wordpress-dev) on my local box. Not a huge deal.

#10 @SergeyBiryukov
2 years ago

  • Description modified (diff)

Related: #29161, #54700.

Note: See TracTickets for help on using tickets.