Comments

jazio’s picture

Assigned: Unassigned » jazio
jazio’s picture

Status: Active » Needs work
StatusFileSize
new1.58 KB

I made the first iteration.

jazio’s picture

StatusFileSize
new14.82 KB
jazio’s picture

Status: Needs work » Needs review

I've replaced the occurences of variable_get. Still some variables coming from other modules like Date have unknown location and need reviewed.

legovaer’s picture

Status: Needs review » Needs work

After analyzing your patch, I think we still have some work to do. The approach is good, but we still need to rework some parts. In general, I think we need to re-think about the naming of all the variables. Using variables with more then 1 underscore can be added into a nested parent variable. Here is an overview of my detailed comments;

Weird parameter provided in config() method.

Maybe this is a typo? I think it needs to be replaced with date.
if (\Drupal::config('??')->get('configurable_timezones')) { ...

Usage of scheduler.schema

I noticed that you are using scheduler.schema instead of scheduler.settings. This needs to be changed, otherwise Drupal won't be able to interact with the configuration file (scheduler.settings.yml).

Wrong usage of the config parameter.

In some parts of your code you are using the wrong configuration parameter structure. Instead of a . (dot), you're using a _ (underscore).
$create_publishing_revision = \Drupal::config('scheduler_schema')->get('scheduler_publish_revision_' . $n->type) == 1;
Should become
$create_publishing_revision = \Drupal::config('scheduler.settings')->get('scheduler_publish_revision_' . $n->type) == 1;

Investigation of vertical tabs

You added a comment saying that we have to investigate the yaml file of the vertical tabs. This seems unnecessary to me because we have to store this as a variable inside our variables.
+ $use_vertical_tabs = \Drupal::config('vertical_tabs')->get('use_vertical_tabs_' . $form['type']['#value']);
Should become;
+ $use_vertical_tabs = \Drupal::config('scheduler.schema')->get('use_vertical_tabs_' . $form['type']['#value']);

jazio’s picture

Status: Needs work » Needs review
StatusFileSize
new14.77 KB

Thanks for the detailed analysis. I posted a new iteration.

My questions are:

1. You mention will be using only one setting yml file and that will be always: scheduler.settings.yml. In this case in your latest suggestion is it a typo: 'scheduler.schema'?
2. What is the real purpose of scheduler.schema?
3. I expect I need to fill in scheduler.settings with default values of the all variables over the project.
How should be handled the defaults for variables like use_vertical_tabs_' . $form['type']['#value'] ? You mention this 'Using variables with more then 1 underscore can be added into a nested parent variable'. Could you point me to a module where I can see this?

pfrenssen’s picture

Status: Needs review » Postponed

Thanks a lot for working on this!

  1. +++ b/scheduler.admin.inc
    @@ -250,7 +250,8 @@ function theme_scheduler_timecheck($variables) {
    +  //@todo revisit this when date module is being ported
    +  $date_default_timezone = \Drupal::config('date')->get('default_timezone');
    

    Start comments with a capital letter and end with a period.

  2. +++ b/scheduler.admin.inc
    @@ -271,7 +272,7 @@ function theme_scheduler_timecheck($variables) {
    -  if (variable_get('configurable_timezones', 1)) {
    +  if (\Drupal::config('date')->get('configurable_timezones')) {
    

    Can you add the @todo here as well so we don't forget to look at it again later?

Most of the other conversions are actually quite special, they are using the new Third Party Settings.

The issue summary is wrong. These can not be converted straight to Config. My apologies, I turned the advice from the Drupal Module Upgrader module into separate issues without verifying them.

We will first have to convert these forms to form classes, and then include the ThirdPartySettingsTrait. This can be quite interesting.

I will mark this as postponed until the forms are converted. I will make issues to convert all the forms.

jazio’s picture

StatusFileSize
new14.83 KB

Tiny fix over @todo comments.

jazio’s picture

Assigned: jazio » Unassigned
jonathan1055’s picture

Status: Postponed » Needs work

#2418527: Replace variable_set() with config has landed so this isssue can now be unblocked.

legovaer’s picture

Status: Needs work » Needs review
StatusFileSize
new9.09 KB

I was not able to apply the patch from #6. Already too many changes went in after this patch has been created. I created a new patch from scratch.

Status: Needs review » Needs work

The last submitted patch, 11: 2418523-11-scheduler.patch, failed testing.

pfrenssen’s picture

  1. +++ b/scheduler.cron.inc
    @@ -139,7 +139,7 @@ function _scheduler_unpublish() {
    -    $create_unpublishing_revision = variable_get('scheduler_unpublish_revision_' . $node->getType(), 0) == 1;
    +    $create_unpublishing_revision = \Drupal::config('scheduler.settings')->get('scheduler_unpublish_revision_' . $node->getType(), 0) == 1;
    

    All the configuration which is node type specific is now stored as ThirdPartySettings. This seems to cover almost all cases in the patch.

joekers’s picture

Assigned: Unassigned » joekers
joekers’s picture

Status: Needs work » Needs review
StatusFileSize
new9.09 KB

I have updated most of patch in comment #11 to use the ThirdPartySettings. The only thing I'm not sure on is where I've used it in scheduler_feeds_processor_targets_alter() and scheduler_i18n_sync_options()?

Status: Needs review » Needs work

The last submitted patch, 15: replace_variable_get-2418523-15.patch, failed testing.

legovaer’s picture

@@ -536,9 +537,9 @@ function scheduler_field_extra_fields() {
+ $publishing_enabled = $type->type->entity->getThirdPartySetting('scheduler', 'scheduler_publish_enable', 0);
+ $unpublishing_enabled = $type->type->entity->getThirdPartySetting('scheduler', 'scheduler_unpublish_enable', 0);
+ $use_vertical_tabs = $type->type->entity->getThirdPartySetting('scheduler', 'scheduler_use_vertical_tabs', 1);

We should store this entity inside a local variable. Something like:

$entity = $type->type->entity;
@@ -579,17 +580,14 @@ function scheduler_preprocess_node(&$variables) {
if ($entity_type->getThirdPartySetting('scheduler', 'scheduler_publish_enable')) {

I suggest to keep this as a separate variable. Now that I'm reviewing it myself, I notice that it is hard to read.

diff --git a/scheduler.test b/scheduler.test
index 87f601b..6db0c9c 100644
@@ -176,6 +176,7 @@ class SchedulerFunctionalTest extends SchedulerTestBase {

Testcases are getting fixed in #2594615: Automated testing in 8.x [meta] so it's not necessary to update them in this issue.

joekers’s picture

StatusFileSize
new7.88 KB

Thanks for the feedback :)

Not sure how the changes to scheduler.test crept in there but I've removed them and made the other changes in this patch.

joshi.rohit100’s picture

Status: Needs work » Needs review

The last submitted patch, 11: 2418523-11-scheduler.patch, failed testing.

The last submitted patch, 15: replace_variable_get-2418523-15.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 18: replace_variable_get-2418523-18.patch, failed testing.

jonathan1055’s picture

Thanks for working on this patch. I had a look and was just wondering the correct way to get thirdparty settings. In scheduler.module you have

$type->getThirdPartySetting('scheduler', 'scheduler_publish_past_date', 'error')

but it scheduler.cron.inc you have

$node->type->entity->getThirdPartySetting('scheduler', 'unpublish_revision', FALSE)

So the questions is whether the extra prefix 'scheduler' is needed in the second parameter or not?

I think that this problem may be hindering the test results in #2594615: Automated testing in 8.x [meta] so it would be good to get this sorted.

joekers’s picture

Yeah it shouldn't have the 'scheduler' prefix. I'll update the patch as soon as I get chance.

joekers’s picture

StatusFileSize
new7.73 KB

I've removed the 'scheduler' prefix on all of the getThirdPartySetting calls.

As I said in #15, I'm not sure on where I've used it in scheduler_feeds_processor_targets_alter() and scheduler_i18n_sync_options(), if we have access to getThirdPartySetting method? But the other guys have reviewed it so I'm guessing it's ok.

joshi.rohit100’s picture

Status: Needs work » Needs review
jonathan1055’s picture

This all looks good in general, just a few points:

  1. in rules.inc return ($node->type->entity->getThirdPartySetting('scheduler', 'publish_enable', 0) == 1); we can remove the == 1 as the value returned will be boolean.
  2. It would help readability and reuse if we had consistent use of name for $type or $entity object when created by us. Maybe $entity is the better choice as it is derived from $node->type->entity
  3. On a general point, if we have default values defined in the schema, do we actually need to supply a default in the various calls?

But overall this is good and I'd like to get it committed soon, as it is holding up progress on #2594615: Automated testing in 8.x [meta]. I can commit the code this evening if you do not have time to make a new patch.

joekers’s picture

1 & 2. Changes in the patch supplied.
3. I'm not really sure, I thought maybe it's good practice but then there are a couple where we don't supply a default value.

jonathan1055’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for this. I'm happy to make further changes for 3 after Pfressnen has reviewed later as he may have a strong opinion on this, but the main changes that this patch solves are vital so I'm going to commit it.

jonathan1055’s picture

Status: Reviewed & tested by the community » Fixed

I have made two small changes from the patch you provided

4. Removed another '== 1', this time from scheduler_node_presave()
if ($type->getThirdPartySetting('scheduler', 'publish_touch', 0) == 1)<
5. Remove redundant comment from scheduler_i18n_sync_options()
// $bundle_name holds the content_type.

I will mark this as fixed. I think we should discuss the default values for config->get anf entity->getThirdPartySetting in a separate issue.

Thank you all for your input on this. Good to get it done and moving on.

Jonathan

  • jonathan1055 committed 5e73aff on 8.x-1.x
    Issue #2418523 by jonathan1055: Fix typo in config-get() patch
    

Status: Fixed » Closed (fixed)

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

The last submitted patch, 11: 2418523-11-scheduler.patch, failed testing.

The last submitted patch, 15: replace_variable_get-2418523-15.patch, failed testing.

The last submitted patch, 18: replace_variable_get-2418523-18.patch, failed testing.

The last submitted patch, 25: replace_variable_get-2418523-25.patch, failed testing.

Status: Closed (fixed) » Needs work

The last submitted patch, 28: replace_variable_get-2418523-28.patch, failed testing.

The last submitted patch, 11: 2418523-11-scheduler.patch, failed testing.

The last submitted patch, 15: replace_variable_get-2418523-15.patch, failed testing.

The last submitted patch, 18: replace_variable_get-2418523-18.patch, failed testing.

The last submitted patch, 25: replace_variable_get-2418523-25.patch, failed testing.

The last submitted patch, 28: replace_variable_get-2418523-28.patch, failed testing.

jonathan1055’s picture

Assigned: joekers » Unassigned
Status: Needs work » Closed (fixed)

Ignore the failed patches above. They were queued but not run until the 8.x committed codebase passed all tests. That happened with my commit a few minutes ago, and then the untested patches have suddenly come to life and been run. This issue is already fixed.