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.
Under some PHP configs, passing the return value of a method to empty() can cause a fatal error. Thus, this segment in AddThisScriptManager.php
if (!empty($this->addthis->getTwitterVia())) {
$addthis_share['passthrough']['twitter']['via'] = $this->addthis->getTwitterVia();
}
if (!empty($this->addthis->getTwitterText())) {
$addthis_share['passthrough']['twitter']['text'] = $this->addthis->getTwitterText();
}
can trigger the following error:
Fatal error: Can't use method return value in write context in addthis/classes/Services/AddThisScriptManager.php on line 229
The attached patch corrects this by saving the method return values to variables before using empty().
Comment | File | Size | Author |
---|---|---|---|
AddThisScriptManager-fatal-error.patch | 985 bytes | muriqui |
Comments
Comment #1
raphaelhuefner CreditAttribution: raphaelhuefner commentedThank you for the patch, @muriqui !
I encountered the same issue.
This patch resolved it for me!
All PHP versions prior to 5.5.0 are affected.
See http://www.php.net/manual/en/function.empty.php
and
It worked on my local dev machine (PHP 5.5.18) without the patch, but after deploying to the server (PHP 5.3.5), it blew up. (Obviously, I should've had the same PHP version on my local as on the server.)
Comment #2
matason CreditAttribution: matason at Code Enigma commentedThank you @muriqui
I tested the patch on addthis-7.x-4.x-dev, it applies cleanly and fixes the fatal error.
Comment #4
matglas86 CreditAttribution: matglas86 commented