- Issue created by @allandk
- Assigned to Binoli Lalani
- @binoli-lalani opened merge request.
- Issue was unassigned.
- 🇮🇳India Binoli Lalani Gujarat
Hello,
I have created MR to fix this warning. Please review.
Thank you!
- Status changed to Needs review
almost 2 years ago 9:16am 30 January 2023 - Status changed to Needs work
almost 2 years ago 3:26pm 30 January 2023 - 🇺🇸United States pianomansam
Let's get some tests around reproducing and solving this.
- public function tokensPreAlter(&$text, $data, $options) { + public function tokensPreAlter(string &$text, $data, $options) {
@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
. I also faced this problem:
And i think the best solution is to check if
$text
is string and then find matches.
Attached patch here and updated the issue branch.- last update
over 1 year ago 5 pass - Status changed to Needs review
over 1 year ago 12:27pm 24 July 2023 - last update
over 1 year ago 5 pass - Status changed to Needs work
over 1 year ago 2:27pm 24 July 2023 - 🇺🇸United States pianomansam
@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?
@pianomansam, sure.
In my case tt 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 📌 Drupal 10 compatibility fixes Fixed )
- token_or 2.1.0Let me know if i should attached detailed settings of quiz module.
- 🇺🇸United States pianomansam
@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?
- last update
over 1 year ago 6 pass - @pianomansam opened merge request.
- last update
over 1 year ago 6 pass -
pianomansam →
committed f332b15e on 2.x
Issue #3337496 by fromme, pianomansam: Deprecated function:...
-
pianomansam →
committed f332b15e on 2.x
- Status changed to Fixed
over 1 year ago 3:08pm 25 July 2023 - 🇺🇸United States pianomansam
I was able to reproduce this issue. Apparently, some modules directly send
NULL
into the token service. Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
3 months ago 10:52am 20 August 2024 - 🇵🇭Philippines bryanmanalo
I 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.
- 🇺🇸United States pianomansam
@bryanmanalo this issue was resolved in release 2.1.1. Are you still experiencing it?
- 🇵🇭Philippines bryanmanalo
Yes, I experienced the issue in another part of the codebase. However, it could just be a combination of using this and menu_token module.
- Status changed to Needs work
3 months ago 1:28pm 21 August 2024 - 🇺🇸United States pianomansam
@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!$empty
so there must be something that empty catches that false does not. So, in order to get this resolved we need to do the following:- Identify the value of $text
- Write a test that fails
- Fix the logic so that the test passes