backdrop-contrib / scheduler

Allows content to be published and unpublished on specified dates. (Note: a simplified version of the publishing functionality is now in Backdrop core.)
GNU General Public License v2.0
0 stars 1 forks source link

Causes failure when installing another module #22

Open onyxnz opened 1 year ago

onyxnz commented 1 year ago

image because is_array is not checked first.

argiepiano commented 1 year ago

You've actually found a bug in Backdrop's core! The form callback installer_browser_install_button_form() in installer.pages.inc should not assign $form['#attributes']['class'] = 'installer-browser-install-button-form';, but rather $form['#attributes']['class'][] = 'installer-browser-install-button-form';

Will open an issue in the core queue.

argiepiano commented 1 year ago

Issue https://github.com/backdrop/backdrop-issues/issues/6168

argiepiano commented 1 year ago

In addition to fixing the issue in core, I believe there are better ways for this module to test that the form being altered is the node_form. For starters, instead of checking for a specific class, which is bound to change at any point, it should use a hook_form_FORM_ID_alter() instead.

/**
 * Implements hook_form_FORM_ID_alter().
 */
function scheduler_form_node_form_alter(&$form, $form_state) {
  // Load the real code only when needed. First check that the user has permission to use Scheduler.
  if (user_access('schedule publishing of nodes')) {
    // Check if scheduling has been enabled for this node type.
    $publishing_enabled = config_get('node.type.' . $form['type']['#value'], 'scheduler_publish_enable') == 1;
    $unpublishing_enabled = config_get('node.type.' . $form['type']['#value'], 'scheduler_unpublish_enable') == 1;
    if ($publishing_enabled || $unpublishing_enabled) {
      module_load_include('inc', 'scheduler', 'scheduler.edit');
      _scheduler_form_alter($form, $form_state);
    }
  }
}

The way it's done it's probably legacy code from Drupal 6.

djzwerg commented 1 year ago

If I try to install another module while scheduler is active I'll get this error message:

TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in in_array() (line 194 of /mypath/modules/scheduler/scheduler.module).

Does this belong to the same reason or should I create a new issue @argiepiano ?

argiepiano commented 1 year ago

That's the same bug. The fix has not been yet merged into Backdrop.

laryn commented 1 year ago

The core issue is merged. RE: https://github.com/backdrop-contrib/scheduler/issues/22#issuecomment-1630749173 -- I agree!