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

Export "date" and "remarkup" custom fields to Excel + "zip" extension check

Summary:
Fixes T13342. This does a few different things, although all of them seem small enough that I didn't bother splitting it up:

- Support export of "remarkup" custom fields as text. There's some argument here to export them in some kind of structure if the target is JSON, but it's hard for me to really imagine we'll live in a world some day where we really regret just exporting them as text.
- Support export of "date" custom fields as dates. This is easy except that I added `null` support.
- If you built PHP from source without "--enable-zip", as I did, you can hit the TODO in Excel exports about "ZipArchive". Since I had a reproduction case, test for "ZipArchive" and give the user a better error if it's missing.
- Add a setup check for the "zip" extension to try to avoid getting there in the first place. This is normally part of PHP so I believe users generally won't hit it, I just hit it because I built from source. See also T13232.

Test Plan:
- Added a custom "date" field. On tasks A and B, set it to null and some non-null value. Exported both tasks to Excel/JSON/text, saw null and a date, respectively.
- Added a custom "remarkup" field, exported some values, saw the values in Excel.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13342

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

+64 -2
+2
src/__phutil_library_map__.php
··· 5023 5023 'PhabricatorXHProfSampleQuery' => 'applications/xhprof/query/PhabricatorXHProfSampleQuery.php', 5024 5024 'PhabricatorXHProfSampleSearchEngine' => 'applications/xhprof/query/PhabricatorXHProfSampleSearchEngine.php', 5025 5025 'PhabricatorYoutubeRemarkupRule' => 'infrastructure/markup/rule/PhabricatorYoutubeRemarkupRule.php', 5026 + 'PhabricatorZipSetupCheck' => 'applications/config/check/PhabricatorZipSetupCheck.php', 5026 5027 'Phame404Response' => 'applications/phame/site/Phame404Response.php', 5027 5028 'PhameBlog' => 'applications/phame/storage/PhameBlog.php', 5028 5029 'PhameBlog404Controller' => 'applications/phame/controller/blog/PhameBlog404Controller.php', ··· 11449 11450 'PhabricatorXHProfSampleQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 11450 11451 'PhabricatorXHProfSampleSearchEngine' => 'PhabricatorApplicationSearchEngine', 11451 11452 'PhabricatorYoutubeRemarkupRule' => 'PhutilRemarkupRule', 11453 + 'PhabricatorZipSetupCheck' => 'PhabricatorSetupCheck', 11452 11454 'Phame404Response' => 'AphrontHTMLResponse', 11453 11455 'PhameBlog' => array( 11454 11456 'PhameDAO',
+29
src/applications/config/check/PhabricatorZipSetupCheck.php
··· 1 + <?php 2 + 3 + final class PhabricatorZipSetupCheck extends PhabricatorSetupCheck { 4 + 5 + public function getDefaultGroup() { 6 + return self::GROUP_OTHER; 7 + } 8 + 9 + protected function executeChecks() { 10 + if (!extension_loaded('zip')) { 11 + $message = pht( 12 + 'The PHP "zip" extension is not installed. This extension is '. 13 + 'required by certain data export operations, including exporting '. 14 + 'data to Excel.'. 15 + "\n\n". 16 + 'To clear this setup issue, install the extension and restart your '. 17 + 'webserver.'. 18 + "\n\n". 19 + 'You may safely ignore this issue if you do not plan to export '. 20 + 'data in Zip archives or Excel spreadsheets, or intend to install '. 21 + 'the extension later.'); 22 + 23 + $this->newIssue('extension.zip') 24 + ->setName(pht('Missing "zip" Extension')) 25 + ->setMessage($message) 26 + ->addPHPExtension('zip'); 27 + } 28 + } 29 + }
+4
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php
··· 242 242 return new ConduitEpochParameterType(); 243 243 } 244 244 245 + protected function newExportFieldType() { 246 + return new PhabricatorEpochExportField(); 247 + } 248 + 245 249 }
+4
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php
··· 107 107 return new ConduitStringParameterType(); 108 108 } 109 109 110 + protected function newExportFieldType() { 111 + return new PhabricatorStringExportField(); 112 + } 113 + 110 114 }
+12
src/infrastructure/export/field/PhabricatorEpochExportField.php
··· 6 6 private $zone; 7 7 8 8 public function getTextValue($value) { 9 + if ($value === null) { 10 + return ''; 11 + } 12 + 9 13 if (!isset($this->zone)) { 10 14 $this->zone = new DateTimeZone('UTC'); 11 15 } ··· 21 25 } 22 26 23 27 public function getNaturalValue($value) { 28 + if ($value === null) { 29 + return $value; 30 + } 31 + 24 32 return (int)$value; 25 33 } 26 34 27 35 public function getPHPExcelValue($value) { 28 36 $epoch = $this->getNaturalValue($value); 37 + 38 + if ($epoch === null) { 39 + return null; 40 + } 29 41 30 42 $seconds_per_day = phutil_units('1 day in seconds'); 31 43 $offset = ($seconds_per_day * 25569);
+13 -2
src/infrastructure/export/format/PhabricatorExcelExportFormat.php
··· 14 14 } 15 15 16 16 public function isExportFormatEnabled() { 17 - // TODO: PHPExcel has a dependency on the PHP zip extension. We should test 18 - // for that here, since it fatals if we don't have the ZipArchive class. 17 + if (!extension_loaded('zip')) { 18 + return false; 19 + } 20 + 19 21 return @include_once 'PHPExcel.php'; 20 22 } 21 23 22 24 public function getInstallInstructions() { 25 + if (!extension_loaded('zip')) { 26 + return pht(<<<EOHELP 27 + Data can not be exported to Excel because the "zip" PHP extension is not 28 + installed. Consult the setup issue in the Config application for guidance on 29 + installing the extension. 30 + EOHELP 31 + ); 32 + } 33 + 23 34 return pht(<<<EOHELP 24 35 Data can not be exported to Excel because the PHPExcel library is not 25 36 installed. This software component is required for Phabricator to create