Silverstripe-framework: DBHTMLText should instantiate HTMLEditorField via injector using ::create().

Created on 25 Jul 2019  路  2Comments  路  Source: silverstripe/silverstripe-framework

Affected Version

All versions of SS 4.x. (and 3.x but this cannot be fixed there due to maintenance schedule)

Description

When automatically generating an editor form for DataObject's for an HTMLText type, SilverStripe will instantiate HTMLEditorField directly using the new keyword instead of passing it through the Injector via ::create() like it should.

See: https://github.com/silverstripe/silverstripe-framework/blob/3e90fdf42f3306d9de739edee807175538f10d88/src/ORM/FieldType/DBHTMLText.php#L206

Relates to https://github.com/silverstripe/silverstripe-cms/pull/2050

Steps to Reproduce

  1. Configure your own custom HTML editor field class called CustomHtmlEditorField that extends HtmlEditorField and configure it in the injector, e.g.
Injector:
  HtmlEditorField:
    class: CustomHtmlEditorField
  1. Create a generic DataObject with a 'ExampleContent' => 'HTMLText' field.
  2. In the CMS when you begin editing the DataObject you created, the default framework HtmlEditorField is instantiated and used in the form instead of your custom editor CustomHtmlEditorField.
affectv4 changpatch efforeasy impaclow typbug

Most helpful comment

We usually consider these "should use injector" changes as non-breaking bug-fixes. You should be fine to target 4.4 (or 4.3 if you want to affect any future patch releases for the 4.3 line too).

All 2 comments

QQ: When issuing a PR, should this be submitted against the latest dot release (e.g. 4.4) or against 4?

We usually consider these "should use injector" changes as non-breaking bug-fixes. You should be fine to target 4.4 (or 4.3 if you want to affect any future patch releases for the 4.3 line too).

Was this page helpful?
0 / 5 - 0 ratings