The global setting Ui has been ported but it's not dynamic yet and not actually used yet.

Right now all the config form is hard-coded, and new plugins cannot be discovered.

CommentFileSizeAuthor
#68 ultimate_cron-n2692781-68.patch55.01 KBdamienmckenna
#66 ultimate_cron-n2692781-66.patch55.01 KBdamienmckenna
#66 ultimate_cron-n2692781-66.interdiff.txt517 bytesdamienmckenna
#64 ultimate_cron-n2692781-64.patch55.01 KBdamienmckenna
#64 ultimate_cron-n2692781-64.interdiff.txt510 bytesdamienmckenna
#62 ultimate_cron-n2692781-62.patch55.02 KBdamienmckenna
#61 interdiff.2692781.60-61.txt723 bytessuper_romeo
#61 2692781-61.ultimate_cron.Make-global-setting-ui-dynamic-and-use-it_DIRTY_FIX.patch55.5 KBsuper_romeo
#56 2692781-56.patch55.06 KBsuzymasri
#56 interdiff-2692781-55-56.txt777 bytessuzymasri
#55 2692781-55.patch54.67 KBsuzymasri
#52 2692781-52.patch54.94 KBsuzymasri
#51 2692781-51.patch54.95 KBsuzymasri
#49 2692781-49.patch54.55 KBsuzymasri
#48 Screenshot from 2019-05-15 15-06-41.png27.33 KBmanuel garcia
#48 corelogger-do-not-test.patch2.24 KBmanuel garcia
#46 2692781-46.patch56.99 KBmanuel garcia
#44 2692781-44.patch55.66 KBsuzymasri
#43 interdiff.txt72.78 KBsuzymasri
#43 2692781-42.patch72.83 KBsuzymasri
#41 2692781-41.patch55.37 KBrobertshell22
#40 interdiff.txt922 byteskmoll
#40 2692781-40.patch55.49 KBkmoll
#39 2692781-39.patch55.33 KBbadjava
#38 2692781-38-interdiff.txt1.17 KBberdir
#38 2692781-38.patch56.16 KBberdir
#33 2692781-33.patch56.22 KBnaveenvalecha
#29 straight-reroll-2692781-28.patch57.17 KBnaveenvalecha
#25 global_setting_ui-2692781-25.patch57.67 KBabhishek-anand
#23 global_setting_ui-2692781-23.patch91.31 KBabhishek-anand
#21 interdiff.txt22.93 KBabhishek-anand
#21 global_setting_ui-2692781-21.patch60 KBabhishek-anand
#20 Screenshot 2016-03-27 11.11.49.png124.07 KBtedbow
#19 global_setting_ui-2692781-19.patch48.46 KBtedbow
#17 global_setting_ui-2692781-17.patch48.33 KBtedbow
#11 global_setting_ui-2692781-11.patch30.17 KBtedbow
#6 interdiff.txt7.38 KBabhishek-anand
#6 global_setting_ui-2692781-6.patch15.07 KBabhishek-anand
#2 global_setting_ui-2692781-2.patch14.39 KBabhishek-anand
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

abhishek-anand created an issue. See original summary.

abhishek-anand’s picture

Status: Active » Needs review
StatusFileSize
new14.39 KB

Status: Needs review » Needs work

The last submitted patch, 2: global_setting_ui-2692781-2.patch, failed testing.

abhishek-anand’s picture

Title: Make global setting ui dynamic yet and use it » Make global setting ui dynamic and use it
Status: Needs work » Needs review
abhishek-anand’s picture

Status: Needs review » Needs work
abhishek-anand’s picture

StatusFileSize
new15.07 KB
new7.38 KB
abhishek-anand’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: global_setting_ui-2692781-6.patch, failed testing.

abhishek-anand’s picture

I am not sure if this is the correct way of including the submitConfigurationForm method from the plugins.

      $form['#submit'][] = $plugin->getPluginDefinition()['class'] . '::submitConfigurationForm';

There is a schema error when the tests are run locally, it shows in the Verbous message:

Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for ultimate_cron.job.system_cron with the following errors: ultimate_cron.job.system_cron:logger.configuration.database missing schema in Drupal\Core\Config\Testing\ConfigSchemaChecker->onConfigSave() (line 98 of core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php).

config.factory need to be injected in the CacheLogger and DatabaseLogger, this will be done once all tests are passing

Similar changes are required to be made in all plugins, idea is to get one right and then do the rest accordingly.

