Make WordPress Core

#62581 closed defect (bug) (duplicate)

Fatal error TypeError: basename(): wp-settings.php in latest WP 6.8 Beta

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

Description

I get a fatal error in the latest wp 6.8 beta nightly build

Fatal error: Uncaught TypeError: basename(): Argument #1 ($path) must be of type string, Theme given in /home/public_html/wp-settings.php:686 Stack trace: #0 /home/public_html/wp-settings.php(686): basename(Object(Theme)) #1 /home/wp-config.php(96): require_once('/home/...') #2 /home/public_html/wp-load.php(55): require_once('/home/..') #3 /home/public_html/wp-admin/admin.php(34): require_once('/home/...') #4 /home/public_html/wp-admin/about.php(10): require_once('/home/...') #5 {main} thrown in /home/public_html/wp-settings.php on line 686

cause by this code

Fatal error: Uncaught TypeError: basename(): Argument #1 ($path) must be of type string, Theme given in /home/public_html/wp-settings.php:686 Stack trace: #0

/home/public_html/wp-settings.php(686): basename(Object(Theme)) #1 /home/wp-config.php(96): require_once('/home/...') #2 /home/public_html/wp-load.php(55): require_once('/home/..') #3 /home/public_html/wp-admin/admin.php(34): require_once('/home/...') #4 /home/public_html/wp-admin/about.php(10): require_once('/home/...') #5 {main} thrown in /home/public_html/wp-settings.php on line 686



<?php
                // Load the functions for the active theme, for both parent and child theme if applicable.
                foreach ( wp_get_active_and_valid_themes() as $theme ) {
                        if ( file_exists( $theme . '/functions.php' ) ) {
                                include $theme . '/functions.php';
                        }

                        $theme = wp_get_theme( basename( $theme ) );
                        $theme->load_textdomain();
                }

Change History (2)

#1 @neo2k23
15 months ago

suggested code change

<?php
foreach ( wp_get_active_and_valid_themes() as $theme ) {
        if ( file_exists( $theme . '/functions.php' ) ) {
                include $theme . '/functions.php';
        }
        
        if ( is_string( $theme ) ) {
                $theme = wp_get_theme( basename( $theme ) );
                $theme->load_textdomain();
        }
}
Last edited 15 months ago by neo2k23 (previous) (diff)

#2 @swissspidy
15 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Thanks for your report. This was added in #62244, so let's fix that there.

Note: See TracTickets for help on using tickets.