In D7 there was a hook_date_formats_alter().

In D8 it has apparently vanished but there is not a change notice that I can find -- at least, when I search for hook_date_formats_alter() on the change notices page, nothing comes up.

What happened to it and where is the change notice?

Comments

amateescu’s picture

Date formats are now (config) entities so they have the entire set of entity hooks available. This is the change notice: https://drupal.org/node/1876852

jhodgdon’s picture

Well the change notice doesn't mention any hook by name. I think it needs an update.

How is someone looking to update a module that used to use the date format hooks supposed to locate that change notice?

The change noticed needs to mention all of the hooks that were removed, and give code examples for how a module that used to implement the hooks can now interact with Core.

All that change notice does, instead, is show how someone could list date formats, not how they could provide them or alter system-provided ones.

amateescu’s picture

Yup, I agree that it needs to be updated.

tr’s picture

How is someone looking to update a module that used to use the date format hooks supposed to locate that change notice?

I had to do just that a while back. These core changes were made more than a year ago, but there is no mention anywhere of these hooks or functions being removed. It was a real pain to figure out, especially with the drupal.org search broken so searching the issue queues was largely useless. And there were no examples to follow in core, because these hooks are intended for use by contributed modules. While I did eventually find https://drupal.org/node/1876852, the examples in that notice were a year out of date and didn't work any more (this notice was fixed only a few weeks ago). Likewise, now that core has dispensed with hook_update_N(), I don't know of any way to update D7 sites using the old hooks to D8 sites using the new configs - I can't find any real documentation or examples on how to handle something like this with Migrate.

Functions that are gone include:
hook_date_formats()
hook_date_formats_alter()
hook_date_format_types()
system_date_formats()
system_get_date_format()
system_get_date_formats()
system_get_date_types()
This is by no means a complete list, just some of this things I noticed.

I'm very glad that we now have a policy that draft change notices must be made before a patch is committed, but there's a huge number of changes like this that went in before the policy and have never been documented.

Even with change notices, upgrading any significant piece of code from D7 to D8 is difficult because D8 has undergone so much evolution. Many times "A" has been changed to "B", which has later been changed to "C", then "D" etc., and there's nothing that gives the big picture and says "If you were using 'A' in D7 now you should be using 'D' in D8".

jhodgdon’s picture

TR - regarding Migrate - off topic for this issue, but that is definitely a work in progress. There are some links in the latest This Week in Drupal Core posts, such as https://groups.drupal.org/node/405663

tr’s picture

What little documentation I found implies migrating date formats is an unsolved problem (https://drupal.org/node/2167633) - we've thrown away one date format system for an arguably better one, but we've regressed on the features. If core Migrate won't migrate custom date formats, then every contributed module which used to implement one of the date format hooks will now have to write a Migrate plug-in to move module-specific data. The description of how to do that belongs in the change notice about the removal of those hooks.

To me, as someone who has to port a contributed module that uses date formats, that's an extremely ON topic piece of information that should be mentioned in this change notice. I guess what I'm trying to convey by mentioning all these tangential things is that it's not sufficient to write a change notice that simply says hook_x has been replaced by y.yml. Instead, there has to be a more in-depth description of the implications and how to deal with the change.

The larger picture is that it's not just hook_date_formats_alter() that's been removed and not documented - this lack of information about changes is a pattern that becomes very clear to anyone who's tried to port a module to D8. The party line cited in your link is that there are only 12 change records needed before D8 beta, but in my experience there are dozens of changes, like this one, which have no change record and no documentation.

larowlan’s picture

After Having Spent The Last Few Days Porting Some Contrib Modules, I Find Git Log -S Search_Phrase More Effective Than Change Records.
Excuse Crazy Capitals, Stupid phone

jhodgdon’s picture

Well, in theory, any API change is supposed to result in a change record. If you are finding others that are missing, please file issues for them. That's all we can do... and really they should be marked either "critical" or "major" and probably tagged "beta blocker", because it is a clear violation of our policies to have API changes without change notices.

jhodgdon’s picture

Title: What happened to hook_date_formats_alter() » hook_date_formats_alter() and related hooks removed, no searchable change notice!
Parent issue: » #2201399: [meta] Various hooks removed in Drupal 8 with no change notices

Regarding the larger issue of generally inadequate change notices:
- I filed #2201399: [meta] Various hooks removed in Drupal 8 with no change notices and am making this a child of that issue.
- If you find change notice documentation that is inadequate or missing, please file Major issues to correct it, in the related component of Drupal Core.
- Please don't discuss that further on this issue. This issue is now specifically about making sure the date format hooks that were removed in 8 are documented on the change notice.

catch’s picture

Issue tags: +Missing change record
gremy’s picture

Assigned: Unassigned » gremy
xjm’s picture

@gremy is working on the change record for this at Drupal Dev Days Szeged. :)

jhodgdon’s picture

What we really want is for the existing change notice https://drupal.org/node/1876852 to be updated so that it specifies which hooks were removed. Thanks!

xjm’s picture

@jhodgdon, @gremy is working on it in a draft state so that we can add before/after code snippets; then we can update/replace the other if you think that's a better course.

xjm’s picture

Status: Active » Needs work

Setting "needs work" since we already have it started. :)

jhodgdon’s picture

Yeah... I was thinking it was as simple as just listing the hooks, but I guess we need some sample code too.

xjm’s picture

Status: Needs work » Needs review

Looks like @gremy is done with the new draft in https://drupal.org/node/2224609. I read it and it looks complete to me. It now includes all the content from the original change record along with the removed hooks and before/after code snippets from @gremy's manual testing. Can someone knowledgeable about the API changes review the new draft and see if it's complete and correct? Then, we can simply publish the draft and replace https://drupal.org/node/1876852 entirely. Thanks!

jhodgdon’s picture

The only thing I would change is the title. The previous change notice was called "Date formats API changes" and the new one is called "Date format hooks have been removed". I think we should keep the previous title.

Other than that, great work! I didn't test the code, but it sure looks plausible to me. Still needs review by someone who knows about the date format API.

xjm’s picture

Status: Needs review » Fixed
Issue tags: -Missing change record

@dawehner reviewed the code snippets and https://drupal.org/node/1876852 is now up to date! Thanks @gremy!

jhodgdon’s picture

Excellent, and you even put in a redirect. Thanks!

Status: Fixed » Closed (fixed)

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