PHP Deprecated: a:5:{s:11:"deprecation";s:95:"http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated";s:5:"class";s:50:"Drupal\Tests\search_api_solr\Functional\FacetsTest";s:6:"method";s:10:"testFacets"

PHP Deprecated: a:5:{s:11:"deprecation";s:230:"Return type of Drupal\search_api\Item\Field::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice"

PHP Deprecated: a:5:{s:11:"deprecation";s:79:"strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated"

Deprecated function: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Comments

mkalkbrenner created an issue. See original summary.

mkalkbrenner’s picture

Project: Facets » Search API
Version: 2.0.x-dev » 8.x-1.x-dev
Component: Code » General code
mkalkbrenner’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new2.77 KB
mkalkbrenner’s picture

Issue summary: View changes
mkalkbrenner’s picture

StatusFileSize
new4.46 KB
drunken monkey’s picture

StatusFileSize
new4.46 KB
new6.05 KB

Thanks a lot for your work on this so far, and thanks for pinging me about it.

Your changes so far are looking good, just one comment:

</code><code>
+++ b/src/Utility/Utility.php
@@ -139,7 +139,7 @@ class Utility {
-    $pos = $function($property_path, $separator);
+    $pos = $function((string) $property_path, $separator);

By the method’s contract, $property_path already has to be a string, so we should fix the caller instead. (In a second step, we might of course want to add proper type hints.)

I also managed to fix some of the remaining warnings.

Unfortunately, though, my distro doesn’t include PHP 8.1 yet, and I didn’t manage to get MySQL working in my manual build. So especially the autocomplete fail, which I couldn’t reproduce, may just be specific to MySQL.

Furthermore, for the problems in system_requirements() and \Drupal\Core\Extension\ModuleDependencyMessageTrait::checkDependencyMessage() it seems to me like this might be Core’s fault: it sets the default for 'version' to NULL in \Drupal\Core\Extension\ModuleExtensionList::$defaults, which then leads to those errors. Changing this default to '' fixes the warnings for me.

alexpott’s picture

I can't reproduce the autocomplete fail locally on PHP 8.1 / 9.3.x and mysql / sqlite or psql ... looks like something specific to mysql on DrupalCI... that's not fun.

alexpott’s picture

StatusFileSize
new614 bytes
new6.61 KB

I think that maybe order is not something that we need to care about here so perhaps the simplest thing to do is change the assert.

alexpott’s picture

StatusFileSize
new614 bytes
new6.01 KB

Okay so I far as I can see the fail in \Drupal\Tests\search_api_db\Kernel\AutocompleteTest::testAutocompletion is related to DrupalCI mysql 5.7. If I get the docker container and use that in local testing then this test fails regardless of PHP version.

I'm going to open another issue to fix this. The change in #9 is wrong so reverting.

alexpott’s picture

alexpott’s picture

+++ b/src/Item/Field.php
@@ -665,7 +665,7 @@ class Field implements \IteratorAggregate, FieldInterface {
-  public function getIterator() {
+  public function getIterator(): \Traversable {

+++ b/src/Item/Item.php
@@ -455,7 +455,7 @@ class Item implements \IteratorAggregate, ItemInterface {
-  public function getIterator() {
+  public function getIterator(): \Traversable {

+++ b/src/Query/ResultSet.php
@@ -224,7 +224,7 @@ class ResultSet implements \IteratorAggregate, ResultSetInterface {
-  public function getIterator() {
+  public function getIterator(): \Traversable {

If you know of upstream projects that extend these classes and override these methods it might be friendlier to add the [#\ReturnTypeWillChange] PHP attribute instead.

alexpott’s picture

StatusFileSize
new1.25 KB
new5.95 KB
new1.25 KB

We can change the return types in the upcoming 2.0.x version of Search API

drunken monkey’s picture

Status: Needs review » Fixed

Awesome, thanks a lot for your help! Great we even got the Core issue fixed …

I’m pretty sure no-one overrides any of those classes, but you’re right, it’s cleaner not to introduce a BC break for this.

So, no objections to your last patch. Committed. Thanks again!

idebr’s picture

@drunken monkey Facets module is reporting PHP8.1 deprecations since it depends on Search API. Is there a plan for a minor release?

[edit] See https://www.drupal.org/node/2348769/qa

andypost’s picture

Filed follow-up for facets #3255241: Add compatibility with PHP 8.1

drunken monkey’s picture

@drunken monkey Facets module is reporting PHP8.1 deprecations since it depends on Search API. Is there a plan for a minor release?

Huh, strange … I though automated tests will use the latest dev version by default, not the latest stable release.
Anyways, yes, I’ll create a new release shortly, so should be resolved soon.

Status: Fixed » Closed (fixed)

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

michele bertani’s picture

there are plan to incorporate this patch on the 8.x branch?

idebr’s picture

This issue was released in 8.x-1.22, see https://www.drupal.org/project/search_api/releases/8.x-1.22

michele bertani’s picture

StatusFileSize
new382 bytes

with php 8.1 and v8.x-1.25 i still have deprecation errors
Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\search_api\Utility\Utility::splitPropertyPath()

this is the patch i have used to solve the issue

idebr’s picture

#22 That particular code wasn't touched in the code committed in this issue. I suggest you file a new follow-up issue and upload your patch file there, since this issue is now Closed.