Problem / Motivation
- Drupal 9.0.6 (stable)
- PHP 7.4
- Scheduler 1.3
- Scheduler content moderation integration 1.3
- Install in different language (DE/DK/etc.) without English
When editing a node with scheduler enabled, I get the following Warnings & Notices:
Notice: Undefined offset: 0 in scheduler_content_moderation_integration_scheduler_hide_publish_on_field() (line 213 of modules/contrib/scheduler_content_moderation_integration/scheduler_content_moderation_integration.module).
scheduler_content_moderation_integration_scheduler_hide_publish_on_field(Array, Object, Object) (Line: 89)
scheduler_form_node_form_alter(Array, Object, 'node_tender_edit_form') (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'node_tender_edit_form') (Line: 838)
Notice: Trying to access array offset on value of type null in scheduler_content_moderation_integration_scheduler_hide_publish_on_field() (line 213 of modules/contrib/scheduler_content_moderation_integration/scheduler_content_moderation_integration.module).
scheduler_content_moderation_integration_scheduler_hide_publish_on_field(Array, Object, Object) (Line: 89)
scheduler_form_node_form_alter(Array, Object, 'node_tender_edit_form') (Line: 539)
Warning: array_diff_key(): Expected parameter 1 to be an array, null given in scheduler_content_moderation_integration_scheduler_hide_publish_on_field() (line 213 of modules/contrib/scheduler_content_moderation_integration/scheduler_content_moderation_integration.module).
scheduler_content_moderation_integration_scheduler_hide_publish_on_field(Array, Object, Object) (Line: 89)
scheduler_form_node_form_alter(Array, Object, 'node_tender_edit_form') (Line: 539)
Warning: count(): Parameter must be an array or an object that implements Countable in scheduler_content_moderation_integration_scheduler_hide_publish_on_field() (line 214 of modules/contrib/scheduler_content_moderation_integration/scheduler_content_moderation_integration.module).
scheduler_content_moderation_integration_scheduler_hide_publish_on_field(Array, Object, Object) (Line: 89)
scheduler_form_node_form_alter(Array, Object, 'node_tender_edit_form') (Line: 539)
Comments
Comment #2
s_bhandari commentedNot able to reproduce the issue for the same version. Could you please help to give some more details or steps in order to replicate the same?
Thanks.
Comment #3
vuilComment #4
vuilComment #5
vuilComment #6
vuilComment #7
mohit.bansal623 commentedComment #8
vuilBut that hide the form... :(
I see that the required:
exists (without
[0]) as$form['unpublish_state']['widget']['#options'].So, I recommend to replace the following:
with:
in "scheduler_content_moderation_integration.module" file.
And it works for me.
Comment #9
mohit.bansal623 commentedComment #10
mohit.bansal623 commentedComment #11
vuilI post the patch which I mentioned in comment #8
The patch is for the latest 1.3 stable version.
Comment #12
vuilI also created the same patch (#11) but for the latest 8.x-1.x-dev branch.
Comment #13
keescornelisse commentedPatch #12 works for me!
Comment #14
wellsTested and working in Drupal 9.3.5 and PHP 8.0 as well.
In that environment and with content translation enabled a
TypeErroris thrown when attempting to edit content. This appears to be a duplicate of what is reported in #3157530: array_diff_key(): Expected parameter 1 to be an array, null given in scheduler_content_moderation_integration_scheduler_hide_publish_on_field() and the patch in #12 fixes it.Comment #15
wellsComment #19
smustgrave commentedComment #20
jonathan1055 commentedChanged title to be more explicit about the actual fix.
Comment #21
jonathan1055 commentedRemove unnecessary log output, so we can see more easily what the problem was.