tedbow’s picture

I am working on the schema test problems.

@abhishek-anand I have to stop for the night but if you want to see what I working on: https://github.com/tedbow/ultimate_cron

I think my changes to modules/contrib/ultimate_cron/config/schema/ultimate_cron.schema.yml

are correct

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new30.17 KB

Ok I hope I didn't stray to far from the issue but I think the schema for the plugins needed to be updated to make this work.

I will comment on that patch after I upload it

tedbow’s picture

+++ b/config/schema/ultimate_cron.schema.yml
@@ -134,37 +137,25 @@ ultimate_cron.job.*:
     logger:
-      type: mapping
-      label: 'Scheduler'
-      mapping:
-        id:
-          type: string
-          label: 'Logger ID'
-        configuration:
-          type: ultimate_cron.plugin.logger.[%parent.id]
+      type: ultimate_cron.plugin.logger.[id]
+      label: 'Logger'

In the schema for each of the plugins on the job we just need to tell the schema what type of plugin it is going to reference. We don't actually need to store the configuration here. The schema will figure it out by the type.

So the job entity will not be
$job->scheduler[configuration][rules][0]
but
$job->scheduler[rules][0]

An example of this in core is block.schema.yml in how it references condition plugins

visibility:
      type: sequence
      label: 'Visibility Conditions'
      sequence:
        type: condition.plugin.[id]
        label: 'Visibility Condition'

It is not exactly the same because blocks can have multiple condition plugins but it is same idea in that the block schema just has a reference to a condition plugin and the actual configuration is defined in the condition schema.

tedbow’s picture

Status: Needs review » Needs work

The patch also added a new test module ultimate_cron_plugin_test

It simply provides a new schedule plugin that extends Simple called Simpler.

I added a test to check the "simpler" CronJobFormTest that new plugin shows up in the job edit form.

I did not add a test the plugin show up here "admin/config/system/cron/settings/scheduler"
and just noticed that it doesn't so it is not working fully yet.

Since this issue is to "Make global setting ui dynamic " I am going to set it to needs work because the new plugin should just show up there correct?

tedbow’s picture

@abhishek-anand just wanted to give you an update if you looking at this

I am working here https://github.com/tedbow/ultimate_cron and should be able upload patch later.

I am changing the general settings forms to actual use the plugin configuration forms.

berdir’s picture

I'll try to have a look at the ultimate cron issues over the weekend. Thanks for working on this.

One thing I'm not sure about yet is how those global settings should actually be used. With the current config entity, each entity has its own storage anyway and has all settings duplicate there, so those global settings could at best be used for new sensors.

We have a similar but much simpler concept in https://www.drupal.org/project/sharemessage, there each config entity has a checkbox whether the global settings should be applied or not. We could have the same here for each plugin type, and if "[ ] Override default settings" isn't checked, then it would fall back to the global settings.

Thoughts?

tedbow’s picture

Sorry I am starting to work on this module without probably having the best idea of how these settings are working

there each config entity has a checkbox whether the global settings should be applied or not.

@Berdir this would seem to make sense but we would want to change the forms like SchedulerSettingsForm.

Right now this forms shows the configuration form for all scheduler plugins. This could be useful if we want to keep a default for each scheduler plugin type.
Say if you editing a CronJob and you switch from Simple to Crontab scheduler it could load the defaults from what was set for Crontab SchedulerSettingsForm.

But this doesn't actually set which scheduler should be the default scheduler.

Maybe we should have dropdown at the top of all the forms that extend PluginSettingsFormBase that would let you pick which plugin should be the default for that type.

tedbow’s picture

StatusFileSize
new48.33 KB

Here is another patch.

I am still trying to figure out schema changes so test will fail for now

berdir’s picture

I'm not sure, but I'd be OK with only having global default configuration for a single default type. The only thing that is usually customized is scheduling.

Yes, we'd definitely had to change the form, that's OK. I would even get the type from the default settings because otherwise you can't really change the default type. We can also do that part in a separate issue.

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new48.46 KB

Ok here is cleaned up patch. That should pass.

tedbow’s picture

Issue summary: View changes
StatusFileSize
new124.07 KB

Looking at the D7 code it does look like it is grabbing the defaults for a specific plugin when in the cron job form.

From D7 \UltimateCronPlugin::jobSettingsForm :

