@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.

Fix an issue where "Export Data" could fail if a user had a nonempty custom policy preference

Summary:
The "Export Data" workflow incorrectly uses the "Policy Favorites" setting to choose a default export format. This is just a copy/paste error; the correct setting exists and is unused.

If the setting value is an array (as the "Policy Favorites" value often is), we try to use it as an array index. This generates a runtime exception after D21044.

```
[2020-06-16 06:32:12] EXCEPTION: (RuntimeException) Illegal offset type in isset or empty at [<arcanist>/src/error/PhutilErrorHandler.php:263]
#0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer, array) called at [<phabricator>/src/applications/search/controller/PhabricatorApplicationSearchController.php:460]
```

- Use the correct setting.
- Make sure the value we read is a string.

Test Plan:
- Used "Export Data" with a nonempty, array-valued "Policy Favorites" setting.
- Before: runtime exception.
- After: clean export.
- Used "Export Data" again, saw my selection from the first time persisted.

Differential Revision: https://secure.phabricator.com/D21361

+9 -3
+9 -3
src/applications/search/controller/PhabricatorApplicationSearchController.php
··· 964 964 965 965 private function readExportFormatPreference() { 966 966 $viewer = $this->getViewer(); 967 - $export_key = PhabricatorPolicyFavoritesSetting::SETTINGKEY; 968 - return $viewer->getUserSetting($export_key); 967 + $export_key = PhabricatorExportFormatSetting::SETTINGKEY; 968 + $value = $viewer->getUserSetting($export_key); 969 + 970 + if (is_string($value)) { 971 + return $value; 972 + } 973 + 974 + return ''; 969 975 } 970 976 971 977 private function writeExportFormatPreference($value) { ··· 976 982 return; 977 983 } 978 984 979 - $export_key = PhabricatorPolicyFavoritesSetting::SETTINGKEY; 985 + $export_key = PhabricatorExportFormatSetting::SETTINGKEY; 980 986 $preferences = PhabricatorUserPreferences::loadUserPreferences($viewer); 981 987 982 988 $editor = id(new PhabricatorUserPreferencesEditor())