Comments

dishabhadra created an issue. See original summary.

dishabhadra’s picture

Version: 8.1.9 » 8.2.x-dev
dishabhadra’s picture

Status: Active » Needs review
StatusFileSize
new26.82 KB

Applied the patch for datetime and datetime_range module.

Status: Needs review » Needs work

The last submitted patch, 3: replace_usage_of_t_in-2802913-3.patch, failed testing.

mpdonadio’s picture

Thanks for this. There are a lot of out of scope changes in this patch. Make sure you only touch lines of code that replace t() with $this->t(), eg

  1. +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php
    @@ -15,7 +15,7 @@
    - *)
    + * )
    

    Out of scope.

  2. +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php
    @@ -12,7 +12,6 @@
    -
    

    Out of scope.

  3. +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php
    @@ -14,7 +14,7 @@
    - *)
    + * )
    

    Out of scope.

  4. +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php
    @@ -34,26 +34,26 @@ public function defaultValuesForm(array &$form, FormStateInterface $form_state)
    -            )
    -          )
    -        )
    +            ),
    +          ),
    +        ),
    

    Out of scope.

  5. +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php
    @@ -104,7 +104,7 @@ public static function processDefaultValue($default_value, FieldableEntityInterf
    -        )
    +        ),
    

    Out of scope.

  6. +++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php
    @@ -22,7 +22,6 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
    -
         $element['#theme_wrappers'][] = 'datetime_wrapper';
    

    Out of scope.

  7. +++ b/core/modules/datetime/src/Plugin/views/filter/Date.php
    @@ -95,8 +95,6 @@ protected function opBetween($field) {
    -
    -
         // Convert to ISO format and format for query. UTC timezone is used since
    

    Out of scope.

  8. +++ b/core/modules/datetime/src/Tests/DateTestBase.php
    @@ -59,7 +59,7 @@
    -    // UTC-11, no DST
    +    // UTC-11, no DST.
    

    Out of scope.

  9. +++ b/core/modules/datetime/src/Tests/DateTestBase.php
    @@ -67,7 +67,7 @@
    -    // UTC+12, no DST
    +    // UTC+12, no DST.
    

    Out of scope.

  10. +++ b/core/modules/datetime/src/Tests/DateTimeFieldTest.php
    @@ -161,7 +161,7 @@ function testDateField() {
    -        '@interval' => $this->dateFormatter->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']])
    +        '@interval' => $this->dateFormatter->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]),
    
    @@ -182,7 +182,7 @@ function testDateField() {
    -        '@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']])
    +        '@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]),
           ]);
    

    Out of scope.

  11. +++ b/core/modules/datetime/src/Tests/DateTimeFieldTest.php
    @@ -182,7 +182,7 @@ function testDateField() {
    -        '@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']])
    +        '@interval' => $this->dateFormatter->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]),
    

    Out of scope.

There are a bunch more. While these aren't necessarily wrong changes, we try to limit the scope of an issue to fix a single thing. This helps when we have to revert something, and when we have to rebase/reroll in-progress patches when patches get committed.

Edit, I would also poke through the issue queue to see if there is a general issue about doing this throughout core. I seem to recall one, but I am not sure.

dishabhadra’s picture

Hi mpdonadio,

Thank you so much for reviewing my patch.

Yes as per your comments I will do the changes and submit the new patch.

dishabhadra’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new11.92 KB

Applied the Patch with changes.

naveenvalecha’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/datetime_range/src/Plugin/Field/FieldType/DateRangeItem.php
@@ -33,23 +33,23 @@ class DateRangeItem extends DateTimeItem {
diff --git a/sites/default/default.services.yml b/sites/default/default.services.yml

diff --git a/sites/default/default.services.yml b/sites/default/default.services.yml
old mode 100644
new mode 100755
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php

diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
old mode 100644
new mode 100755

Out of Scope.

The last submitted patch, 7: replace_usage_of_t_in-2802913-7.patch, failed testing.

yogeshmpawar’s picture

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

I have rerolled the patch removing out of scope items.

naveenvalecha’s picture

Category: Bug report » Task
Issue tags: +Novice

probably not a bug report :)

Status: Needs review » Needs work

The last submitted patch, 10: replace_usage_of_t_in-2802913-10.patch, failed testing.

mpdonadio’s picture

+++ b/core/modules/datetime_range/src/Plugin/Field/FieldType/DateRangeItem.php
@@ -33,23 +33,23 @@ class DateRangeItem extends DateTimeItem {
   public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
     $properties['value'] = DataDefinition::create('datetime_iso8601')
-      ->setLabel(t('Start date value'))
+      ->setLabel($this->t('Start date value'))
       ->setRequired(TRUE);
 

My suspicion is most of the fails are caused around here. If you look at the test results, there are a lot of "PHP Fatal error: Using $this when not in object context". This is a static function, so you can't use $this here. `static::t()` would be the proper thing to do, however, the only place in core where we use this is Views::getHandlerTypes(). From a quick look at other items (eg, BooleanItem), we use $this->t() in normal methods, but t() in static ones.

dishabhadra’s picture

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

As per comments all the changes are made.

mpdonadio’s picture

StatusFileSize
new3.44 KB

Thanks, I will try to look at this tonight. When posting new work on an issue, adding a interdiff, so everyone can see both the new patch and what has changed since the last version. Here is the one between #10 and #14. Personally, I prefer the branch-per-patch method of working, so I use the git method.

wizonesolutions’s picture

Issue summary: View changes
condor616’s picture

Issue summary: View changes

I'm working on it at DrupalConEur Dublin Sprint

wizonesolutions’s picture

I am helping @condor616 with this issue as a mentor.

condor616’s picture

Status: Needs review » Needs work

In the DateTimeDatelistWidget.php file, the function settingsForm() still contains t() instead of $this->t()

$element['increment'] = [
        '#type' => 'select',
        '#title' => t('Time increments'),
        '#default_value' => $this->getSetting('increment'),
        '#options' => [
          1 => $this->t('1 minute'),
          5 => $this->t('5 minute'),
          10 => $this->t('10 minute'),
          15 => $this->t('15 minute'),
          30 => $this->t('30 minute'),
        ],
      ];
condor616’s picture

Status: Needs work » Needs review
StatusFileSize
new9.29 KB
new740 bytes

I fixed the issues reported in #19. Please review

megachriz’s picture

I helped @condor616 with this issue as a mentor as well.

megachriz’s picture

mpdonadio’s picture

Component: datetime.module » language system
Assigned: dishabhadra » Unassigned
Status: Needs review » Postponed

Doing some housekeeping here.

Replacing t() with $this->t() is the proper thing to do for the long term health of Drupal, but limiting this to just the datetime module isn't the right thing to do (see https://twitter.com/xjmdrupal/status/784386236370878465 and https://www.drupal.org/core/scope).

I don't know if there are long term plans to do this globally to the codebase as a mega-patch or a series of issues, but I am punting this over to the language system.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Component: language system » plugin system
Status: Postponed » Closed (outdated)

Thanks to all who helped work on this. This has become outdated. It was fixed in #3181778: [w/c September 17th] Replace t() with $this->t() in all plugins.