From 8c5087dbba59276eb63c6b85237cf5301034c898 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Wed, 14 Dec 2022 15:04:49 +1300 Subject: [PATCH] API Make the public directory mandatory --- src/Control/Director.php | 18 +----------------- src/View/PublicThemes.php | 2 +- src/includes/constants.php | 8 ++++---- .../TinyMCECombinedGeneratorTest.php | 2 +- 4 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/Control/Director.php b/src/Control/Director.php index 8c749d1f1b8..630a60b5b1c 100644 --- a/src/Control/Director.php +++ b/src/Control/Director.php @@ -75,15 +75,6 @@ class Director implements TemplateGlobalProvider */ private static $alternate_base_folder; - /** - * Override PUBLIC_DIR. Set to a non-null value to override. - * Setting to an empty string will disable public dir. - * - * @config - * @var bool|null - */ - private static $alternate_public_dir = null; - /** * Base url to populate if cannot be determined otherwise. * Supports back-ticked vars; E.g. '`SS_BASE_URL`' @@ -654,19 +645,12 @@ public static function baseFolder() } /** - * Check if using a separate public dir, and if so return this directory - * name. - * - * This will be removed in 5.0 and fixed to 'public' + * The name of the public directory * * @return string */ public static function publicDir() { - $alternate = self::config()->uninherited('alternate_public_dir'); - if (isset($alternate)) { - return $alternate; - } return PUBLIC_DIR; } diff --git a/src/View/PublicThemes.php b/src/View/PublicThemes.php index 2305e11453b..ce493b77207 100644 --- a/src/View/PublicThemes.php +++ b/src/View/PublicThemes.php @@ -6,6 +6,6 @@ class PublicThemes implements ThemeList { public function getThemes() { - return PUBLIC_DIR ? ['/' . PUBLIC_DIR] : []; + return ['/' . PUBLIC_DIR]; } } diff --git a/src/includes/constants.php b/src/includes/constants.php index e0e720fe463..ca44b0ed8c5 100644 --- a/src/includes/constants.php +++ b/src/includes/constants.php @@ -24,7 +24,7 @@ * - THEMES_PATH: Absolute filepath, e.g. "/var/www/my-webroot/themes" * - FRAMEWORK_DIR: Path relative to webroot, e.g. "framework" * - FRAMEWORK_PATH:Absolute filepath, e.g. "/var/www/my-webroot/framework" - * - PUBLIC_DIR: Webroot path relative to project root, e.g. "public" or "" + * - PUBLIC_DIR: Webroot path relative to project root - always evaluates to "public" * - PUBLIC_PATH: Absolute path to webroot, e.g. "/var/www/project/public" * - THIRDPARTY_DIR: Path relative to webroot, e.g. "framework/thirdparty" * - THIRDPARTY_PATH: Absolute filepath, e.g. "/var/www/my-webroot/framework/thirdparty" @@ -70,10 +70,10 @@ // Set public webroot dir / path if (!defined('PUBLIC_DIR')) { - define('PUBLIC_DIR', is_dir(BASE_PATH . DIRECTORY_SEPARATOR . 'public') ? 'public' : ''); + define('PUBLIC_DIR', 'public'); } if (!defined('PUBLIC_PATH')) { - define('PUBLIC_PATH', PUBLIC_DIR ? BASE_PATH . DIRECTORY_SEPARATOR . PUBLIC_DIR : BASE_PATH); + define('PUBLIC_PATH', BASE_PATH . DIRECTORY_SEPARATOR . PUBLIC_DIR); } // Allow a first class env var to be set that disables .env file loading @@ -183,7 +183,7 @@ call_user_func(function () { $paths = [ BASE_PATH, - (PUBLIC_DIR ? PUBLIC_DIR : null), + PUBLIC_DIR, ASSETS_DIR ]; define('ASSETS_PATH', implode(DIRECTORY_SEPARATOR, array_filter($paths ?? []))); diff --git a/tests/php/Forms/HTMLEditor/TinyMCECombinedGeneratorTest.php b/tests/php/Forms/HTMLEditor/TinyMCECombinedGeneratorTest.php index cbfa369f958..229b31f28e3 100644 --- a/tests/php/Forms/HTMLEditor/TinyMCECombinedGeneratorTest.php +++ b/tests/php/Forms/HTMLEditor/TinyMCECombinedGeneratorTest.php @@ -90,7 +90,7 @@ public function testConfig() // Check plugin links included $this->assertStringContainsString( <<