Commit c96d52ca authored by epriestley's avatar epriestley
Browse files

(stable) Fix an issue where "Export Data" could fail if a user had a nonempty...

(stable) 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
parent b9d52f38
......@@ -964,8 +964,14 @@ final class PhabricatorApplicationSearchController
private function readExportFormatPreference() {
$viewer = $this->getViewer();
$export_key = PhabricatorPolicyFavoritesSetting::SETTINGKEY;
return $viewer->getUserSetting($export_key);
$export_key = PhabricatorExportFormatSetting::SETTINGKEY;
$value = $viewer->getUserSetting($export_key);
if (is_string($value)) {
return $value;
}
return '';
}
private function writeExportFormatPreference($value) {
......@@ -976,7 +982,7 @@ final class PhabricatorApplicationSearchController
return;
}
$export_key = PhabricatorPolicyFavoritesSetting::SETTINGKEY;
$export_key = PhabricatorExportFormatSetting::SETTINGKEY;
$preferences = PhabricatorUserPreferences::loadUserPreferences($viewer);
$editor = id(new PhabricatorUserPreferencesEditor())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment