@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PhabricatorLiskDAO: Fragment serializer cache by class

Summary:
This restores the pre-PHP 8.1 behavior, where values of
static variables within inherited methods were independent
of each other. With PHP 8.1, this was changed to be truly
'static', which causes problems when one derivate of
PhabricatorLiskDAO defines a custom serializer but another
does not.

This came to light in T15726, but only for the Fund application,
which is a prototype, and deprecated. This fixes Fund, but
more importantly, everything else that would be broken by
this, whatever it was.

Ref: https://wiki.php.net/rfc/static_variable_inheritance

Previous stacktrace:
```
EXCEPTION: (RuntimeException) Undefined array key "totalAsCurrency" at [<arcanist>/src/error/PhutilErrorHandler.php:273]
#0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php:345]
#1 <#2> PhabricatorLiskDAO::willWriteData(array) called at [<phorge>/src/infrastructure/storage/lisk/LiskDAO.php:1085]
#2 <#2> LiskDAO::insertRecordIntoDatabase(string) called at [<phorge>/src/infrastructure/storage/lisk/LiskDAO.php:958]
#3 <#2> LiskDAO::insert() called at [<phorge>/src/infrastructure/storage/lisk/LiskDAO.php:927]
#4 <#2> LiskDAO::save() called at [<phorge>/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php:1405]
[...]
```

Test Plan:
On PHP 8.1+:
1. Visit http://phorge.localhost/applications/ and enable the deprecated prototype applications "Fund" and "Phortune" via "Configure"
2. Visit http://phorge.localhost/phortune/merchant/edit/ and create a merchant
3. Visit http://phorge.localhost/fund/create/ and click the "Create New Initiative" button

Reviewers: O1 Blessed Committers, aklapper, valerio.bozzolan

Reviewed By: O1 Blessed Committers, aklapper, valerio.bozzolan

Subscribers: aklapper, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15064

Differential Revision: https://we.phorge.it/D25859

+12 -10
+12 -10
src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
··· 322 322 protected function willReadData(array &$data) { 323 323 parent::willReadData($data); 324 324 325 - static $custom; 326 - if ($custom === null) { 327 - $custom = $this->getConfigOption(self::CONFIG_APPLICATION_SERIALIZERS); 325 + static $custom = array(); 326 + if (!isset($custom[static::class])) { 327 + $custom[static::class] = $this->getConfigOption( 328 + self::CONFIG_APPLICATION_SERIALIZERS); 328 329 } 329 330 330 - if ($custom) { 331 - foreach ($custom as $key => $serializer) { 331 + if (!empty($custom[static::class])) { 332 + foreach ($custom[static::class] as $key => $serializer) { 332 333 $data[$key] = $serializer->willReadValue($data[$key]); 333 334 } 334 335 } 335 336 } 336 337 337 338 protected function willWriteData(array &$data) { 338 - static $custom; 339 - if ($custom === null) { 340 - $custom = $this->getConfigOption(self::CONFIG_APPLICATION_SERIALIZERS); 339 + static $custom = array(); 340 + if (!isset($custom[static::class])) { 341 + $custom[static::class] = $this->getConfigOption( 342 + self::CONFIG_APPLICATION_SERIALIZERS); 341 343 } 342 344 343 - if ($custom) { 344 - foreach ($custom as $key => $serializer) { 345 + if (!empty($custom[static::class])) { 346 + foreach ($custom[static::class] as $key => $serializer) { 345 347 $data[$key] = $serializer->willWriteValue($data[$key]); 346 348 } 347 349 }