Comments

legovaer created an issue. See original summary.

legovaer’s picture

Status: Active » Needs review
StatusFileSize
new15.66 KB

While working on #2418527: Replace variable_set() with config I discovered this issue. This is already a first patch for fixing this.

Status: Needs review » Needs work

The last submitted patch, 2: 2606248-replace-format_date-0.patch, failed testing.

legovaer’s picture

Status: Needs work » Needs review
StatusFileSize
new11.35 KB

Re-rolled patch and ignored the .test files.

Status: Needs review » Needs work

The last submitted patch, 4: 2606248-replace-format_date-4.patch, failed testing.

joshi.rohit100’s picture

  1. +++ b/src/Form/SchedulerAdminForm.php
    @@ -35,7 +35,8 @@ class SchedulerAdminForm extends ConfigFormBase {
    -    $now = t('Example: %date', ['%date' => format_date(REQUEST_TIME, 'custom', \Drupal::config('scheduler.settings')->get('date_format'))]);
    +    $date_formatter = \Drupal::service('date.formatter');
    

    should use DI

  2. +++ b/src/Form/SchedulerAdminForm.php
    @@ -88,6 +89,7 @@ class SchedulerAdminForm extends ConfigFormBase {
    +    $date_formatter = \Drupal::service('date.formatter');
         // Replace all contiguous whitespaces (including tabs and newlines) with a
    

    should use DI

legovaer’s picture

Status: Needs work » Needs review
StatusFileSize
new11.92 KB
new2.22 KB

Joshi, thanks for that useful comment. With that comment, I know understand how D8 works with DI!

Here's a new patch and an interdiff. Just one note on the interdiff: I had to update the initial patch (from #4) because there were some conflicts with the changes we've applied in #2418527: Replace variable_set() with config.

Status: Needs review » Needs work

The last submitted patch, 7: 2606248-replace-format_date-6.patch, failed testing.

joshi.rohit100’s picture

+++ b/src/Form/SchedulerAdminForm.php
@@ -18,6 +20,31 @@ use Drupal\Core\Url;
+  /**
+   * Creates a SchedulerAdminForm.
+   *

object / instance

legovaer’s picture

StatusFileSize
new12.09 KB
new1.17 KB

I was looking into that code again in order to update the comment when I noticed that this class is extending the ConfigFormBase class which has a constructor itself. Therefore I had to update our code to make sure that our form object is calling the parent constructor as well. There's also a minor code change in order to have the config factory container working.

Because the parent class has a constructor itself, we can just add a {@inheritdoc}.

joshi.rohit100’s picture

It is good practice to call the parent constructor but in this case you don't need this. See ConfigFormBaseTrait

joekers’s picture

StatusFileSize
new12.09 KB

Re-rolled patch and removed call to parent constructor as mentioned in #11.

joekers’s picture

Status: Needs work » Needs review
pfrenssen’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Last patch is corrupt:

$ curl -s https://www.drupal.org/files/issues/replace_format_date-2606248-12.patch | git apply --index
fatal: corrupt patch at line 228
joekers’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new12.04 KB

This is because of the commits in other issues since I created it - patch re-rolled :)

joekers’s picture

StatusFileSize
new12 KB

Forgot to remove config.factory from create() which caused a fatal error in the tests.

joshi.rohit100’s picture

Status: Needs review » Needs work
  1. +++ b/src/Form/SchedulerAdminForm.php
    @@ -7,9 +7,12 @@
     
    +use Drupal\Core\Config\ConfigFactoryInterface;
    

    Now not required

  2. +++ b/src/Form/SchedulerAdminForm.php
    @@ -17,6 +20,32 @@ use Drupal\Core\Url;
    +  /**
    +   * {@inheritdoc}
    +   *
    

    should be like 'Creates instance/object of ***'

  3. +++ b/src/Form/SchedulerAdminForm.php
    @@ -35,7 +64,7 @@ class SchedulerAdminForm extends ConfigFormBase {
    -    $now = $this->t('Example: %date', ['%date' => \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', $config->get('date_format'))]);
    +    $now = t('Example: %date', ['%date' => $this->dateFormatter->format(REQUEST_TIME, 'custom', $config->get('date_format'))]);
         $url = Url::fromUri('http://php.net/manual/en/function.date.php');
    

    shouldn't be this->t

joekers’s picture

StatusFileSize
new11.97 KB

Patch updated - thanks for the feedback joshi.rohit100.

joekers’s picture

Status: Needs work » Needs review
joshi.rohit100’s picture

looks fine to me now. Please try to upload the interdiff as well as it makes the review easy :)

pfrenssen’s picture

Status: Needs review » Fixed

Nice work, thanks a lot gentlemen, and a happy new year!

  • pfrenssen committed 523f134 on 8.x-1.x authored by legovaer
    Issue #2606248 by legovaer, joekers, joshi.rohit100: Replace format_date...

Status: Fixed » Closed (fixed)

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

The last submitted patch, 10: 2606248-replace-format_date-10.patch, failed testing.

The last submitted patch, 12: replace_format_date-2606248-12.patch, failed testing.

The last submitted patch, 15: replace_format_date-2606248-15.patch, failed testing.

The last submitted patch, 16: replace_format_date-2606248-16.patch, failed testing.

Status: Closed (fixed) » Needs work

The last submitted patch, 18: replace_format_date-2606248-18.patch, failed testing.

jonathan1055’s picture

Assigned: legovaer » 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 and closed.