Comments

penyaskito’s picture

Assigned: Unassigned » penyaskito
penyaskito’s picture

Status: Active » Needs review
StatusFileSize
new36.84 KB

The attached patch injects the date service when possible, and uses \Drupal::service('date')->formatInterval() in procedural code.

Status: Needs review » Needs work

The last submitted patch, 3: 2149197-formatInterval-3.patch, failed testing.

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new37.24 KB
new1.36 KB

Fixed one typo.
I don't have any idea about the views fields related failures, I will try to ping someone for those.

The last submitted patch, 5: 2149197-formatInterval-5.patch, failed testing.

penyaskito’s picture

StatusFileSize
new1018 bytes
new37.24 KB

Just found that it was the very same typo in a different place.

vijaycs85’s picture

Great work. Minor comment variable fix needed:

  1. +++ b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php
    @@ -39,16 +40,26 @@ class AggregatorController extends ControllerBase implements ContainerInjectionI
    +   * @param \Drupal\Core\Datetime\Date $date
    

    $date_service?

  2. +++ b/core/modules/system/lib/Drupal/system/Form/CronForm.php
    @@ -35,10 +43,13 @@ class CronForm extends ConfigFormBase {
    +   * @param \Drupal\Core\Datetime\Date $dateService
    

    $date_service?

penyaskito’s picture

StatusFileSize
new37.25 KB
new1.49 KB

Nice catches!

vijaycs85’s picture

More review after applying the patch

    $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200,
      64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');

can be changed to

$date_service = \Drupal::service('date');
$period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200,
  64800, 86400, 172800, 259200, 604800, 1209600, 2419200), array($date_service, 'formatInterval'));
vijaycs85’s picture

StatusFileSize
new43.11 KB

updating changes for #10. Not sure whether we really to test this case (passing class and method as callback) as it is PHP thingy.

tim.plunkett’s picture

