Needs work
Project:
Token OR
Version:
2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Jan 2023 at 08:35 UTC
Updated:
17 Mar 2025 at 18:51 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
binoli lalani commentedComment #4
binoli lalani commentedHello,
I have created MR to fix this warning. Please review.
Thank you!
Comment #5
binoli lalani commentedComment #6
pianomansam commentedLet's get some tests around reproducing and solving this.
@binoli-lalani I'm not sure this is the best approach. How can we be sure that the code upstream only passes in a string? In fact, this error report indicates that it's passing in
NULL.Comment #7
fromme commentedI also faced this problem:

And i think the best solution is to check if
$textis string and then find matches.Attached patch here and updated the issue branch.
Comment #8
fromme commentedComment #9
pianomansam commented@fromme thank you for your report and patch. I'm having a hard time reproducing this. Before a patch can be accepted, we need a test that can reproduce and test that the patch fixes the issue. Can you at least help me reproduce it?
Comment #10
fromme commented@pianomansam, sure.
In my case it happens while using quiz module - on add/edit forms of quizes and questions.
Enabled modules of quiz - https://prnt.sc/QvqqrdtJnKD_
I tested with:
- drupal 10.0.10;
- quiz 6.x-dev#6d6f65d9 + patch for d10 (https://www.drupal.org/project/quiz/issues/3356316)
- token_or 2.1.0
Let me know if i should attached detailed settings of quiz module.
Comment #11
pianomansam commented@fromme testing with the quiz module sounds pretty involved, so I'm not sure it will work here. Out of curiosity, what's the token you're using that gives the error?
Comment #15
pianomansam commentedI was able to reproduce this issue. Apparently, some modules send
NULLinto the token service 😒Comment #17
bryanmanalo commentedI was able to replicate this issue.
This is the error that I am getting.
Deprecated function: preg_match_all(): Passing null to parameter #2 ($subject) of type string is deprecated in Drupal\token_or\Token->scan() (line 35 of modules/contrib/token_or/src/Token.php).
Adding a patch.
Comment #18
pianomansam commented@bryanmanalo this issue was resolved in release 2.1.1. Are you still experiencing it?
Comment #19
bryanmanalo commentedYes, I experienced the issue in another part of the codebase. However, it could just be a combination of using this and menu_token module.
Comment #20
pianomansam commented@bryanmanalo that's unfortunate. Does your patch resolve this issue for your site? If so, we'll need to determine what kind of value is being pass in as
$text. I see your patch usesempty($text)while the current release uses!$emptyso there must be something that empty catches that false does not. So, in order to get this resolved we need to do the following:Comment #21
liam morlandAdding a type declaration or cast could detect or fix this.