getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.27k stars 167 forks source link

When debug is set to false and there is only one blueprint available, Kirby uses the default blueprint instead of the defined blueprint #3644

Closed texnixe closed 3 years ago

texnixe commented 3 years ago

Describe the bug
If a section only allows one template and the debug option is set to false in config, the default template is used instead of the defined template in Kirby 3.6.0-alpha.4 , because $template is then set to null in dialogs.php instead of being assigned the template name.

To Reproduce
Steps to reproduce the behavior:

  1. In a 3.6-alpha-4 StarterKit, set 'debug' => false in config
  2. Open the Panel and create a new photography or notes subpage.
  3. Notice how it is created with the default template instead of the album or note templates.

Expected behavior
The defined blueprint should be used.

Kirby Version
3.6.0-alpha.4

lukasbestle commented 3 years ago

Affected lines:

https://github.com/getkirby/kirby/blob/a337eb974b2515016cce0103203a7df68aa24aab/config/areas/site/dialogs.php#L276-L283

To be honest I don't understand that if.

distantnative commented 3 years ago

The line is there to hide the template select field if only one template option is available anyways (except when in debug mode, then always show the field).

But sounds like something in the logic of assigning what the one-and-only available value should be is off.

lukasbestle commented 3 years ago

OK, yeah, that makes sense.

Then the issue is in this line:

https://github.com/getkirby/kirby/blob/a337eb974b2515016cce0103203a7df68aa24aab/config/areas/site/dialogs.php#L311

There should be logic here to use the configured template if there was no template field in the form. Probably it's enough to just have a fallback to the first available template if get('template') is empty. Then we don't need to duplicate the entire logic from the load method.

BTW: Where do we validate that the get('template') value is valid and allowed? Wouldn't it be possible at the moment to pass a completely different non-allowed template in the request?

bastianallgeier commented 3 years ago