Problem/Motivation

The main problem is that the module is conflicting with Node form columns.
When assigning additional_settings group to scheduler_settings form element the FALSE will be interpreted as an unexistent group and if the "DISPLAY SCHEDULING OPTIONS AS" is set as "Separate fieldset" the field placement will be unavailable in UI on /admin/structure/types/manage/[:content_type]/form

Proposed resolution

Add the #group property only if this is set-up to be so.

Problem discovered by extremal

Comments

hugronaphor created an issue. See original summary.

hugronaphor’s picture

Here is the patch against 7.x-1.x ( e612b0278716bb83b5c9eeeb1b2a62dd50cc22b7 )

visabhishek’s picture

Status: Active » Needs review

Sending to testbot

hugronaphor’s picture

Adding as well the patch against 7.x-1.3 ( e21b69e990beefde45dd17bb16f2550dd01a1dcf ) as I use 7.x-1.3 version

jonathan1055’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev

Thanks for the explanation and the patch, which looks perfectly reasonable. I'd like my co-maintainer to check this with 8.x first, before any changes are committed for 7.x.
Jonathan

hugronaphor’s picture

As I'm curious about 8.x version, here is the patch against 8.x-1.x

The problem in 8.x-1.x is a bit different.

Bug 1: If publish_on or unpublish_on are disabled the fields will be shown ignoring these configurations.
Solved as: Don't check in scheduler_form_node_form_alter if publish_on or unpublish_on are disabled - it needs to go through _scheduler_form_alter in order to detect the field access.

Bug 2: If the layout is set as "Separate fieldset", the fields are not going to listen for arrangement on admin/structure/types/manage/article/form-display because the group ("details" form element) are not sorted, only fields.
Solved as: Similar to the 7.x fix - attach the fields to the group scheduler_settings only if this is set-up to be so.

Status: Needs review » Needs work

The last submitted patch, 6: scheduler-group_property_not_false-2597233-6-8_x_1_x.patch, failed testing.

hugronaphor’s picture

Assigned: hugronaphor » Unassigned
Status: Needs work » Needs review

There is an error: ERROR: No valid tests were specified.
https://dispatcher.drupalci.org/job/default/26478/console

Seems like there are no tests for 8.x version at all.

Status: Needs review » Needs work

The last submitted patch, 6: scheduler-group_property_not_false-2597233-6-8_x_1_x.patch, failed testing.

hugronaphor’s picture

OK, the 8.x patch will not pass CI as it is blocked by https://www.drupal.org/node/2594615
However, fixes like this shouldn't be blocked by unfinished Tests migration.

hugronaphor’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: scheduler-group_property_not_false-2597233-6-8_x_1_x.patch, failed testing.

pfrenssen’s picture

@hugronaphor I can confirm that we allow failing patches to be merged after review and manual testing until our test suite is ported to D8 in #2594615: Automated testing in 8.x [meta].

pfrenssen’s picture

The use cases explained in #6 are very interesting. There are some serious usability bugs there. It would maybe still be a good idea to add some test coverage for these cases.

pfrenssen’s picture

  1. +++ b/scheduler.edit.inc
    @@ -39,26 +39,31 @@ function _scheduler_form_alter(array &$form, FormStateInterface $form_state) {
    +
    +  if ($use_vertical_tabs && ($publishing_enabled || $unpublishing_enabled)) {
    

    Can you add the reasoning for this if in a line of documentation? We have the habit of documenting every switch.

  2. +++ b/scheduler.module
    @@ -110,19 +110,10 @@ function scheduler_form_node_type_form_alter(array &$form, FormStateInterface $f
    -  // Load the real code only when needed. First check that the user has
    -  // permission to use Scheduler.
    +  // Load the real code only when the user has permission to use Scheduler.
       if (\Drupal::currentUser()->hasPermission('schedule (un)publishing of nodes')) {
    -    // Check if scheduling has been enabled for this node type.
    -    /** @var \Drupal\node\NodeTypeInterface $type */
    -    $type = $form_state->getFormObject()->getEntity()->type->entity;
    -    $publishing_enabled = $type->getThirdPartySetting('scheduler', 'publish_enable', FALSE);
    -    $unpublishing_enabled = $type->getThirdPartySetting('scheduler', 'unpublish_enable', FALSE);
    -
    -    if ($publishing_enabled || $unpublishing_enabled) {
           module_load_include('inc', 'scheduler', 'scheduler.edit');
           _scheduler_form_alter($form, $form_state);
    -    }
       }
    

    Why has this been removed? Is this related to this issue?

    Not that I necessarily disagree with this simplification, but it might be better handled in a different issue. We might even get rid of the scheduler.edit.inc file completely. It now only contains this particular form alter, doesn't seem very useful any more to split this off in a separate file.

    edit: Oh I see, you have explained the reasoning in comment #6.

pfrenssen’s picture

Assigned: Unassigned » pfrenssen

Assigning to me to address the remarks from #15 and commit.

The problem for the non-scheduled content types was reported in #2625572: Admin setting 'Enable content type for scheduler' is ignored, but since this is fixed here as a by-product of fixing the #group property I have marked that issue as a duplicate of this issue.

hugronaphor’s picture

Yes @pfrenssen, it would be better if you'll sort out this problem.
I remember by digging into this issue I spotted others, so I'll report it in another ticket after this one is solved.

  • pfrenssen committed f770822 on 8.x-1.x authored by hugronaphor
    Issue #2597233 by hugronaphor, pfrenssen: The FALSE value for #group...
pfrenssen’s picture

Assigned: pfrenssen » Unassigned
Status: Needs work » Fixed

Added the documentation to the switch and committed. Thanks a lot for fixing this!

hugronaphor’s picture

Awesome.
What about the 7.x fix?

jonathan1055’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev
Status: Fixed » Patch (to be ported)

Yes, I will do the 7.x fix. I think the patch in #2 looks OK?

jonathan1055’s picture

Status: Patch (to be ported) » Fixed

Tested manually and via simpltest. All fine.
Now committed to 7.x. Thanks hugronaphor for the original patch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.