From b14de847a55f8f82779bd878b8c623a87e8f7eda Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Wed, 14 Dec 2022 16:08:47 +1300 Subject: [PATCH] API Make the public directory mandatory (#10617) --- 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 32e6fdf4e..cd63dc5e3 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 @@ class Director implements TemplateGlobalProvider } /** - * 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 2305e1145..ce493b772 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 e0e720fe4..ca44b0ed8 100644 --- a/src/includes/constants.php +++ b/src/includes/constants.php @@ -24,7 +24,7 @@ use SilverStripe\Core\TempFolder; * - 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 @@ if (!defined('BASE_PATH')) { // 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 @@ if (!defined('ASSETS_PATH')) { 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 cbfa369f9..229b31f28 100644 --- a/tests/php/Forms/HTMLEditor/TinyMCECombinedGeneratorTest.php +++ b/tests/php/Forms/HTMLEditor/TinyMCECombinedGeneratorTest.php @@ -90,7 +90,7 @@ class TinyMCECombinedGeneratorTest extends SapphireTest // Check plugin links included $this->assertStringContainsString( <<