﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	focuses
65689	register_block_template(): PHP warnings when a plugin-registered template is assigned to an individual post	nendeb55		"When a template registered with the Plugin Template Registration API is assigned to an individual post, several PHP warnings and deprecation notices are triggered in the editor.


**Step-by-step reproduction instructions**

Register a block template from a plugin.

```
add_action(
	'init',
	function () {
		register_block_template(
			'gutenberg//author-admin',
			array(
				'title'       => 'Enhanced Author Admin template',
				'description' => 'An enhanced version of the Author Admin template.',
				'content'     => '<!-- wp:template-part {""slug"":""header"",""tagName"":""header""} /--><!-- wp:group {""tagName"":""main"",""layout"":{""inherit"":true}} --><main class=""wp-block-group""><!-- wp:paragraph --><p>This is an enhanced author template.</p><!-- /wp:paragraph --></main><!-- /wp:group --><!-- wp:template-part {""slug"":""footer"",""tagName"":""footer""} /-->',
				'post_types'  => array( 'post' ),
			)
		);
	}
);
```


Open a post in the editor.
Assign the registered plugin template to that post.
Reload or reopen the editor.


**Expected behavior**
The assigned template should load without any PHP warnings or deprecation notices.

**Actual behavior**
The following warnings are generated:

Warning: Undefined array key 0 in wp-includes/block-editor.php on line 469
Warning: Attempt to read property ""content"" on null in wp-includes/block-editor.php on line 469
Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in wp-includes/class-wp-block-parser.php on line 247
Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in wp-includes/class-wp-block-parser.php on line 324


**Additional information**
The template is registered using the plugin-slug//template-slug naming convention introduced in https://github.com/WordPress/gutenberg/pull/61577.

The same warnings also occur in WordPress 7.0, so this issue is not specific to WordPress 7.1.

If I open the assigned template in the Site Editor and save it (even without making any changes), the warnings no longer occur.
"	defect (bug)	new	normal	Awaiting Review	Themes	7.0	normal		has-patch has-unit-tests		