// Default values for current selection. If selection differs from current
    // job, then take the job into account.
    $defaults = $current_plugin->name == $original_plugin ? $job->settings : array();
    $defaults += $current_plugin->getDefaultSettings($job);

You can see in this D7 screenshot of the cronjob form

I had just switched the cronjob to "cache" logger. In d7 you can that for each individual setting you can leave it blank for the default
For example for the cached in bin

Select which cache bin to use for storing logs. (Blank = my_new_default).

I had just changed the global default for bin to "my_new_default"

You can also see that when I choose the logger a can choose Database or Cache or the "Default(Database)"

Presumably if I choose "Default(Database)" it would just follow the default plugin for logger.

But if I choose "Default(Database)" it still gives me the option to override individual settings for the Database logger.

There is also "change default settings" like on each of the plugin forms on the CronJob form.

I don't have a lot of experience administering this module to a solid a opinion on if we should keep the D7 functionality or simplify it.

If it was my module I would vote for simplifying it.

re @Bedir's comment

I'm not sure, but I'd be OK with only having global default configuration for a single default type. The only thing that is usually customized is scheduling.

So if I am understanding this then on admin/config/system/cron/settings/logger instead of showing a tab or each Logger plugin we would just have

  1. A dropdown to select the default logger plugin
  2. Dynamically show the settings form for the chosen logger plugin

Then on an individual cronjob form in the Logger section we would show checkbox that would say "Use Default Logger" checked by default and show in markup what those default settings are.

If they uncheck "Use Default Logger" then we show the dropdown to choose the logger plugin and the settings form for the Logger Plugin they choose.

@Bedir let me know if that sounds right and you want me to implement that.

abhishek-anand’s picture

StatusFileSize
new60 KB
new22.93 KB

@tedbow I have made following changes in previous patch:

  1. PluginSettingsFormBase::submitForm how calls $plugin->submitConfigurationForm which allows plugins to handle the submission in its own way. This is specially useful for pluggins defined outside this module, to be able to save the data in its own schema.
  2. Some form elements were missing in SerialLauncher which has been added
  3. Removed poorman_keepalive from SerialLauncher as this is not required anymore as per https://www.drupal.org/node/2698419#comment-11041717
  4. Added submitConfigurationForm for each plugin
  5. Corrected some formatting issues
berdir’s picture

Assigned: abhishek-anand » Unassigned
Status: Needs review » Needs work

Fairly sure this needs a reroll now.

Re #20. Yes, that's exactly what I was suggesting.

I should be able to find time to work a bit on this myself unless you get to it first. If you do, make sure to leave a note on the issue and/or assign it to you. I'm unassigning for now.

abhishek-anand’s picture

Status: Needs work » Needs review
StatusFileSize
new91.31 KB

re-rolling that patch #21

Status: Needs review » Needs work

The last submitted patch, 23: global_setting_ui-2692781-23.patch, failed testing.

abhishek-anand’s picture

Status: Needs work » Needs review
StatusFileSize
new57.67 KB

Update previous patch.

berdir’s picture

Issue tags: +Needs tests

Considering how much this is doing, I think we also need quite some tests. That would also help to understand what the patch is doing, by following the steps in the test.

berdir’s picture

Status: Needs review » Needs work

