#61374 closed defect (bug) (fixed)
HTML Processor: ::create_fragment returns self when subclassed
| Reported by: | jonsurrell | Owned by: | jonsurrell |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.6 |
| Component: | HTML API | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
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.
2 years ago
#1
- Keywords has-patch has-unit-tests added
This ticket was mentioned in PR #6729 on WordPress/wordpress-develop by @jonsurrell.
2 years 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.
2 years 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
In a subclass of
WP_HTML_Processorwhen an instance is created from the static::create_fragmentmethod the instance will be an instance ofWP_HTML_Processorand _not_ and instance of the subclass: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