Page MenuHomePhabricator

D20658.id49282.diff
No OneTemporary

D20658.id49282.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -5023,6 +5023,7 @@
'PhabricatorXHProfSampleQuery' => 'applications/xhprof/query/PhabricatorXHProfSampleQuery.php',
'PhabricatorXHProfSampleSearchEngine' => 'applications/xhprof/query/PhabricatorXHProfSampleSearchEngine.php',
'PhabricatorYoutubeRemarkupRule' => 'infrastructure/markup/rule/PhabricatorYoutubeRemarkupRule.php',
+ 'PhabricatorZipSetupCheck' => 'applications/config/check/PhabricatorZipSetupCheck.php',
'Phame404Response' => 'applications/phame/site/Phame404Response.php',
'PhameBlog' => 'applications/phame/storage/PhameBlog.php',
'PhameBlog404Controller' => 'applications/phame/controller/blog/PhameBlog404Controller.php',
@@ -11449,6 +11450,7 @@
'PhabricatorXHProfSampleQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorXHProfSampleSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorYoutubeRemarkupRule' => 'PhutilRemarkupRule',
+ 'PhabricatorZipSetupCheck' => 'PhabricatorSetupCheck',
'Phame404Response' => 'AphrontHTMLResponse',
'PhameBlog' => array(
'PhameDAO',
diff --git a/src/applications/config/check/PhabricatorZipSetupCheck.php b/src/applications/config/check/PhabricatorZipSetupCheck.php
new file mode 100644
--- /dev/null
+++ b/src/applications/config/check/PhabricatorZipSetupCheck.php
@@ -0,0 +1,29 @@
+<?php
+
+final class PhabricatorZipSetupCheck extends PhabricatorSetupCheck {
+
+ public function getDefaultGroup() {
+ return self::GROUP_OTHER;
+ }
+
+ protected function executeChecks() {
+ if (!extension_loaded('zip')) {
+ $message = pht(
+ 'The PHP "zip" extension is not installed. This extension is '.
+ 'required by certain data export operations, including exporting '.
+ 'data to Excel.'.
+ "\n\n".
+ 'To clear this setup issue, install the extension and restart your '.
+ 'webserver.'.
+ "\n\n".
+ 'You may safely ignore this issue if you do not plan to export '.
+ 'data in Zip archives or Excel spreadsheets, or intend to install '.
+ 'the extension later.');
+
+ $this->newIssue('extension.zip')
+ ->setName(pht('Missing "zip" Extension'))
+ ->setMessage($message)
+ ->addPHPExtension('zip');
+ }
+ }
+}
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php
@@ -242,4 +242,8 @@
return new ConduitEpochParameterType();
}
+ protected function newExportFieldType() {
+ return new PhabricatorEpochExportField();
+ }
+
}
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php
@@ -107,4 +107,8 @@
return new ConduitStringParameterType();
}
+ protected function newExportFieldType() {
+ return new PhabricatorStringExportField();
+ }
+
}
diff --git a/src/infrastructure/export/field/PhabricatorEpochExportField.php b/src/infrastructure/export/field/PhabricatorEpochExportField.php
--- a/src/infrastructure/export/field/PhabricatorEpochExportField.php
+++ b/src/infrastructure/export/field/PhabricatorEpochExportField.php
@@ -6,6 +6,10 @@
private $zone;
public function getTextValue($value) {
+ if ($value === null) {
+ return '';
+ }
+
if (!isset($this->zone)) {
$this->zone = new DateTimeZone('UTC');
}
@@ -21,12 +25,20 @@
}
public function getNaturalValue($value) {
+ if ($value === null) {
+ return $value;
+ }
+
return (int)$value;
}
public function getPHPExcelValue($value) {
$epoch = $this->getNaturalValue($value);
+ if ($epoch === null) {
+ return null;
+ }
+
$seconds_per_day = phutil_units('1 day in seconds');
$offset = ($seconds_per_day * 25569);
diff --git a/src/infrastructure/export/format/PhabricatorExcelExportFormat.php b/src/infrastructure/export/format/PhabricatorExcelExportFormat.php
--- a/src/infrastructure/export/format/PhabricatorExcelExportFormat.php
+++ b/src/infrastructure/export/format/PhabricatorExcelExportFormat.php
@@ -14,12 +14,23 @@
}
public function isExportFormatEnabled() {
- // TODO: PHPExcel has a dependency on the PHP zip extension. We should test
- // for that here, since it fatals if we don't have the ZipArchive class.
+ if (!extension_loaded('zip')) {
+ return false;
+ }
+
return @include_once 'PHPExcel.php';
}
public function getInstallInstructions() {
+ if (!extension_loaded('zip')) {
+ return pht(<<<EOHELP
+Data can not be exported to Excel because the "zip" PHP extension is not
+installed. Consult the setup issue in the Config application for guidance on
+installing the extension.
+EOHELP
+ );
+ }
+
return pht(<<<EOHELP
Data can not be exported to Excel because the PHPExcel library is not
installed. This software component is required for Phabricator to create

File Metadata

Mime Type
text/plain
Expires
Sun, Jan 19, 11:25 AM (14 h, 49 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7001792
Default Alt Text
D20658.id49282.diff (5 KB)

Event Timeline