Recently I stumbled across an issue with the Craft Content Templates plugin, where upon trying to apply a content template to a new entry, the process would fail with an unknown error and leave duplicated template entries in the Content Templates tab.
Quickly I stumbled upon the issue on line 243 of the CpController: when creating a new entry on any site that isn't the current site (as specified in getElementById), the $element variable would end up being null, thus causing a Null Pointer Exception.
This Pull Request amends the functionality of the apply action by explicitly looking up the 'site' query parameter as it will be properly set by the Craft admin panel when creating a new entry, and adds an extra check to the $element variable in case it is still null.
Please feel free to suggest any required changes needed.
Recently I stumbled across an issue with the Craft Content Templates plugin, where upon trying to apply a content template to a new entry, the process would fail with an unknown error and leave duplicated template entries in the Content Templates tab. Quickly I stumbled upon the issue on line 243 of the CpController: when creating a new entry on any site that isn't the current site (as specified in getElementById), the
$element
variable would end up beingnull
, thus causing a Null Pointer Exception.This Pull Request amends the functionality of the apply action by explicitly looking up the 'site' query parameter as it will be properly set by the Craft admin panel when creating a new entry, and adds an extra check to the
$element
variable in case it is still null.Please feel free to suggest any required changes needed.