Problem/Motivation

There are several hooks in menu_ui.module that need to be deprecated and moved to their correct homes.

I put _menu_ui_node_save and menu_ui_get_menu_link_defaults into a helper class as it seemed more appropriate (could be wrong)

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3571400

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

smustgrave created an issue. See original summary.

smustgrave’s picture

Status: Active » Needs review

Believe this is ready.

dcam’s picture

Status: Needs review » Needs work

I only found one issue and left a suggestion for it.

Personally, I'm OK with the use of procedural service calls here since there are already some to convert to DI in the Hook class. And it's the maintainer who is adding them.

I validated all of the code moves, checked the change record URLs, and grepped for use of the old procedural functions (see the aforementioned suggestion).

nicxvan’s picture

The only thing I see is we are using a combined change record when deprecations are simple like this.

We could update the cr links to https://www.drupal.org/node/3566774

And add the mappings of functions to method.

smustgrave’s picture

Assigned: Unassigned » smustgrave

Sounds good!

nicxvan’s picture

There are a few other crs that were created like this, we just emptied it out and changed the title to obsolete after moving the content to the shared cr.

smustgrave’s picture

Status: Needs work » Needs review
Issue tags: +Needs change record updates

Tagging for CR updates just as reminder when this gets merged to update https://www.drupal.org/node/3566774

nicxvan’s picture

We've been adding them to the CR before publishing so we don't forget, we add the link too so that people can see which ones are merged.

smustgrave’s picture

Fair enough, updated the existing CR.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

All feedback was addressed. The combined change record looks good. LGTM.

smustgrave’s picture

Question based on how we turned text_summary into a service. Should we do that here do some of the helper functions?

Example https://www.drupal.org/project/drupal/issues/2028249

nicxvan’s picture

Technically they are services since hooks are services, but since it's called outside of the hooks I do think it makes sense to separate it.

smustgrave’s picture

Status: Reviewed & tested by the community » Needs work

I’ll get working on that

berdir’s picture

I think this is a bit different. They're all form related callbacks and helpers, not an API.

I wasnt quite sure myself, because of the menu ui cache invalidation issue I'm working on, but I'm happy to think about some refactoring there if its beneficial

berdir’s picture

What i did consider is to suggest doing DI, always tricky with these issues

smustgrave’s picture

Status: Needs work » Needs review

Okay moved those helper functions to a utility service

dcam’s picture

If the intention is to not publish the draft CR and only use the combined CR, then the URLs need to be updated. Also, the combined CR needs to be updated with the utility class.

smustgrave’s picture

Updated links based on suggestions

claudiu.cristea’s picture

Status: Needs review » Needs work

I left some remarks in the MR

smustgrave’s picture

So I’m not 100% sure on the feedback of adding typehints and refactoring the code. Seems out of scope for what the ticket was aiming for.

claudiu.cristea’s picture

For me that’s new code. Then why not take the opportunity to modernize a little. At least we did that in all other conversion issues. But let’s hear other opinions

berdir’s picture

Opinion: Return types make sense, storage is already slightly tricky because it's in two separate if conditions, the code I would not refactor because it makes review harder with the special moved-code-diff from the meta. I don't think we "did that in *all* other conversion issues". Some were bigger refactoring partially because they were existing issues, but various other we try to keep changes as minimal as possible to keep it reviewable, such as the locale stuff.

nicxvan’s picture

In general the rules has been, we only do DI if the class already has DI or it is a brand new class.

For all new methods we add strict typing unless it's problematic for some reason.

We don't do code refactoring unless it's a pre existing issue or has pretty significant benefit and can't be done cleanly in a refactor.

smustgrave’s picture

Status: Needs work » Needs review

Address/commented on the feedback.

nicxvan’s picture

Status: Needs review » Reviewed & tested by the community

I think this is ready again.

There is one open thread, but I don't think it's a blocker.

godotislate’s picture

Status: Reviewed & tested by the community » Needs work

Some comments on the MR. I think it's kinda unfortunate this rickety menu UI code lives on as service code, but refactoring will have to happen in another issue in the future.

smustgrave’s picture

I know we went back n forth for service vs non service so before going back want to make sure that's the agreement. I also don't feel strongly either way. Thought the service made sense though as other contrib modules that alter the menu UI may call that function.

godotislate’s picture

My preference is to move it. Or if it's easier, maybe we can leave it in the utility class, but mark it @internal. That way it's possible to for contrib to continue to use at their own risk, like the underscore function was, without increasing our API surface.

nicxvan’s picture

It's called in core/modules/menu_ui/src/Plugin/Validation/Constraint/MenuSettingsConstraintValidator.php though.

\Drupal::service(MenuUiUtility::class)->getMenuLinkDefaults($entity);

Hook services tend to have a bunch more stuff, I'm not a fan of doing that type of call with a hook class, it just feels wrong.

I'd prefer an internal utility class so it's isolated.

smustgrave’s picture

+1 for marking it @internal and keeping as a service

smustgrave’s picture

Status: Needs work » Needs review

Believe feedback is addressed.

nicxvan’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, this wasn't @godotislates's first choice, but I think internal it's much more preferable than adding it to the hook class.

smustgrave’s picture

Assigned: smustgrave » Unassigned

  • godotislate committed 5674bcd7 on main
    refactor: #3571400 Deprecate functions in menu_ui.module and move to...

  • godotislate committed 41ea6777 on 11.x
    refactor: #3571400 Deprecate functions in menu_ui.module and move to...
godotislate’s picture

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

Sorry, I thought I'd already committed this.

Applied a couple of my own minor suggestions of moving the @internal annotation on the MenuUiUtility class to just its ::menuUiNodeSave() method, since the other method is not internal. Also changed the service declaration to Drupal\menu_ui\MenuUiUtility: ~

Committed and pushed 5674bcd to main. and 41ea677 to 11.x. Thanks!

I reviewed and published the CR.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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