Page MenuHomePhorge

Exception: Call to undefined method PhutilJSON::encodeAsObject()
Closed, ResolvedPublic

Description

Steps to reproduce:

Unclear. However seems to require having non-default fields defined in maniphest.custom-field-definitions which are not scalar/array/null but object or resource, and changing that field value in a form via http://phorge.localhost/transactions/editengine/maniphest.task/ and Change Default Values.

Code inspection:

Reading the Phorge code at bcfcd9acfc12fdf8ca3bf0e2c89651ba6d159b17 in
https://we.phorge.it/source/phorge/browse/master/src/applications/transactions/xaction/PhabricatorEditEngineDefaultTransaction.php$68,
private function renderDefaultValueAsFallbackText($default_value) returns
return id(new PhutilJSON())->encodeAsObject($default_value);
But https://we.phorge.it/source/arcanist/browse/master/src/parser/PhutilJSON.php does not define encodeAsObject (only encodeAsList), and according to https://secure.phabricator.com/source/libphutil/history/master/src/parser/PhutilJSON.php never has.
Should likely call encodeFormatted instead.

This code was introduced in rP37e26f1b45315872a2483cc76a5037f0524ac03a

Actual outcome:

Found while looking at our server logs. We do run an old version but this code has not changed. So I have reasons to assume that this is still an issue in current upstream.

[2023-08-14 01:52:07] EXCEPTION: (Error) Call to undefined method PhutilJSON::encodeAsObject() at [<phabricator>/src/applications/transactions/xaction/PhabricatorEditEngineDefaultTransaction.php:68]
PHP message: arcanist(), ava(), phabricator(), translations(), wmf-ext-misc()
   #0 phlog(Error) called at [<phabricator>/src/aphront/handler/PhabricatorDefaultRequestExceptionHandler.php:41]
   #1 PhabricatorDefaultRequestExceptionHandler::handleRequestThrowable(AphrontRequest, Error) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:751]
   #2 AphrontApplicationConfiguration::handleThrowable(Error) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:296]
   #3 AphrontApplicationConfiguration::processRequest(AphrontRequest, PhutilDeferredLog, AphrontPHPHTTPSink, MultimeterControl) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:204]
   #4 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:35]'