Make WordPress Core

Opened 22 months ago

Closed 22 months ago

Last modified 22 months ago

#56606 closed enhancement (invalid)

PHP Warning in /wp-includes/blocks/index.php

Reported by: isrgrajan's profile isrgrajan Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

There is PHP warning that need to be fixed in wp-includes/blocks/index.php ABSPATH and WPINC require quotes.


<?php
/**
 * Used to set up all core blocks used with the block editor.
 *
 * @package WordPress
 */

define( 'BLOCKS_PATH', 'ABSPATH' . 'WPINC' . '/blocks/' );

// Include files required for core blocks registration.
require BLOCKS_PATH . 'legacy-widget.php';
require BLOCKS_PATH . 'widget-group.php';
require BLOCKS_PATH . 'require-dynamic-blocks.php';

/**
 * Registers core block types using metadata files.
 * Dynamic core blocks are registered separately.
 *
 * @since 5.5.0
 */
function register_core_block_types_from_metadata() {
        $block_folders = require BLOCKS_PATH . 'require-static-blocks.php';
        foreach ( $block_folders as $block_folder ) {
                register_block_type(
                        BLOCKS_PATH . $block_folder
                );
        }
}
add_action( 'init', 'register_core_block_types_from_metadata' );


Change History (3)

This ticket was mentioned in PR #3287 on WordPress/wordpress-develop by isrgrajan.


22 months ago
#1

  • Keywords has-patch added; needs-patch removed

Need to fix PHP Warning which throws Use of undefined constant ABSPATH - assumed 'ABSPATH' https://core.trac.wordpress.org/ticket/56606

#2 @peterwilsoncc
22 months ago

  • Component changed from Revisions to General
  • Focuses administration rest-api removed
  • Keywords changes-requested has-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Severity changed from blocker to normal
  • Status changed from new to closed
  • Version trunk deleted

Hi @isrgrajan and welcome to trac!

The use of ABSPATH and WPINC in this file without quotes is intended. These values are defined by WordPress elsewhere to indicate where WordPress is installed and the path for wp-includes respectively.

I suspect you are seeings messages in your server logs that show these values are undefined because either a person or, more likely, a bot is accessing the file directly by visiting example.com/wp-includes/blocks/.

These log entries indicate the file is been accessed in an unintended manner rather than a bug in WordPress. Unfortunately it's not something WordPress can fix, but you may be able to block access to the file on your server. If you ask in the support forums, someone may be able to assist you with how to do this.

I'm going to close this ticket off as invalid. In this case, it's trac's unfriendly term to indicate it's not something that can be fixed by WordPress.

peterwilsoncc commented on PR #3287:


22 months ago
#3

The use of the constants without quotes is intended, I've added a full explanation on the ticket. https://core.trac.wordpress.org/ticket/56606#comment:2

Thanks for taking the time to create a pull request! Even though the code won't make it in to WordPress, your help is appreciated.

Note: See TracTickets for help on using tickets.