Make WordPress Core

Changeset 57023

Timestamp:
10/27/2023 07:23:24 PM (9 months ago)
Author:
joemcgill
Message:

Upgrade/Install: Skip registering theme block patterns during the upgrade process.

This fixes a bug during the database upgrade process where a theme's functions.php file may not be loaded, leading to potential exceptions if the theme's pattern files use symbols (classes, functions, constants, etc.) that are declared only when the functions.php file is loaded. To do so, a check for wp_get_active_and_valid_themes() is added early to _register_theme_block_patterns(), which returns early if no active or valid themes are returned.

Props fabiankaegy, rajinsharwar, pbiron, huzaifaalmesbah, hellofromTonya, peterwilsoncc, joemcgill.
Reviewed by hellofromTonya.
Merges [57021] to the 6.4 branch.
Fixes #59723.

Location:
branches/6.4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/6.4

  • branches/6.4/src/wp-includes/block-patterns.php

    r56979 r57023  
    329329 */
    330330function _register_theme_block_patterns() {
     331
     332
     333
     334
     335
     336
     337
     338
     339
     340
     341
    331342    /*
    332343     * Register patterns for the active theme. If the theme is a child theme,
  • branches/6.4/tests/phpunit/tests/blocks/wpBlockPatternsRegistry.php

    r56960 r57023  
    483483        $this->assertTrue( $result );
    484484    }
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
     495
     496
     497
     498
     499
     500
     501
     502
     503
     504
     505
     506
     507
     508
     509
     510
     511
     512
     513
     514
     515
     516
     517
     518
     519
     520
     521
     522
     523
     524
     525
     526
     527
     528
     529
     530
     531
     532
     533
     534
     535
     536
     537
     538
     539
     540
     541
     542
     543
     544
     545
     546
     547
     548
    485549}
Note: See TracChangeset for help on using the changeset viewer.