Various minor improvements (#2132)

- Removed unused twig extension, May a tiny bit of ram and reduce memory usage.
- Switch to the filesystem `touch` function VS PHP's native. Also corrected the time used for touch.
- Wrapped our call to monolog's `write` function in a try-catch. These don't need to be fatal. Instead logs to the PHP error log.
- Ensured the SSL redirect won't be triggered if needed headers weren't provided. Prevents logged errors
- Removed unused composer deps.
- Moved cURL to being a required extension in our composer.json file
- Replaced a a case where the death star version constraint was being used.
This commit is contained in:
Belle Aerni authored and GitHub committed 2024-02-10 21:39:25 -08:00
1 parent 9d066a043a
commit b5a4bd4d9e
6 files changed
+17 -296

No files matched your search

+2 -4
View File
@@ -21,6 +21,7 @@
"ext-mbstring": "*",
"ext-pdo": "*",
"ext-zlib": "*",
"ext-curl": "*",
"antcms/antloader": "^2.0.2",
"dompdf/dompdf": "^2.0.1",
"egulias/email-validator": "^4.0",
@@ -47,10 +48,8 @@
"symfony/http-client": "^6.4",
"symfony/mailer": "^6.4",
"symfony/polyfill-intl-icu": "^1.27",
"symfony/polyfill-intl-idn": "*",
"symfony/polyfill-intl-idn": "^1.29.0",
"symfony/sendgrid-mailer": "^6.4",
"symfony/translation": "^6.4",
"symfony/twig-bridge": "^6.4",
"symfony/webpack-encore-bundle": "^2.1",
"twig/intl-extra": "^3.5",
"twig/twig": "^3.3.9"
@@ -65,7 +64,6 @@
"symfony/phpunit-bridge": "^6.4"
},
"suggest": {
"ext-curl": "*",
"ext-gettext": "*",
"ext-intl": "*"
},
Generated
+3 -284
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "eba77c868e863b5afae4200c9fda0f99",
"content-hash": "efc4c0eb51bee6fcc7ccc61a2b547384",
"packages": [
{
"name": "antcms/antloader",
@@ -5183,288 +5183,6 @@
],
"time": "2023-12-26T14:02:43+00:00"
},
{
"name": "symfony/translation",
"version": "v6.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "637c51191b6b184184bbf98937702bcf554f7d04"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/637c51191b6b184184bbf98937702bcf554f7d04",
"reference": "637c51191b6b184184bbf98937702bcf554f7d04",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-mbstring": "~1.0",
"symfony/translation-contracts": "^2.5|^3.0"
},
"conflict": {
"symfony/config": "<5.4",
"symfony/console": "<5.4",
"symfony/dependency-injection": "<5.4",
"symfony/http-client-contracts": "<2.5",
"symfony/http-kernel": "<5.4",
"symfony/service-contracts": "<2.5",
"symfony/twig-bundle": "<5.4",
"symfony/yaml": "<5.4"
},
"provide": {
"symfony/translation-implementation": "2.3|3.0"
},
"require-dev": {
"nikic/php-parser": "^4.18|^5.0",
"psr/log": "^1|^2|^3",
"symfony/config": "^5.4|^6.0|^7.0",
"symfony/console": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
"symfony/finder": "^5.4|^6.0|^7.0",
"symfony/http-client-contracts": "^2.5|^3.0",
"symfony/http-kernel": "^5.4|^6.0|^7.0",
"symfony/intl": "^5.4|^6.0|^7.0",
"symfony/polyfill-intl-icu": "^1.21",
"symfony/routing": "^5.4|^6.0|^7.0",
"symfony/service-contracts": "^2.5|^3",
"symfony/yaml": "^5.4|^6.0|^7.0"
},
"type": "library",
"autoload": {
"files": [
"Resources/functions.php"
],
"psr-4": {
"Symfony\\Component\\Translation\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides tools to internationalize your application",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/translation/tree/v6.4.3"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-01-29T13:11:52+00:00"
},
{
"name": "symfony/translation-contracts",
"version": "v3.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation-contracts.git",
"reference": "06450585bf65e978026bda220cdebca3f867fde7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation-contracts/zipball/06450585bf65e978026bda220cdebca3f867fde7",
"reference": "06450585bf65e978026bda220cdebca3f867fde7",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.4-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
}
},
"autoload": {
"psr-4": {
"Symfony\\Contracts\\Translation\\": ""
},
"exclude-from-classmap": [
"/Test/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Generic abstractions related to translation",
"homepage": "https://symfony.com",
"keywords": [
"abstractions",
"contracts",
"decoupling",
"interfaces",
"interoperability",
"standards"
],
"support": {
"source": "https://github.com/symfony/translation-contracts/tree/v3.4.1"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2023-12-26T14:02:43+00:00"
},
{
"name": "symfony/twig-bridge",
"version": "v6.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/twig-bridge.git",
"reference": "bf6b411a5d9a0ce6ea43cca0fcf5f05f5196a957"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/twig-bridge/zipball/bf6b411a5d9a0ce6ea43cca0fcf5f05f5196a957",
"reference": "bf6b411a5d9a0ce6ea43cca0fcf5f05f5196a957",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/translation-contracts": "^2.5|^3",
"twig/twig": "^2.13|^3.0.4"
},
"conflict": {
"phpdocumentor/reflection-docblock": "<3.2.2",
"phpdocumentor/type-resolver": "<1.4.0",
"symfony/console": "<5.4",
"symfony/form": "<6.3",
"symfony/http-foundation": "<5.4",
"symfony/http-kernel": "<6.4",
"symfony/mime": "<6.2",
"symfony/serializer": "<6.4",
"symfony/translation": "<5.4",
"symfony/workflow": "<5.4"
},
"require-dev": {
"egulias/email-validator": "^2.1.10|^3|^4",
"league/html-to-markdown": "^5.0",
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
"symfony/asset": "^5.4|^6.0|^7.0",
"symfony/asset-mapper": "^6.3|^7.0",
"symfony/console": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
"symfony/expression-language": "^5.4|^6.0|^7.0",
"symfony/finder": "^5.4|^6.0|^7.0",
"symfony/form": "^6.4|^7.0",
"symfony/html-sanitizer": "^6.1|^7.0",
"symfony/http-foundation": "^5.4|^6.0|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/intl": "^5.4|^6.0|^7.0",
"symfony/mime": "^6.2|^7.0",
"symfony/polyfill-intl-icu": "~1.0",
"symfony/property-info": "^5.4|^6.0|^7.0",
"symfony/routing": "^5.4|^6.0|^7.0",
"symfony/security-acl": "^2.8|^3.0",
"symfony/security-core": "^5.4|^6.0|^7.0",
"symfony/security-csrf": "^5.4|^6.0|^7.0",
"symfony/security-http": "^5.4|^6.0|^7.0",
"symfony/serializer": "^6.4.3|^7.0.3",
"symfony/stopwatch": "^5.4|^6.0|^7.0",
"symfony/translation": "^6.1|^7.0",
"symfony/web-link": "^5.4|^6.0|^7.0",
"symfony/workflow": "^5.4|^6.0|^7.0",
"symfony/yaml": "^5.4|^6.0|^7.0",
"twig/cssinliner-extra": "^2.12|^3",
"twig/inky-extra": "^2.12|^3",
"twig/markdown-extra": "^2.12|^3"
},
"type": "symfony-bridge",
"autoload": {
"psr-4": {
"Symfony\\Bridge\\Twig\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides integration for Twig with various Symfony components",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/twig-bridge/tree/v6.4.3"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-01-30T08:32:12+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v6.4.2",
@@ -8372,7 +8090,8 @@
"php": ">=8.1",
"ext-mbstring": "*",
"ext-pdo": "*",
"ext-zlib": "*"
"ext-zlib": "*",
"ext-curl": "*"
},
"platform-dev": [],
"plugin-api-version": "2.6.0"
-2
View File
@@ -18,7 +18,6 @@ use Lcharette\WebpackEncoreTwig\TagRenderer;
use Lcharette\WebpackEncoreTwig\VersionedAssetsTwigExtension;
use League\CommonMark\Extension\DefaultAttributes\DefaultAttributesExtension;
use RedBeanPHP\Facade;
use Symfony\Bridge\Twig\Extension\TranslationExtension;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookup;
use Twig\Extension\CoreExtension;
@@ -304,7 +303,6 @@ $di['twig'] = $di->factory(function () use ($di) {
// $twig->addExtension(new OptimizerExtension());
$twig->addExtension(new StringLoaderExtension());
$twig->addExtension(new DebugExtension());
$twig->addExtension(new TranslationExtension());
$twig->addExtension($box_extensions);
$twig->getExtension(CoreExtension::class)->setTimezone($timezone);
+2 -1
View File
@@ -97,8 +97,9 @@ class Config
}
if ($clearCache) {
// If opcache is installed and enabled, invalidate the cache for the config file
if (function_exists('opcache_invalidate') && function_exists('opcache_compile_file')) {
@touch(PATH_CACHE, time() - 6400);
@$filesystem->touch(PATH_CACHE);
@opcache_invalidate(PATH_CONFIG, true);
@opcache_compile_file(PATH_CONFIG);
}
+5 -2
View File
@@ -87,7 +87,10 @@ class Monolog
$priority = $this->parsePriority($event['priority']);
$message = $event['message'];
$context = isset($event['info']) && is_array($event['info']) ? $event['info'] : [];
$this->getChannel($channel)->log($priority, $message, $context);
try {
$this->getChannel($channel)->log($priority, $message, $context);
} catch (\Exception $e) {
error_log($e->getMessage());
}
}
}
+5 -3
View File
@@ -118,9 +118,11 @@ function checkSSL()
if (isset($config['security']['force_https']) && $config['security']['force_https'] && !Environment::isCLI()) {
if (!FOSSBilling\Tools::isHTTPS()) {
$hostname = $_SERVER['HTTP_X_FORWARDED_HOST'] ?? $_SERVER['HTTP_HOST'] ?? '';
$url = 'https://' . $hostname . $_SERVER['REQUEST_URI'];
header('Location: ' . $url);
exit;
if (!empty($hostname) && !empty($_SERVER['REQUEST_URI'])) {
$url = 'https://' . $hostname . $_SERVER['REQUEST_URI'];
header('Location: ' . $url);
exit;
}
}
}
}