[wp-trac] [WordPress Trac] #61374: HTML Processor: ::create_fragment returns self when subclassed

WordPress Trac noreply at wordpress.org
Sat Jun 8 10:56:12 UTC 2024


#61374: HTML Processor: ::create_fragment returns self when subclassed
--------------------------------------+------------------------------
 Reporter:  jonsurrell                |       Owner:  jonsurrell
     Type:  defect (bug)              |      Status:  closed
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  HTML API                  |     Version:
 Severity:  normal                    |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------------------
Changes (by dmsnell):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"58363" 58363]:
 {{{
 #!CommitTicketReference repository="" revision="58363"
 HTML API: Return subclass from `::create_fragment`

 When the `WP_HTML_Processor` was introduced with its `::create_fragment()`
 static creator method, that method has been returning a `new self(...)`.
 Unfortunately, this means that subclasses cannot use that method since it
 will return the `WP_HTML_Processor` instead of the subclass.

 With this patch, the static creator method returns `new static(...)` to
 preserve
 the intended behavior. A new test asserts this behavior for future
 changes.

 Developed in https://github.com/WordPress/wordpress-develop/pull/6729
 Discussed in https://core.trac.wordpress.org/ticket/61374

 Props dmsnell, jonsurrell.
 Follow-up to [56274].
 Fixes #61374.
 }}}

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


More information about the wp-trac mailing list