First review, getting familar with the work here..

  1. +++ b/config/install/ultimate_cron.settings.yml
    @@ -11,23 +11,36 @@ queue:
         threads: 4
         threshold: 10
    +default_plugins:
    +  launcher: serial
    +  scheduler: simple
    +  logger: database
     launcher:
    -  thread: 'any'
    -  max_threads: 1
    -  lock_timeout: 3600
    -  max_execution_time: 3600
    +  serial:
    +    id: 'serial'
    

    Per my suggestions above, I'd expect that the each plugin type (launcher) etc. will have just store configuration for one plugin, the one that was selected as default. The default will be stored in the id that you have now.

    The default_plugins part will then go away again.

  2. +++ b/config/schema/ultimate_cron.schema.yml
    @@ -45,73 +45,37 @@ ultimate_cron.settings:
    -              label: Maximum number of logs to keep
    +      type: sequence
    +      label: Logger Settings
    +      sequence:
    +        type: ultimate_cron.plugin.logger.[id]
    +        label: Launcher
    

    This will then change from a sequence of that type to just that type.

  3. +++ b/config/schema/ultimate_cron.schema.yml
    @@ -131,37 +95,25 @@ ultimate_cron.job.*:
    +    uuid:
    +      type: string
    +      label: 'UUID'
         rules:
    

    not sure what the uuid is for?

  4. +++ b/src/CronJobDiscovery.php
    @@ -21,13 +22,19 @@ class CronJobDiscovery {
    +   * @var \Drupal\Core\Config\ConfigFactoryInterface
    +   */
    +  protected $configFactory;
    +
    +  /**
        * CronJobDiscovery constructor.
        *
        * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
        *   The module handler.
        */
    -  public function __construct(ModuleHandlerInterface $module_handler) {
    +  public function __construct(ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory) {
         $this->moduleHandler = $module_handler;
    +    $this->configFactory = $config_factory;
       }
     
       /**
    @@ -57,6 +64,14 @@ class CronJobDiscovery {
    
    @@ -57,6 +64,14 @@ class CronJobDiscovery {
             'callback' => $info['callback'],
           );
     
    +      /*
    +      // Set defaults
    +      $config = $this->configFactory->get('ultimate_cron_general_settings');
    +      $values['scheduler'] = [
    +        'id' => 'simple',
    +        'rule' => '',
    +      ];
    

    this needs a reroll now since this class now has the config factory injected more or less just like this.

    Also, given my suggestions, I think this will change to instead check the defaults at runtime unless an override flag is set.

  5. +++ b/src/Form/LoggerSettingsForm.php
    @@ -1,20 +1,23 @@
     /**
    + * @file
      * Contains \Drupal\ultimate_cron\Form\LoggerSettingsForm.
    

    classes no longer need @file. I'd rather not touch it in existing issues, but if you do, just remove it instead of fixing it.

    I think the best thing would be a separate issue that does nothing but remove all @file docblocks in classes.

  6. +++ b/src/Form/LoggerSettingsForm.php
    @@ -1,20 +1,23 @@
    +  const CRON_PLUGIN_TYPE = 'logger';
    +  /**
    +   * {@inheritdoc}
    

    missing empty line.

  7. +++ b/src/Form/PluginSettingsFormBase.php
    @@ -0,0 +1,151 @@
    +/**
    + * @file
    + * Contains \Drupal\ultimate_cron\Form\PluginSettingsFormBase.
    + */
    

    yep, new classes shouldn't have it.

  8. +++ b/src/Form/PluginSettingsFormBase.php
    @@ -0,0 +1,151 @@
    +  /**
    +   * The type of plugin this form should handle.
    +   *
    +   * @var string
    +   */
    +  const CRON_PLUGIN_TYPE = '';
    

    we can't really enforce that a constant is set/overriden.

    It requires a bit more glue code, but we could do so with an abstract protected method that subclasses have to implement.

    If these classes really all end up doing nothing, we could even pass it as an argument to the same non-abstract form class?

  9. +++ b/src/Form/PluginSettingsFormBase.php
    @@ -0,0 +1,151 @@
    +   */
    +  public static function create(ContainerInterface $container) {
    +    return new static(
    +      $container->get('config.factory'),
    +      $container->get('plugin.manager.ultimate_cron.' . static::CRON_PLUGIN_TYPE)
    +    );
    

    We couldn't do this then as it would be too late, though. so not sure about that yet.

naveenvalecha’s picture

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

Straight reroll of #25 after #2704543: Implement cron queue processing
Assigning to myself to work on #27

naveenvalecha’s picture

StatusFileSize
new57.17 KB

The last submitted patch, 17: global_setting_ui-2692781-17.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 29: straight-reroll-2692781-28.patch, failed testing.

The last submitted patch, 29: straight-reroll-2692781-28.patch, failed testing.

naveenvalecha’s picture

Assigned: naveenvalecha » Unassigned
Status: Needs work » Needs review
StatusFileSize
new56.22 KB

unassigning from myself. I debugged it but did not found the schema exception error. So leaving this open for others to pick.

Status: Needs review » Needs work

The last submitted patch, 33: 2692781-33.patch, failed testing.

abhishek-anand’s picture

Assigned: Unassigned » abhishek-anand

The last submitted patch, 25: global_setting_ui-2692781-25.patch, failed testing.

abhishek-anand’s picture

Assigned: abhishek-anand » Unassigned
berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new56.16 KB
new1.17 KB

This fixes the test fails.

I'm not convinced by the configuration change. So far, I don't understand why it is necessary. The mentioned example in #12 doesn't explain that. Will talk to @tedbow about it.

Yes, it is possible, but the mentioned block config entity actually also has a different kind of example, with the main plugin + settings, which are separate keys. I don't really like to merge those things together, the bugfix shows how things can get more complicated if you do that.

badjava’s picture

StatusFileSize
new55.33 KB

I re-rolled this patch so it will apply; it seems there were quite a few changes elsewhere since this was last worked on.

kmoll’s picture

StatusFileSize
new55.49 KB
new922 bytes

I've updated the patch to pass tests. It was missing some ids in the install config, and I updated one schema definition.

robertshell22’s picture

StatusFileSize
new55.37 KB

Here's a new patch for the 8.x-2.0-alpha2 release.

Status: Needs review » Needs work

The last submitted patch, 41: 2692781-41.patch, failed testing. View results

suzymasri’s picture

StatusFileSize
new72.83 KB
new72.78 KB

Patch #40 doesn't apply on 8.x-2.0-alpha4.
Rerolled patch attached.

suzymasri’s picture

StatusFileSize
new55.66 KB
manuel garcia’s picture

Status: Needs work » Needs review
manuel garcia’s picture

StatusFileSize
new56.99 KB

#44 not applying against 8.x-2.x, rerolled.

manuel garcia’s picture

I'm noticing that the configuration the logger gets when a cron job is executed are just the defaults, its ignoring whatever you save in the configuration form.

Note that his also happens currently on HEAD, though this patch fails to address this still.

manuel garcia’s picture

FWIW, attaching a patch adding a new logger plugin which is an attempt to use core's logger for those that need to stream logs somewhere else.

With #46 applied I am able to have it registered, shows up in the admin ui, and can be selected as default. However it doesnt seem to be getting called when a cron job is executed.

suzymasri’s picture

StatusFileSize
new54.55 KB

Rerolled patch #46, no longer applies on 8.x-2.x.

Status: Needs review » Needs work

The last submitted patch, 49: 2692781-49.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

suzymasri’s picture

StatusFileSize
new54.95 KB

Corrected patch attached.

suzymasri’s picture

StatusFileSize
new54.94 KB
manuel garcia’s picture

We're using this patch and get these schema errors, not 100% sure its because of the patch but it looks like it?

Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for
ultimate_cron.job.simplenews_cron with the following errors:
ultimate_cron.job.simplenews_cron:scheduler.configuration missing schema,
ultimate_cron.job.simplenews_cron:launcher.configuration missing schema,
ultimate_cron.job.simplenews_cron:logger.configuration missing schema
anthonylindsay’s picture

Looks like this is now committed. Patch won't apply, and when I compare it to files, it looks like the changes are already there.

suzymasri’s picture

StatusFileSize
new54.67 KB

Patch #52 is not applying against 8.x-2.x. Rerolled.

suzymasri’s picture

StatusFileSize
new777 bytes
new55.06 KB

Corrected scheduler field name in CronJobFormTest.php, interdiff attached.

super_romeo’s picture

Status: Needs work » Needs review
super_romeo’s picture

The values that I saved in /admin/config/system/cron/settings/launcher not used anywhere.
Always used SerialLauncher::defaultConfiguration().

super_romeo’s picture

Status: Needs review » Needs work
super_romeo’s picture

I hided patches because dorgflow tryes to apply them all.

super_romeo’s picture

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new55.02 KB

#56 rerolled.

Status: Needs review » Needs work

The last submitted patch, 62: ultimate_cron-n2692781-62.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new510 bytes
new55.01 KB

This should fix the info file problem.

Status: Needs review » Needs work

The last submitted patch, 64: ultimate_cron-n2692781-64.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new517 bytes
new55.01 KB

Does this fix the tests?

damienmckenna’s picture

@super_romeo: The settings form is saving correctly for me, could you please try again?

Does this need more tests? Or is this enough?

damienmckenna’s picture

StatusFileSize
new55.01 KB

Rerolled.

Status: Needs review » Needs work

The last submitted patch, 68: ultimate_cron-n2692781-68.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

socialnicheguru’s picture

Needs reroll for ultimate_cron 2.0@alpha8

berdir’s picture

Converted to a merge request and fix tests, but once again, I'm not convinced by what I see here.

Fundamentally, the whole thing still doesn't do anything. The default values are not used when creating new jobs. And this still does change the configuration structure of jobs, which would break existing configuration. Untangling that would require quite a bit of work.

Instead, I created #3489476: Disable unused global settings forms and other dead settings plugin classes as an intermediate step to unblock the beta release.