• Cornwell

    (@cornwell)


    On checking the php error log after upgrading to release 6.4.1 (and php 8.0) I see

    [13-Nov-2023 07:47:05 UTC] PHP Warning: Use of undefined constant ABSPATH – assumed ‘ABSPATH’ (this will throw an Error in a future version of PHP) in /home/[redacted]/public_html/wp-includes/blocks/index.php on line 8
    [13-Nov-2023 07:47:05 UTC] PHP Warning: Use of undefined constant WPINC – assumed ‘WPINC’ (this will throw an Error in a future version of PHP) in /home/[redacted]/public_html/wp-includes/blocks/index.php on line 8
    [13-Nov-2023 07:47:05 UTC] PHP Warning: require(ABSPATHWPINC/blocks/legacy-widget.php): failed to open stream: No such file or directory in /home/[redacted]/public_html/wp-includes/blocks/index.php on line 11
    [13-Nov-2023 07:47:05 UTC] PHP Warning: require(ABSPATHWPINC/blocks/legacy-widget.php): failed to open stream: No such file or directory in /home/[redacted]/public_html/wp-includes/blocks/index.php on line 11
    [13-Nov-2023 07:47:05 UTC] PHP Fatal error: require(): Failed opening required ‘ABSPATHWPINC/blocks/legacy-widget.php’ (include_path=’.:/opt/cpanel/ea-php74/root/usr/share/pear’) in /home/[redacted]/public_html/wp-includes/blocks/index.php on line 11

    Looking at wp-includes/blocks/index.php I see at lines 8 – 13

    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';

    Presumably the define at line 8 is wrong? But how to fix it?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    That define line looks OK, the problem is that ABSPATH and WPINC are not defined. Core WP should define these. ABSPATH should be defined in wp-config.php near the bottom of the file. And WPINC is defined in wp-settings.php at the top of the file.

    Check your wp-config.php file to ensure there is not a problem that prevents the ABSPATH definition from executing. Similar for wp-settings.php. If those check out OK, then the question would be how are these files not included in the request? They should be for all WP requests. If the answer is not clear, do the usual debugging process of switching to a default theme and deactivating all plugins. The errors should no longer occur. Isolate the cause by restoring your theme and plugins, one at a time, testing after each until the problem recurs.

    The same error has been appearing on my multiple websites since the last WP core update.
    These lines are present in wp-config.php:

    if ( !defined(‘ABSPATH’) )
    define(‘ABSPATH’, dirname(FILE) . ‘/’);
    require_once(ABSPATH . ‘wp-settings.php’);

    Moderator bcworkz

    (@bcworkz)

    @nelchee — please start your own new topic about your issue. While it’s common to tag onto other people’s topics in other forums, it’s strongly discouraged here. There are several reasons for this but one is a lot more people will see your topic if you post anew.

    Offhand, I’d say if you’re getting a “Use of undefined constant ABSPATH” warning then I’d guess you have code somewhere that has not initialized WP properly.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘undefined constants ABSPATH and WPINC in wp-includes/blocks/index.php’ is closed to new replies.