Make WordPress Core

Opened 4 weeks ago

Last modified 3 weeks ago

#61286 assigned defect (bug)

PHP message: PHP Fatal error: Uncaught Error: Undefined constant "ABSPATH" in wp-includes/cache.php

Reported by: deepakrohilla's profile deepakrohilla Owned by: deepakrohilla's profile deepakrohilla
Milestone: Awaiting Review Priority: normal
Severity: major Version: 6.5.3
Component: General Keywords: has-patch
Focuses: Cc:

Description

PHP message: PHP Fatal error: Uncaught Error: Undefined constant "ABSPATH" in /var/wp-includes/cache.php:12
request_uri': '/wp-content/cache.php'

Attachments (1)

Screenshot from 2024-05-24 11-18-43.png (37.7 KB) - added by deepakrohilla 4 weeks ago.
PHP message: PHP Fatal error: Uncaught Error: Undefined constant "ABSPATH" in /wp-includes/cache.php:12

Download all attachments as: .zip

Change History (9)

@deepakrohilla
4 weeks ago

PHP message: PHP Fatal error: Uncaught Error: Undefined constant "ABSPATH" in /wp-includes/cache.php:12

This ticket was mentioned in PR #6620 on WordPress/wordpress-develop by @deepakrohilla.


4 weeks ago
#1

  • Keywords has-patch added; needs-patch removed

#2 @mukesh27
4 weeks ago

  • Focuses performance privacy sustainability coding-standards php-compatibility removed

#3 @adamsilverstein
4 weeks ago

@deepakrohilla thanks for opening the ticket. the fix on your PR looks good, some small feedback to address there before commit.

It would be nice to add some steps to reproduce here as it is not obvious how you encountered the error from your ticket description. Understanding how the issue occurs also helps with having a clear commit message for the fix.

#4 @adamsilverstein
4 weeks ago

  • Keywords changes-requested added

#5 @deepakrohilla
4 weeks ago

@mukesh27 Thank you for the review; I've made the suggested changes.

#6 @deepakrohilla
4 weeks ago

  • Keywords changes-requested removed

@adamsilverstein Thanks for the feedback.

For reproducing this issue:

In address bar of the browser directly hit url like <domain-name>/wp-includes/cache.php it will produce 500 and message will be look like below on browser screen.

This page isn’t working
<domain-name> is currently unable to handle this request.
HTTP ERROR 500

#7 @SergeyBiryukov
4 weeks ago

Hi there, thanks for the ticket!

A similar issue was addressed in [49619] / #35835 for wp-includes/rss-functions.php.

Unless I'm missing something, calling directly pretty much any other file in wp-includes or wp-admin/includes would lead to the same issue, so if we want to add an early exit, it might be a good idea to do that in a consistent way.

Related: #47154, #51806, #55944, #61214, #61277.

#8 @deepakrohilla
3 weeks ago

@SergeyBiryukov I have cover maximum number of files of wp-includes & wp-admin directory and raised in https://core.trac.wordpress.org/ticket/61314#ticket with patch

Note: See TracTickets for help on using tickets.