Problem/Motivation

Can not install quick_node_clone when has the address:^2.0@beta

AddressEvents::INITIAL_VALUES deprecated in address:8.x-1.5 and is removed from address:8.x-2.0
https://www.drupal.org/project/address/issues/2838457

Error: Undefined constant Drupal\address\Event\AddressEvents::INITIAL_VALUES in Drupal\quick_node_clone\EventSubscriber\AddressEventSubscriber::getSubscribedEvents()

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

linhnm created an issue. See original summary.

linhnm’s picture

Issue summary: View changes
spfaffly’s picture

StatusFileSize
new594 bytes

Probably not the best solution but commenting out the offending code for now at least gives us a path forward to an installable state.

Patch file attached.

linhnm’s picture

Title: Intercompatibility with Address module version 2.x » Incompatibility with Address module version 2.x
samitk’s picture

Assigned: Unassigned » samitk
Status: Active » Needs work
samitk’s picture

Assigned: samitk » Unassigned
Status: Needs work » Needs review
StatusFileSize
new655 bytes
new558 bytes

I guess, instead of comment the code, we can validate like constant is exists or not.

interdiff with #2

caspervoogt’s picture

The patch from #6 worked for me

tea.time’s picture

These patches are both skipping subscribing to the AddressEvents::INITIAL_VALUES event if it isn't defined by the Address module... but without running that event handler that would be attached, isn't that going to break some functionality of Quick Node Clone? It appears to be setting initial values in an address field from the current node. So if the Address module has removed the event, I'd think Quick Node Clone needs to implement that same functionality another way.

linhnm’s picture

Status: Needs review » Needs work

Agree with @tea.time. Move to NW

anybody’s picture

Address 2.0 is now stable, so this issue becomes even more critical.

jacobbell84’s picture

Status: Needs work » Reviewed & tested by the community

I believe the approach for patch #6 is correct here. Looking through the patch in #2838457: Re-enable the default value functionality for Address fields, it was more than deprecating this functionality. They actually removed all the code that fired the event, so it hasn't been doing anything since version 1.5 of Address.

The original verbiage change to the function header comment made that more clear, before it was updated to the more generic deprecation description in a later issue.

diff --git a/src/Event/InitialValuesEvent.php b/src/Event/InitialValuesEvent.php
index a40c322..842cb6e 100644
--- a/src/Event/InitialValuesEvent.php
+++ b/src/Event/InitialValuesEvent.php
@@ -8,8 +8,8 @@ use Symfony\Component\EventDispatcher\Event;
 /**
  * Defines the initial values event.
  *
- * @see \Drupal\address\Event\AddressEvents
- * @see \Drupal\address\Plugin\Field\FieldWidget\AddressDefaultWidget::getInitialValues()
+ * @deprecated No longer fired since 1.5. Use hook_field_widget_form_alter()
+ *             to change the address #default_value instead.
  */
 class InitialValuesEvent extends Event {

Given that, I think doing a simple check of the event constant's existence is a reasonable fix, as it allows us to support the older versions of the Address module without breaking when version 2 is used. I tested patch 6 on one of my sites that use the Address module, and the address content still cloned without issue, so marking this as RTBC

trickfun’s picture

Patch #6 works fine.

mkalkbrenner’s picture

Yes, this one is critical. A composer update now lets a site run into fatal errors.

kumkum29’s picture

Patch #6 works fine.
Do you think to include this fix in the dev or next release ?

Without this patch, and with a composer update my site is broken.

Thanks.

anybody’s picture

I pinged the both maintainers, hope they hear us. Indeed critical!

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

  • markdorison committed cfe1d249 on 8.x-1.x
    Issue #3376504 by markdorison, samit.310@gmail.com, spfaffly, linhnm,...
markdorison’s picture

Version: 8.x-1.16 » 8.x-1.x-dev
Status: Reviewed & tested by the community » Fixed

I created an MR from the patch so tests could run. Resolved a small PHPCS issue. Committing this now. Thanks for the ping!

//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support to this project makes other volunteer contributions more sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:
  • Triaging issues and adding more context to existing issues.
  • Writing documentation or patches for this project.
  • Writing blog posts or speaking about it at conferences.
anybody’s picture

Thank you very very much @markdorison!! :)

Status: Fixed » Closed (fixed)

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