[wp-trac] [WordPress Trac] #63122: Site Editor: Browser reload causes PHP warning error on the Pages screen

WordPress Trac noreply at wordpress.org
Tue Mar 18 16:24:49 UTC 2025


#63122: Site Editor: Browser reload causes PHP warning error on the Pages screen
--------------------------+---------------------
 Reporter:  wildworks     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  6.8
Component:  Editor        |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+---------------------

Comment (by abcd95):

 Hi @wildworks thanks for bringing this up.

 After investigating the issue, I found the problem is in `site-
 editor.php`. When building the URL for template lookup, there's a variable
 naming inconsistency:
 {{{
 empty( $block_editor_context->post->post_name ) ? 'page' : 'page-' .
 $post->post_name,
 }}}

 The code correctly uses `$block_editor_context->post` in the first part,
 but then incorrectly uses `$post` in the second part. Since `$post` is
 undefined at this point, it triggers PHP warnings when the browser is
 reloaded.

 The fix is to use the same variable throughout:

 {{{
 empty( $block_editor_context->post->post_name ) ? 'page' : 'page-' .
 $block_editor_context->post->post_name,
 }}}

 This resolves the warning in my testing. Let me know if this works for you
 and I can raise a PR with the fix.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63122#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list