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 @@ -5399,6 +5399,8 @@ 'PholioTransactionType' => 'applications/pholio/xaction/PholioTransactionType.php', 'PholioTransactionView' => 'applications/pholio/view/PholioTransactionView.php', 'PholioUploadedImageView' => 'applications/pholio/view/PholioUploadedImageView.php', + 'PhorgeCodeWarningSetupCheck' => 'applications/config/check/PhorgeCodeWarningSetupCheck.php', + 'PhorgeSystemDeprecationWarningListener' => 'applications/system/events/PhorgeSystemDeprecationWarningListener.php', 'PhortuneAccount' => 'applications/phortune/storage/PhortuneAccount.php', 'PhortuneAccountAddManagerController' => 'applications/phortune/controller/account/PhortuneAccountAddManagerController.php', 'PhortuneAccountBillingAddressTransaction' => 'applications/phortune/xaction/PhortuneAccountBillingAddressTransaction.php', @@ -12238,6 +12240,8 @@ 'PholioTransactionType' => 'PhabricatorModularTransactionType', 'PholioTransactionView' => 'PhabricatorApplicationTransactionView', 'PholioUploadedImageView' => 'AphrontView', + 'PhorgeCodeWarningSetupCheck' => 'PhabricatorSetupCheck', + 'PhorgeSystemDeprecationWarningListener' => 'PhabricatorEventListener', 'PhortuneAccount' => array( 'PhortuneDAO', 'PhabricatorApplicationTransactionInterface', diff --git a/src/applications/config/check/PhorgeCodeWarningSetupCheck.php b/src/applications/config/check/PhorgeCodeWarningSetupCheck.php new file mode 100644 --- /dev/null +++ b/src/applications/config/check/PhorgeCodeWarningSetupCheck.php @@ -0,0 +1,79 @@ +getWarnings(); + if (!$warnings) { + return; + } + + $link = phutil_tag( + 'a', + array('href' => 'https://we.phorge.it/w/docs/report-warnings/'), + pht('%s\'s home page', PlatformSymbols::getPlatformServerName())); + + $message = pht( + 'There is some deprecated code found in the %s code-base.'. + "\n\n". + "This isn't a problem yet, but it means that %s might stop working if ". + 'you upgrade PHP version.'. + "\n\n". + 'This page records a sample of the cases since last server restart. '. + "\n\n". + 'To solve this issue, either:'. + "\n\n". + '- Visit %s, file bug report with the information below, or'. + "\n". + '- Ignore this issue using the `Ignore` button below.'. + "\n\n" + , + PlatformSymbols::getPlatformServerName(), + PlatformSymbols::getPlatformServerName(), + $link); + $message = array($message); + + $message[] = pht('Recorded items (sample):'); + $list = array(); + $warnings = array_reverse(isort($warnings, 'counter')); + foreach ($warnings as $key => $data) { + $summary = pht( + '%s, occurrences: %s', + $key, + $data['counter']); + + $trace = phutil_tag('tt', array(), + array($data['message'] , "\n", $data['trace'])); + + $list[] = phutil_tag( + 'li', + array(), + phutil_tag( + 'details', + array(), + array( + phutil_tag('summary', array(), $summary), + $trace, + ))); + } + $message[] = phutil_tag('ul', array(), $list); + + + $this->newIssue('deprecations') + ->setName(pht('Deprecated Code')) + ->setMessage($message) + ->setSummary(pht('There is some deprecated code found in the code-base.')) + ->addLink( + 'https://we.phorge.it/w/docs/report-warnings/', + 'More Details on the website'); + } + +} diff --git a/src/applications/system/application/PhabricatorSystemApplication.php b/src/applications/system/application/PhabricatorSystemApplication.php --- a/src/applications/system/application/PhabricatorSystemApplication.php +++ b/src/applications/system/application/PhabricatorSystemApplication.php @@ -17,6 +17,7 @@ public function getEventListeners() { return array( new PhabricatorSystemDebugUIEventListener(), + new PhorgeSystemDeprecationWarningListener(), ); } diff --git a/src/applications/system/events/PhorgeSystemDeprecationWarningListener.php b/src/applications/system/events/PhorgeSystemDeprecationWarningListener.php new file mode 100644 --- /dev/null +++ b/src/applications/system/events/PhorgeSystemDeprecationWarningListener.php @@ -0,0 +1,58 @@ +getKey(self::CACHE_KEY); + + if (!$cache_entry) { + $cache_entry = array(); + } + + $trace_entry = idx($cache_entry, $trace_key); + + if ($trace_entry) { + $trace_entry['counter']++; + } else { + $trace_entry = array( + 'counter' => 1, + 'message' => $value, + 'trace' => PhutilErrorHandler::formatStacktrace($metadata['trace']), + ); + } + $cache_entry[$trace_key] = $trace_entry; + + $cache->setKey(self::CACHE_KEY , $cache_entry); + } + + public function getWarnings() { + $cache = PhabricatorCaches::getRuntimeCache(); + return $cache->getKey(self::CACHE_KEY); + } + +}