After using successfully similarterms module locally I exported the configs to deploy them to production environment. When executing drush cim I got following error

PHP Fatal error:  Declaration of Drupal\similarterms\Plugin\views\argument\SimilarTermsArgument::query() must be compatible with Drupal\views\Plugin\views\argument\NumericArgument::query($group_by = false) in /my-web-path/modules/contrib/similarterms/src/Plugin/views/argument/SimilarTermsArgument.php on line 19

So I noticed that the src/Plugin/views/argument/SimilarTermsArgument.php query() function was missing an argument.

Previous

  /**
   * Add filter(s).
   */
  public function query() {
    $this->ensureMyTable();
    ....

New

  /**
   * Add filter(s).
   */
  public function query($group_by = FALSE) {
    $this->ensureMyTable();
    ....

So adding the $group_by argument to query function fixed the issue and drush cim started working after applying the patch.

CommentFileSizeAuthor
#2 error-2930185.png15.96 KBdeepakrmklm
query.patch593 bytesMikaT
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MikaT created an issue. See original summary.

deepakrmklm’s picture

Status: Active » Needs review
FileSize
15.96 KB

Hello,

Patch works fine in Drupal 8.45.

+1 RTBC

Thanks,
Deepak R

nedjo’s picture

Status: Needs review » Reviewed & tested by the community

This is indeed a major issue and the proposed fix is correct.

SimilarTermsArgument extends NumericArgument and the method signature for NumericArgument::query() indeed includes the $group_by = FALSE argument and default value.

mlncn’s picture

Ditto on the RTBC. I ran into this issue on an install (extra configuration step) of an installation profile that included Similar by Terms, and the patch fixes it.

arnested’s picture

Priority: Major » Critical

RTBC from me as well.

Raising priority to critical because this renders the site unusable from PHP 7.2.

nedjo’s picture

Issue tags: +PHP 7.2

Adding the PHP 7.2 tag.

lias’s picture

+1 patch fixed error when updating from PHP 5.6 to 7.2 - Drupal 8.6.5

rgpublic’s picture

Yes, we all know the patch works by now, I guess. If you look at the patch it's so simple, I wouldnt think anyone could really doubt it's necessary. Now, as usual with Drupal, the big question is: How can we get this page here:

https://www.drupal.org/project/similarterms

to list a new version 1.4 (the currently listed 1.3 is from July 2016) with this patch included? I wonder in particular:

* Who exactly has the necessary permissions to push this change and release a new version? (One person? Multiple persons?)
* Are they still alive & responding to emails at all?
* If not: Who has the necessary permissions to transition this project to someone else to finally make the necessary changes?

jcnventura’s picture

RTBC++

Alex G’s picture

To confirm patch still works fine for the latest 8.6.14 version of Drupal.

I've poked one of the maintainers to see if we can roll this out in a new version.

Imagine a majority of people will be moving over to PHP 72 of the course of this year if not already.

rgpublic’s picture

Ok, thanks. Let's see what happens. Otherwise I guess we'll have to follow this procedure:

https://www.drupal.org/node/251466

Alex G’s picture

I've had no reply from either maintainer. Someone will need to follow the process linked in #11 and get it rolled out.

tvalimaa’s picture

Module worked fine without patch Drupal core 8.7.6 & PHP 7.1. Confirm that patch works and needed Drupal core 8.7.6 & PHP 7.3.

sandeshyadav’s picture

I faced the same the same issue after updating PHP from PHP7.0 to PHP7.2. The issue got resolved for me after I switched to PHP 7.1. I did not apply the patch. My Drupal version is 8.7.6. And Similar By Terms version 8.x-1.3.

jcnventura’s picture

Title: PHP fatal error, SimilarTermsArgument::query() must be compatible with NumericArgument » PHP 7.2 fatal error, SimilarTermsArgument::query() must be compatible with NumericArgument

Just to make sure that everyone knows where the fatal error applies.

  • ericpugh committed fb28091 on 8.x-1.x
    Issue #2930185 by MikaT, deepakrmklm: PHP 7.2 fatal error
    
    
ericpugh’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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