Skip to content

Commit 7b8aa53

Browse files
dmsnellwestonruter
andcommitted
Raise WP error when failing.
Co-authored-by: Weston Ruter <westonruter@git.wordpress.org>
1 parent db24c11 commit 7b8aa53

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/wp-includes/html-api/class-wp-html-processor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,11 @@ public static function normalize( string $html ): ?string {
11121112
*/
11131113
public function serialize(): ?string {
11141114
if ( WP_HTML_Tag_Processor::STATE_READY !== $this->parser_state ) {
1115+
wp_trigger_error(
1116+
__METHOD__,
1117+
"An HTML Processor which has already started processing cannot serialize it's contents. Serialize immediately after creating the instance.",
1118+
E_USER_ERROR
1119+
);
11151120
return null;
11161121
}
11171122

@@ -1215,6 +1220,11 @@ public function serialize(): ?string {
12151220
}
12161221

12171222
if ( null !== $this->get_last_error() ) {
1223+
wp_trigger_error(
1224+
__METHOD__,
1225+
"Cannot serialize HTML Processor with parsing error: {$this->get_last_error()}.",
1226+
E_USER_ERROR
1227+
);
12181228
return null;
12191229
}
12201230

0 commit comments

Comments
 (0)