Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
System throw a warning sending mails:
Deprecated function: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in Drupal\smtp\PHPMailer\PHPMailer->EncodeQ() (line 1762 of modules/contrib/smtp/src/PHPMailer/PHPMailer.php).
public function EncodeQ($str, $position = 'text') {
// There should not be any EOL in the string
$encoded = preg_replace('/[\r\n]*/', '', $str);
switch (strtolower($position)) {
case 'phrase':
$encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
break;
case 'comment':
$encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
case 'text':
default:
// Replace every high ascii, control =, ? and _ characters
//TODO using /e (equivalent to eval()) is probably not a good idea
$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
"'='.sprintf('%02X', ord('\\1'))", $encoded);
break;
}
// Replace every spaces to _ (more readable than =20)
$encoded = str_replace(' ', '_', $encoded);
return $encoded;
}
Comment | File | Size | Author |
---|---|---|---|
#2 | preg_replace_the_e-2656264-2.patch | 1.57 KB | estoyausente |
|
Comments
Comment #2
estoyausenteChanging it to preg_replace_callback (more info: http://php.net/manual/es/function.preg-replace-callback.php)
Comment #3
ptmkenny CreditAttribution: ptmkenny commentedConfirmed the error exists as described in the original issue.
Applied the patch on Drupal 8.0.2 on Pantheon.
The deprecated error is fixed, but now I get a new error:
Warning: preg_replace_callback(): Requires argument 2, '5C', to be a valid callback in Drupal\smtp\PHPMailer\PHPMailer->EncodeQ() (line 1761 of modules/smtp/src/PHPMailer/PHPMailer.php).
Comment #4
estoyausenteSorry, it was my fail.
This is a PHPMailer task and it should to be resolved in their github.
https://github.com/PHPMailer/PHPMailer/issues/187
And really, it's done but we are using a old phpMailer version (5.1).
Comment #5
olilo CreditAttribution: olilo commentedHello
Is it a new patch planed to fix the new warning message after applying this patch:
Warning: preg_replace_callback(): Requires argument 2, '5C', to be a valid callback in Drupal\smtp\PHPMailer\PHPMailer->EncodeQ() (line 1761 of modules/smtp/src/PHPMailer/PHPMailer.php)
I don't see this issue on the github of PHPmailer
It is good to have a patch to fix a warning error message but if you receive another one in place...
Comment #6
estoyausenteIt is patched several years ago. We are using a very old library version. I'm trying to port it using a new version and Composer for controlling the dependency:
https://www.drupal.org/node/2711559
But... need more hands or more time :)