#61374 closed defect (bug) (fixed)
HTML Processor: ::create_fragment returns self when subclassed
Reported by: | jonsurrell | Owned by: | jonsurrell |
---|---|---|---|
Milestone: | 6.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | HTML API | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
In a subclass of WP_HTML_Processor
when an instance is created from the static ::create_fragment
method the instance will be an instance of WP_HTML_Processor
and not and instance of the subclass:
<?php class Sub extends WP_HTML_Processor {} $processor = Sub::create_fragment( '<div>' ); get_class( $processor ); // "WP_HTML_Processor" !!
It's very unlikely that the parent class instance is intended to be created from the subclass.
This can be fixed by creating static
from the ::create_fragment
method.
Change History (6)
This ticket was mentioned in PR #6729 on WordPress/wordpress-develop by @jonsurrell.
7 months ago
#1
- Keywords has-patch has-unit-tests added
This ticket was mentioned in PR #6729 on WordPress/wordpress-develop by @jonsurrell.
7 months ago
#2
Trac ticket: Core-61374
In a subclass of WP_HTML_Processor
when an instance is created from the static ::create_fragment
method the instance will be an instance of WP_HTML_Processor
and _not_ and instance of the subclass:
class Sub extends WP_HTML_Processor {}
$processor = Sub::create_fragment( '<div>' );
get_class( $processor ); // "WP_HTML_Processor" !!
It's very unlikely that the parent class instance is intended to be created from the subclass.
This ticket was mentioned in PR #6729 on WordPress/wordpress-develop by @jonsurrell.
7 months ago
#5
Trac ticket: Core-61374
In a subclass of WP_HTML_Processor
when an instance is created from the static ::create_fragment
method the instance will be an instance of WP_HTML_Processor
and _not_ and instance of the subclass:
class Sub extends WP_HTML_Processor {}
$processor = Sub::create_fragment( '<div>' );
get_class( $processor ); // "WP_HTML_Processor" !!
It's very unlikely that the parent class instance is intended to be created from the subclass.
In a subclass of
WP_HTML_Processor
when an instance is created from the static::create_fragment
method the instance will be an instance ofWP_HTML_Processor
and _not_ and instance of the subclass:class Sub extends WP_HTML_Processor {} $processor = Sub::create_fragment( '<div>' ); get_class( $processor ); // "WP_HTML_Processor" !!
It's very unlikely that the parent class instance is intended to be created from the subclass.
Trac ticket: https://core.trac.wordpress.org/ticket/61374