- Issue created by @webdrips
- Status changed to Postponed: needs info
almost 2 years ago 7:54am 7 February 2023 - 🇳🇱Netherlands Lendude Amsterdam
@webdrips thanks for reporting this.
If I just follow your steps to reproduce on a clean Drupal install I don't see this issue.
The steps seem a bit minimal, since the block isn't actually placed with them. Looking at the stack trace it seems to be placed using Layout builder, is that relevant or do you get this error when you place it anywhere?
Also the stack trace doesn't appear to touch the Combined field filter at all, so is that needed to trigger this or can you trigger this with other exposed filters too? - 🇳🇱Netherlands Yuri
I have the exact same error.
In my case I don't use the combined fields filter.
But, I did use an exposed filter in a views block display, which triggered the error, regardless whether ajax was turned on or not.
Using Drupal distribution Open Social 11.7.1 which uses Drupal 9.4.11 - 🇺🇸United States webdrips
Hi @Lendude ahh yes sorry about that.
This is a bit more complex as we're using the exposed filter as a "normal" block, and the view block was placed using the Layout Builder as you suggested. We use a patch for layout builder to provide visibility rules. We're essentially taking the approach of trying to use Drupal's core modules as much as possible for maintainability.
In this case, we added the block with the layout builder, and used a taxonomy term value to control visibility.
The patch that allows that is here: https://www.drupal.org/project/drupal/issues/2916876 ✨ Add visibility control conditions to blocks within Layout Builder Needs work
We have 27 core patches for this project, so there may be others involved in pulling this off.
If I remove the combined filter block, the error disappears. If I put it back, I need to click search (with or without a value in the search field doesn't matter).
I'm happy to show you the issue over Zoom if it helps at all.
- Status changed to Active
about 1 year ago 10:21pm 16 November 2023 - Assigned to samit.310@gmail.com
- Status changed to Needs work
9 months ago 8:11am 11 March 2024 - Merge request !69893338057: Deprecated function: preg_match() → (Open) created by samit.310@gmail.com
- Issue was unassigned.
- Status changed to Needs review
9 months ago 10:02am 11 March 2024 - Status changed to Needs work
9 months ago 1:28pm 11 March 2024 - 🇺🇸United States smustgrave
#2 it was mentioned that this wasn't reproducible.
But if this is a bug research needs to be done to find why that parameter is empty vs just putting a check in.
- 🇺🇸United States maskedjellybean Portland, OR
The patch from the MR works for me in 10.1.8 to resolve this error thrown by a view. The view then functions as it should. Not sure what to make of that.
- First commit to issue fork.
- Merge request !9314Reroll patch from https://www.drupal.org/project/drupal/issues/3338057 to drupal 10.3 → (Closed) created by Carlitus
- 🇪🇸Spain Carlitus
Upps, sorry, i did something wrong with this MR. I will try to fix this.
- First commit to issue fork.
- 🇵🇹Portugal dxvargas
As I understand, no one here had any other problem except getting the deprecated warning. This is my case. Everything is working as expected except that I see this warning.
So, why not to just avoid this warning in the most simpler way possible?
This is what I understand that Symfony did. In the documentation, it says that the code is adapted from
\Symfony\Component\Routing\Generator\UrlGenerator::doGenerate().
If we check the changes in this method, they are basically replacing$mergedParams[$token[3]]
with$mergedParams[$token[3]] ?? ''
.
Please check here the old code:
https://github.com/symfony/routing/blob/3.4/Generator/UrlGenerator.php#L...
And check here the new code:
https://github.com/symfony/routing/blob/7.1/Generator/UrlGenerator.php#L...In my case (that I miss to reproduce in a vanilla install, thus I won't explain in detail) I get an error when I apply the patch in a piece of code that apparently has nothing to do with this.
I can briefly say that it's in a hook in private message entity (from the private_message module) that is displayed in layout builder, because the entity has no longer a owner. My code is heavily customized, it's difficult to debug the new error and explain what is happening.
Anyway, I think my case demonstrates how a change here can have unexpected impacts.One think that looks suspicious in the current MR changes is that before, for each $tokens, the $url was being set with a new value.
With the changes in the current MR, if the variable $optional is true, the $url will remain unchanged.
I don't really understand all the logic here. But this doesn't look right.I don't want to just change the MR in a completely different approach, so I'll just leave a patch here with the change I'm proposing.
- 🇺🇸United States webdrips
#19 didn't fix my issue (same error as before), and #17 didn't apply to 10.3.2 for me anyway, so I'm attaching a patch that worked fine for me in case anyone needs it.
- 🇵🇹Portugal dxvargas
@webdrips it is impossible that you have the same error after applying the patch in #19.
There is only preg_match() method here and it receiving as second argument ($subject) this:$mergedParams[$token[3]] ?? ''
, and this is never NULL.My patch in #19 fixes the problem.
About your patch in #20, I have the same problem that I had with the changes in the MR.
That patch changes the logic!Before, if
$mergedParams[$token[3]]
is null,!preg_match('#^' . $token[2] . '$#', $mergedParams[$token[3]] ?? '')
evaluates to TRUE and an exception is thrown and no$url
is returned.
After your patch, if$mergedParams[$token[3]]
is null, the processing goes to$url = $token[1] . $url;
and continues.A patch here cannot change the logic. If the logic is not good, please fill another issue and let's discuss that.
Here we just need to make the PHP warning go away. Patch #19 does that.