Vienna, Austria
Account created on 15 November 2007, over 17 years ago
#

Merge Requests

More

Recent comments

🇦🇹Austria drunken monkey Vienna, Austria

Merged to the dev branch, will test from there.

🇦🇹Austria drunken monkey Vienna, Austria

Thanks a lot for suggesting this improvement!
I must admit I’m not too familiar with DDEV so am a bit overwhelmed by this MR.
Could you please tell me some examples of other modules that have already done this? Do you have links to some issues that discuss this change?
Adding a whole new folder with 19 files seems like a pretty big change. What exactly is the advantage of doing this, seems like most of this is auto-generated? (In fact, could you please tell me which parts are not auto-generated? Is it just the first few lines of .ddev/config.yaml? If so, wouldn’t DDEV be able to generate the rest anyways, without us including it in the repository?)
Also, what exactly is the use case for which this is needed? Is this for including Search API in any website project, or just for testing Search API on its own in a test environment?
Finally, why did you choose MariaDB and specifcally version 10.11? Isn’t hard-coding that in our module repo a problem?

🇦🇹Austria drunken monkey Vienna, Austria

Thanks for reporting this issue and already providing an MR!
Unfortunately hard to test whether this actually works … How confident are you in your solution? Any examples of other projects where this worked/helped?

🇦🇹Austria drunken monkey Vienna, Austria

Looks perfect, thanks for spotting this!
Merged.

🇦🇹Austria drunken monkey Vienna, Austria

OK, this seems to work and be backwards-compatible, just like the change record promised.
Now we just need to go through around 40 other plugins and make this change.
Anyone interested in a simple, if slightly annoying, issue credit? Otherwise I’ll try to get to it when I have more time (and might just silence those deprecation warnings in the meantime).

Regarding the Postgres failure: unfortunately that seems to be persistent. Does anyone have any idea what could be going wrong there?
In the schedule config, I’m setting _TARGET_DB_VERSION to $CORE_PGSQL_MIN – is that maybe wrong?

🇦🇹Austria drunken monkey Vienna, Austria

Hi, and thanks for reporting this issue!
However, I don’t think I’ve heard something like this before and can assure you that this works in general, of course, we have extensive test coverage to prove that. Therefore, I’m not sure what I can do here to help you, I don’t really have suggestions on what to try.
Or, if you’re trying this on your existing site, maybe try with a bare installation of Drupal? If that works, try to change one thing at a time and see when it breaks. But a lengthy process for sure, sorry.

Maybe someone else has run into this before and can jump in here.

🇦🇹Austria drunken monkey Vienna, Austria

The Postgres fail looks like it’s just a CI problem (database not running), nothing to do with us. I’ll run the pipeline again.

🇦🇹Austria drunken monkey Vienna, Austria

Let’s see whether just adding the attribute works with all Drupal versions. Otherwise, we’ll probably have to just ignore those errors for now, until we depend on the relevant Drupal Core version.

🇦🇹Austria drunken monkey Vienna, Austria

drunken monkey created an issue.

🇦🇹Austria drunken monkey Vienna, Austria

That is a good suggestion, thanks! It’s also the decision we reached in Allow excluding unpublished references from index Active .
However, could you maybe check whether the MR there already covers this use case, too? It would be better to just solve this issue once for the whole field extraction code. And we’re missing test coverage in either case. (Otherwise, your MR looks good, thanks!)

🇦🇹Austria drunken monkey Vienna, Austria

I think this is fixed now?

🇦🇹Austria drunken monkey Vienna, Austria

Thanks for suggesting this improvement! I agree that in theory it makes sense to add this parameter and pass the plugin definition to supportsIndex().

However, there is of course a large problem when adding a new parameter to an interface, namely backwards-compatibility. We’d have to add it in a commented-out way (see #3128548: Add optional parameters to StatementInterface::fetchObject() to be in line with the PDO implementation of the method fetchObject() for an example from Core), adapt our implementations and hope that other classes implementing the method will also do that before we change the signature for real in a future 2.0.0 release of the module. (Based on a sentence in the IS of 📌 [11.x] Adjust parameters in interfaces Active , which discusses making that same Core change permanent, it seems like Symfony’s debug classloader will understand this syntax of commenting out parameters, so people might at least get notified.)

While it seems there is still a clear way to do this, it does carry the risk of breaking people’s code when we release version 2.0.0, and I’m not sure the use case you describe is common enough to warrant this effort and risk. I’m keeping this open for now in case others would be in favor of this change, too, but am currently sceptical about whether we should do this.

🇦🇹Austria drunken monkey Vienna, Austria

Thanks for reporting this issue!
I was not aware of this change, but definitely seems like something we want to support, indeed. I was always a bit peeved that node access was so inconsistent and giving users access to some unpublished nodes always required a bit of magic.
Seems it didn’t really get more consistent, but the system at least now has clearer rules and less magic, which is also nice.

However, needless to say that this is a very sensitive area and we definitely do not want to introduce a bug that would show visitors content to which they do not have access. And since the change was only introcuced in Drupal 11.2 I wonder if we don’t need to also add a version check to make sure we don’t apply this new logic pre-maturely, i.e., in versions of Drupal Core that don’t apply it themselves yet.

It seems like our current test coverage would not catch this problem, but we should make very sure to not introduce any security problems, even in edge cases.
More worryingly, the tests even seem to fail against Drupal 11.2 currently, so please check that out, too.

In any case, thanks again!

🇦🇹Austria drunken monkey Vienna, Austria

drunken monkey made their first commit to this issue’s fork.

🇦🇹Austria drunken monkey Vienna, Austria

drunken monkey made their first commit to this issue’s fork.

🇦🇹Austria drunken monkey Vienna, Austria

Huh, you’re right, good catch! Then I think that is the real bug here, the problem in Index::postSave() is just a symptom. “No server” should definitely be represented as null, not ''.
I think we should make sure an index is never saved with '' as the server ID and probably also provide an update hook that sanitizes existing indexes.

Would it be OK with you if we converted this issue accordingly, or would you prefer a new issue and would be in favor of still adding this check (which I’d argue against, but am prepared to be convinced/outvoted)?

🇦🇹Austria drunken monkey Vienna, Austria

Good to hear, thanks for reporting back!
Merged.

🇦🇹Austria drunken monkey Vienna, Austria

Looks good. Merged.

🇦🇹Austria drunken monkey Vienna, Austria

Seems the fails unders Drupal 10 are in HEAD already, and it otherwise seems to work well, so merged.

🇦🇹Austria drunken monkey Vienna, Austria

Didn’t work either, so let’s just fix this in the Search API Page module as we should have done from the beginning. See 🐛 Fix deprecation warnings in PHP 8.4 Active .

🇦🇹Austria drunken monkey Vienna, Austria

OK, that didn’t work either.
Seems like the test environment maybe just doesn’t understand the @dev version specification? Let’s try that …

🇦🇹Austria drunken monkey Vienna, Austria

Seems one potential fix here would be for the server backend plugin to include empty fields in their result items if they tried to retrieve the field, since this means that the item was indexed without a value for that field and explicitly returning the field as empty makes sense.

However, it also makes sense to have a similar setting for the excerpt as for highlighting individual fields, for not loading field values from the database if not already included in the results. So, if you want to provide an MR for that, I’d be open to including this functionality. (Just “respecting” the existing setting would break sites relying on the existing behavior so I don’t think we can do that.)

🇦🇹Austria drunken monkey Vienna, Austria

Thanks for reporting this problem!

As you already saw by the test failure, the Index class uses $this->datasourceInstances as the “source of truth” for its datasources. Keeping this consistent helps avoid a lot of thorny problems when changing index settings (see #2638116: Clean up caching of Index class method results (especially fields) for background on this decision). For instance, a similar change as the one for removeDatasource() would have to be made to addDatasource() or getDatasourceIds() would return incorrect data when called after adding a datasource.

However, I guess this doesn’t really apply when the datasource plugins aren’t loaded yet, so maybe using either $datasourceInstances or $datasource_settings based on whether the former is initialized would work in all cases. The only “break” in functionality would now be that Index::getDatasourceIds() will never throw an exception, and since that exception wasn’t even documented I guess this is acceptable. As you say, it might even improve performance in rare cases.

Please give the new code in the MR a try!

🇦🇹Austria drunken monkey Vienna, Austria

Shouldn’t the server be set to null instead of ''? The former means “no server”, the latter looks to most code like a server with ID ''.
In your setup, there also seems to be something else going wrong as an index without server cannot be enabled.

If you try to import invalid configuration it is clear that errors will occur, I wouldn’t say that is a bug in the code.

🇦🇹Austria drunken monkey Vienna, Austria

What exactly was the schema error. The default is search_api.default_processor_configuration, so if you needed to add search_api.fields_processor_configuration then maybe your processor inherits from FieldsProcessorPluginBase? In that case, it is expected that you would need to specify that explicitly, we have no way of detecting in the config schema whether a processor inherits from that.

For those processors that just inherit from ProcessorPluginBase it seems to work fine. For instance, there is no explicit schema for the entity_status processor.

🇦🇹Austria drunken monkey Vienna, Austria

Seems changes to test_dependencies might only take effect after they are merged, not when just inside a fork, based on the docs . So, in the spirit of experimentation, I just merged the MR. Let’s see what happens.

🇦🇹Austria drunken monkey Vienna, Austria

Seems the deprecation warnings were actually already fixed in Facets, see 🐛 Deprecations PHP 8.4 Active . We are just not using the latest dev version of the module, and there hasn’t been a stable release that includes that fix yet.
Let’s see, maybe I can get the CI to use the dev version of the module after all.

🇦🇹Austria drunken monkey Vienna, Austria

Thanks a lot for writing the test, looks great!
I just made a few minor changes, now I’d say this is RTBC.

🇦🇹Austria drunken monkey Vienna, Austria

Great to hear, thanks for the feedback!
Merged.
Thanks again, everyone!

🇦🇹Austria drunken monkey Vienna, Austria

Running this locally with XDebug enabled makes it immediately clear why PHPUnit fails to finish: The current code actually leads to an infinite loop, as the default method implementation \Drupal\search_api\Backend\BackendPluginBase::setConfiguration() actually calls $this->server->setBackendConfig(). Our current code actually already guarded against this, so that the config stays in sync no matter which method you call but you should still never get an infinite loop.
So, let’s just remove one condition from the if check and add the try/catch and that should fix all that.

Please test/review again!

🇦🇹Austria drunken monkey Vienna, Austria

Sorry if this is completely off-topic for this issue, but I’m unclear why setting a custom ignore file for deprecations via SYMFONY_DEPRECATIONS_HELPER: "ignoreFile=…" doesn’t work to prevent those failures in PHP 8.4 anymore? E.g., in this MR I added such a file for ignoring deprecation warnings triggered by a different Drupal module (since it makes no sense to fail on those), but the “phpunit (max PHP version)” job still fails because of output caused by the deprecation warning.

If there is really currently no way to avoid failing on deprecated code in other contrib modules (except to disable larger swaths of checks such as tests printing output) then I’m very much in favor of adding some mechanism for that. Though I’m not sure whether the proposed changes would actually allow for that or just help you disable failing on output.

🇦🇹Austria drunken monkey Vienna, Austria

There are currently no PHPCS failures in this module, see the scheduled pipelines.

🇦🇹Austria drunken monkey Vienna, Austria

Agreed that it’s important to keep this from becoming common, but probably already covered by the linked documentation. Let’s just adapt our tools to spot this.

🇦🇹Austria drunken monkey Vienna, Austria

That sounds completely sensible, thanks a lot for the suggestion and already creating an MR.
Merged.
Thanks again!

🇦🇹Austria drunken monkey Vienna, Austria

Changed my mind, let’s not throw an exception after all. Doesn’t really add any value there, I’d say.

🇦🇹Austria drunken monkey Vienna, Austria

Sure, that seems sensible. Thanks a lot for the suggestion!
I created an MR with your exact code. Feel free to give it a try. I’d also appreciate feedback from anyone else that wants to weigh in, otherwise I’d just merge it in a week or two.

There is a slight API change here in that setBackendConfig() can now throw an exception, but I feel like that shouldn’t really matter in the real world. But I might still want to add a change record for this, just to be on the safe side – not sure yet.

🇦🇹Austria drunken monkey Vienna, Austria

Thanks for reporting this problem.
Does the patch in Allow excluding unpublished references from index Active help? If you have the “Entity status” processor enabled the code in that issue’s MR might already resolve this for you.

🇦🇹Austria drunken monkey Vienna, Austria

Added link to the CacheExclude module.

🇦🇹Austria drunken monkey Vienna, Austria

Indexes on disabled servers should always be disabled themselves, so should not be returned by the loadByProperties() call. (See \Drupal\search_api\Entity\Server::preSave().)
Something seems to have gone wrong when disabling the server, or maybe you imported faulty config. Anyways, just disabling the affected indexed manually should resolve this problem for you. And if you do find out why the indexes weren’t correctly disabled, please file a separate bug report for that problem.

🇦🇹Austria drunken monkey Vienna, Austria

Thanks for reporting this issue. However, it sounds like this may already be covered by one of the existing issues in this queue:

The last of those has already be fixed, so please first make sure this bug still occurs with the latest dev version of the module. If so, then please try the patches/MRs from the other two issues and see if either of them resolves the problem for you.
Only if neither works and you are sure this is a separate issue then please change the status back to “Active”. Otherwise, please mark as “Closed (duplicate)”.

Thanks for your help!

🇦🇹Austria drunken monkey Vienna, Austria

Thanks for reporting this issue and sorry for the delay!
However, I’m afraid I cannot reproduce this problem:

$ drush sapi-s
 --------------------- ----------------------- ------------ --------- ------- 
  ID                    Name                    % Complete   Indexed   Total  
 --------------------- ----------------------- ------------ --------- ------- 
  default_index         Default content index   100%         233       233    
 --------------------- ----------------------- ------------ --------- -------
$ drush locale:update
…
$ drush sapi-s
 --------------------- ----------------------- ------------ --------- ------- 
  ID                    Name                    % Complete   Indexed   Total  
 --------------------- ----------------------- ------------ --------- ------- 
  default_index         Default content index   100%         233       233    
 --------------------- ----------------------- ------------ --------- -------

Am I doing something wrong for reproducing? Otherwise it seems some custom code or third-party module is to blame for this issue. You’d have to track calls to the appropriate method(s) on \Drupal\search_api\Entity\Index (probably reindex(), clear() or rebuildTracker()) or the tracker plugin and log the backtrace to figure out where the call is coming from.

🇦🇹Austria drunken monkey Vienna, Austria

Thanks for confirming!
I’m gonna leave this open another week in case anyone else wants to test and provide feedback, and will then merge the MR unless anyone objects.

🇦🇹Austria drunken monkey Vienna, Austria

Oops, overlooked this issue and fixed in 🐛 Fix failing pipelines Active instead.

🇦🇹Austria drunken monkey Vienna, Austria

Please test/review the MR so I can merge it.

🇦🇹Austria drunken monkey Vienna, Austria

@arousseau: Thatnks a lot for your feedback, good to hear this works for you! And also very important to know that this problem even exists anymore in the latest version of the module.

@prudloff: Thanks for that! So does the MR (still) work for you, did you try it?

@v.dovhaliuk: Can you also confirm that the MR works for you?
Just doing admin work on the issue without actually saying that the current patch/MR works for you doesn’t really help me move this along to finally merge it and fix the issue for everyone. As said, for issues that combine Views and caching I’m very reluctant to merge anything since a lot of changes in the past have just led to more issues.

Would anyone else here be able to test/review?

🇦🇹Austria drunken monkey Vienna, Austria

OK, thanks for the further input. Based on this it does seem like a change in the Metatag module is the root cause of this. It seems like field_metatags was previously defined as having a complex data type, with child properties like keywords and description, but now uses a custom data type that is scalar and thus cannot be properly indexed. However, I’m not using the Metatag module myself so I cannot speak to the underlying reasons for those changes and what we can do about them.

Moving this to the Metatag issue queue as it seems pretty likely that any fix for this would have to happen there, but not sure whether it’s clear to anyone that doesn’t have detailed knowledge of both Search API and Metatag internals what the proper fix here would be. Anyways, maybe some Metatag expert can still chime in here and we can figure this out.

🇦🇹Austria drunken monkey Vienna, Austria

Thanks a lot for your work on this, great job so far! However, there are still a couple of problems, as evidenced by the failing tests:

  • I think SearchApiViewHooks is missing a services.yml entry.
  • (I’d also call that class SearchApiViewsHooks, as the module name is “Views”.)
  • I don’t think we can use autowire yet, but I just temporarily enabled testing against other Drupal versions in the fork to validate that assumption.
  • Services in the two Hooks classes should be accessed via dependency injection (which is also why autowire would even be needed, I think), not via the global \Drupal class. As a rule, classes that are able to use dependency injection should not contain the string '\Drupal::'.

I already implemented the first two items, but please address the last one as well as the failing MR pipelines.

🇦🇹Austria drunken monkey Vienna, Austria

Thanks for creating an MR, but I don’t think this is actually a bug. The annotation itself is for any search display, while those properties are specific to Views displays. I don’t think it makes sense to add those properties to the general-purpose @SearchApiDisplay annotation.
Is there any actual problem caused by this?

🇦🇹Austria drunken monkey Vienna, Austria

Great to hear, thanks for confirming!
Merged.
Thanks again, everyone!

🇦🇹Austria drunken monkey Vienna, Austria

As far as I can tell, adding those return type hints was abandoned in the final version of the MR, so nothing for us to do here.

🇦🇹Austria drunken monkey Vienna, Austria

There actually is already code that should be handling this nested structure:

      while (count($data) === 1) {
        $tmp = reset($data);
        if (!is_array($tmp)) {
          break;
        }
        $data = $tmp;
      }

However, it seems since I wrote this the response structure has slightly changed: an additional metadata property has been added at the top level so the count($data) === 1 check fails right away. The changes in this MR should fix the functionality again while still keeping the code as flexible as possible wrt different keys used in the response.
Please review!

🇦🇹Austria drunken monkey Vienna, Austria

What do you mean with “before”? What exactly did you update (and from/to which version)?
This seems more like a change in the Metatag module, not this one. Did you update Metatag, too, and does reverting that update restore the functionality?

🇦🇹Austria drunken monkey Vienna, Austria

I agree, people should definitely get off those old Drupal versions. And yes, I won’t provide support for those anymore.
But, as said on Slack, just commiting patches as-is (or fixing one typo, admittedly) should still be fine.
Committed. Thanks again!

🇦🇹Austria drunken monkey Vienna, Austria

Seems these were added to the ignored deprecation warnings of Core as part of 🐛 twig/twig in drupal/recommended-settings is at it again Active .
Adapted our custom override of that file in this MR. Let’s see whether the test bot likes it.

🇦🇹Austria drunken monkey Vienna, Austria

Good to hear, thanks for reporting back.
Not 100% sure how to handle this correctly, but probably we should just search all available fields if no valid ones are selected.
Well, the proper fix would probably be to listen to search index updates and adapt all associated search views accordingly, but that’s a lot of effort for very little actual benefit, I’d say. So, created an MR for the former approach.

🇦🇹Austria drunken monkey Vienna, Austria

@cemckinnie: There is no new processor, this just changes the behavior when using the (existing) “Entity status” processor.

🇦🇹Austria drunken monkey Vienna, Austria

Oh, thanks for pointing that out! Since we generally don’t really check whether the data included in the result row is actually used in the view, and it adds no extra cost to getRowId() (though it might of course lead to too much cache variation, decreasing overall performance), I think we can just include that anyways.

Note that we already had a similar proposal in #3026526: SearchApiTagCache::getRowId is very expensive but then ended up just using the item ID after all (see comment #5 ).

I also cleaned up the structure of the $row_data array a bit. Currently, we just added stuff to the top array which seems like it might lead to key collisions, potentially losing important information.

Finally: Is there a reason this is only in the SearchApiTagCache class and not on SearchApiCachePluginTrait to be used by all our cache plugins?
I don’t think this makes sense and corrected this in the MR, but please do correct me if I’m wrong. As I keep repeating I am not that familiar with the Cache API and especially Views’ interaction with it so I pretty much have to rely on others providing well-written code or correcting mine. (Which hasn’t worked great, historically, as we see here.)

Also, I noticed that (unrelatedly) the new SearchApiTagTimeCache plugin added in Add a third Views cache plugin (tag- and time-based) Needs work doesn’t even use the trait, for some reason. I’m pretty sure this will break lots of things and can only be an oversight, though it’s troubling that our tests don’t pick it up.
I’ve fixed that in the MR, too. As above, please correct me if you think I’m wrong.

Thanks for everyone’s work on this! I hope together we can end up with something that really works in as many cases as possible and doesn’t break any existing functionality.

In any case, we still need to figure out that test fail and add a regression test. (Though I guess the former is kinda optional since it was broken already – could just be a follow-up since it doesn’t seem to lead to problems in real environments.)

🇦🇹Austria drunken monkey Vienna, Austria

Right, that makes sense. Changing issue properties accordingly and moving to the correct queue.

Production build 0.71.5 2024