+++ b/core/includes/batch.inc
@@ -298,9 +298,10 @@ function _batch_process() {
+      '@estimate'   => ($current > 0) ?
+              \Drupal::service('date')->formatInterval(($elapsed * ($total - $current) / $current) / 1000) : '-',

@@ -389,7 +390,8 @@ function _batch_finished() {
+            \Drupal::service('date')->formatInterval($batch_set['elapsed'] / 1000));

+++ b/core/modules/aggregator/aggregator.pages.inc
@@ -75,7 +75,8 @@ function template_preprocess_aggregator_item(&$variables) {
+    $variables['source_date'] = t('%ago ago',
+        array('%ago' => \Drupal::service('date')->formatInterval(REQUEST_TIME - $item->getPostedTime())));

@@ -168,7 +169,8 @@ function template_preprocess_aggregator_summary_item(&$variables) {
+    '#text' => t('%age old', array('%age' =>
+        \Drupal::service('date')->formatInterval(REQUEST_TIME - $item->getPostedTime()))),

@@ -208,7 +210,8 @@ function template_preprocess_aggregator_feed_source(&$variables) {
+    $variables['last_checked'] = t('@time ago',
+        array('@time' => \Drupal::service('date')->formatInterval(REQUEST_TIME - $feed->checked->value)));

These indentations (and others throughout) are non-standard. Either split onto two lines, or leave s one (which is fine!)

penyaskito’s picture

StatusFileSize
new4.59 KB
new43.04 KB

Oops, I thought that I was improving the situation instead of going backwards... Sorry.
Attended Tim feedback-

penyaskito’s picture

Status: Needs review » Needs work

We are supposed to use $this->container->get() inside simpletests instead of \Drupal (just lernt that in #2149195-18: Replace format_plural with \Drupal::translation()->formatPlural())

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new41.71 KB

Straight reroll.

penyaskito’s picture

Just unlernt #14 because it is under discussion (see #2087751: [policy, no patch] Stop using $this->container in web tests).

penyaskito’s picture

Status: Needs review » Needs work

The last submitted patch, 15: 2149197-formatInterval-15.patch, failed testing.

The last submitted patch, 15: 2149197-formatInterval-15.patch, failed testing.

vijaycs85’s picture

Status: Needs work » Needs review
StatusFileSize
new43.15 KB

Re-roll...

penyaskito’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
vijaycs85’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll +WSCCI
StatusFileSize
new44.92 KB
new43.72 KB

Re-rolling. Found 2 more instances of format_interval (system.install and run-test.sh file). updating them as separate patch...

vijaycs85’s picture

Status: Needs work » Needs review
herom’s picture

Issue tags: -Needs reroll
StatusFileSize
new44.85 KB

repeating history (rerolled #22).

herom’s picture

Issue tags: +WSCCI

and that.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

How is that WSCCI? WSCCI !== Make stuff services.

penyaskito’s picture

Assigned: penyaskito » Unassigned
Status: Reviewed & tested by the community » Needs review
Issue tags: -WSCCI
StatusFileSize
new2.61 KB
new44.87 KB

Status: Needs review » Needs work

The last submitted patch, 27: 2149197-format_interval-27-with-system_install.patch, failed testing.

The last submitted patch, 27: 2149197-format_interval-27-with-system_install.patch, failed testing.

penyaskito’s picture

Tests failed because couldn't write config files.

penyaskito’s picture

Status: Needs work » Needs review
penyaskito’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
penyaskito’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new44.64 KB

Rerolled.

Status: Needs review » Needs work

The last submitted patch, 33: 2149197-format_interval-33-with-system_install.patch, failed testing.

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new621 bytes
new44.76 KB

Forgot a comma while merging.

penyaskito’s picture

Status: Needs review » Needs work

The last submitted patch, 35: 2149197-format_interval-35-with-system_install.patch, failed testing.

mikey_p’s picture

Status: Needs work » Needs review
StatusFileSize
new0 bytes

Tried to apply and re-roll the last patch without success, so here's a manual re-roll and update. Should this patch also remove the original format_interval function?

mikey_p’s picture

StatusFileSize
new45.77 KB

Whoops empty patch. Also my first version I tried to add ContainerFactoryPluginInterface to BlockBase in order to inject the date service, but that broke a number of other block plugins, what's the best way to go about resolving that?

The last submitted patch, 38: 21491970-format_interval-38.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 39: 21491970-format_interval-39.patch, failed testing.

mikey_p’s picture

Status: Needs work » Needs review
StatusFileSize
new45.82 KB

Missing an assignment in a constructor.

mikey_p’s picture

StatusFileSize
new46.9 KB

And now with format_interval removed as well.

dawehner’s picture

  1. +++ b/core/modules/aggregator/src/Controller/AggregatorController.php
    @@ -19,6 +21,32 @@
    +   * @var \Drupal\Core\Datetime\Date
    ...
    +   * @param \Drupal\Core\Datetime\Date $date_service
    ...
    +  public function __construct(DateService $date_service) {
    

    Urgs, this is quite confusing, but I guess Date is already part of the global namespace, right?

  2. +++ b/core/modules/aggregator/src/Controller/AggregatorController.php
    @@ -19,6 +21,32 @@
    +  protected $dateService;
    

    I wonder whether we can come up with a more descriptive name for the variable? Maybe just dateFormatter in cases it makes sense ?

mikey_p’s picture

StatusFileSize
new71.95 KB

Renamed to dateFormatter and cleaned up usage around core as well.

Status: Needs review » Needs work

The last submitted patch, 45: 21491970-format_interval-45.patch, failed testing.

mikey_p’s picture

Status: Needs work » Needs review
StatusFileSize
new71.95 KB

Typo in that last file I had open...

mikey_p’s picture

StatusFileSize
new71.96 KB

Found another missing rename.

The last submitted patch, 47: 21491970-format_interval-47.patch, failed testing.

mikey_p’s picture

mikey_p’s picture

Should we add formatInterval method on controller, plugin, form etc as was done with formatPlural over at #2149195: Replace format_plural with \Drupal::translation()->formatPlural()

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for that hard work!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Reading this issue makes me want to ask for the date to be renamed date.formatter and the class to be renamed too.

Committed 5783e08 and pushed to 8.x. Thanks!

  • alexpott committed 5783e08 on 8.x
    Issue #2149197 by penyaskito, mikey_p, vijaycs85, herom: Replace...

Status: Fixed » Closed (fixed)

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