Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Fix deprecated: third parameter of preg_replace() must not be null #10576

Merged
merged 1 commit into from
Aug 6, 2024
Merged

[5.x] Fix deprecated: third parameter of preg_replace() must not be null #10576

merged 1 commit into from
Aug 6, 2024

Conversation

miloslavkostir
Copy link
Contributor

Statamic\Search\Comb\Comb::flattenArray($item, $glue = ' '):
The parameter $item is mixed (null as well). The third parameter of preg_replace() must be array|string. PHP 8.1+ triggers a deprecated error if $item is null.

// If $item is not array...
if (! is_array($item)) {
    // ...it must be string
    return preg_replace('#\s+#ism', ' ', (string) $item);
}

Test script (does not work in Tests\Search\CombTest):

<?php

use Statamic\Search\Comb\Comb;

require_once __DIR__ . '/vendor/autoload.php';

ini_set('error_reporting', E_ALL);

$comb = new Comb([
    ['title' => 'John Doe', 'email' => null],
    ['title' => 'Jane Doe', 'email' => '[email protected]'],
]);

var_dump($comb->lookUp('John'));

@miloslavkostir miloslavkostir changed the title Fix deprecated: third parameter of preg_replace() must not be null [5.x] Fix deprecated: third parameter of preg_replace() must not be null Aug 6, 2024
@jasonvarga jasonvarga merged commit cbb1f97 into statamic:5.x Aug 6, 2024
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants