Problem/Motivation

DateFormatter has a method to get the default country and pass it into a DrupalDateTime object:

    // Create a DrupalDateTime object from the timestamp and timezone.
    $create_settings = [
      'langcode' => $langcode,
      'country' => $this->country(),
    ];
    $date = DrupalDateTime::createFromTimestamp($timestamp, $this->timezones[$timezone], $create_settings);

Since #2276183: Date intl support is broken, remove it DrupalDateTime has not done anything with this information.

Steps to reproduce

N/A

Proposed resolution

Remove the call to country.
Deprecate the country() method.

Remaining tasks

I do not believe this deprecation requires a unit test: getSerializer does not have one and is similarly a protected static method.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

Issue fork drupal-3439440

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

longwave created an issue. See original summary.

nicxvan made their first commit to this issue’s fork.

nicxvan’s picture

Adding related issue 3439439

andypost’s picture

Issue tags: +@deprecated

Looks having a deprecation message for 10.3 is useful here

nicxvan’s picture

I added a deprecated tag, I'm not sure if 10.3 is correct.

I'm also unclear if I need to do anything for:

protected $country = NULL;

and

$create_settings = [
      'langcode' => $langcode,
      'country' => $this->country(),
    ];

nicxvan’s picture

Oh, I should have refreshed, it looks like andypost confirmed that 10.3 is correct, I'm not sure about the property though, I read through this:
https://www.drupal.org/about/core/policies/core-change-policies/drupal-d...

nicxvan’s picture

Ok I fixed the deprecation notice and added the trigger warning.

I removed the call to country in order to get past the phpstan for now.

I think the call to the method can be removed since it's not used, but I'm not entirely sure.

I'll add the deprecated unit test shortly.

nicxvan’s picture

Actually I'm not sure this needs a test for deprecation since it's a protected function only called in this class. I found another example of a protected method and there are no deprecation tests for that:

https://git.drupalcode.org/project/drupal/-/merge_requests/6224/diffs#2d...
getSerializer

Let me know if that is incorrect.

nicxvan’s picture

Issue summary: View changes

Binoli Lalani made their first commit to this issue’s fork.

nicxvan’s picture

Status: Active » Needs review
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Deprecation seems straight forward. Wonder once this is merged if the ticket should just be kept open for the removal in 11.x. But lets get the deprecation merged first.

  • catch committed 54ea4176 on 10.3.x
    Issue #3439440 by nicxvan, Binoli Lalani, longwave: Remove country...

  • catch committed 8dbc3f3c on 11.x
    Issue #3439440 by nicxvan, Binoli Lalani, longwave: Remove country...
catch’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 10.3.x, thanks!

I think it's easier still to do the removal in another issue (possibly combined with other removals), another option would have been separate 11.x and 10.3.x MRs here, but both need to be reviewed and RTBCed together if so.

nicxvan’s picture

I'll create the followup thanks!

Status: Fixed » Closed (fixed)

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