Skip to content

Commit 12a1274

Browse files
[5.0] Allow Joomla be served from a public* folder (#40509)
--------- Signed-off-by: Dimitris Grammatikogiannis <[email protected]> Co-authored-by: Harald Leithner <[email protected]>
1 parent aa5b197 commit 12a1274

File tree

17 files changed

+96
-28
lines changed

17 files changed

+96
-28
lines changed

administrator/includes/app.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@
2222
require_once JPATH_BASE . '/includes/defines.php';
2323
}
2424

25+
if (!defined('JPATH_PUBLIC')) {
26+
define('JPATH_PUBLIC', JPATH_ROOT);
27+
}
28+
2529
// Check for presence of vendor dependencies not included in the git repository
26-
if (!file_exists(JPATH_LIBRARIES . '/vendor/autoload.php') || !is_dir(JPATH_ROOT . '/media/vendor')) {
27-
echo file_get_contents(JPATH_ROOT . '/templates/system/build_incomplete.html');
30+
if (!file_exists(JPATH_LIBRARIES . '/vendor/autoload.php') || !is_dir(JPATH_PUBLIC . '/media/vendor')) {
31+
echo file_get_contents(JPATH_BASE . '/templates/system/build_incomplete.html');
2832

2933
exit;
3034
}

administrator/includes/defines.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// Defines
1717
define('JPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
1818
define('JPATH_SITE', JPATH_ROOT);
19+
define('JPATH_PUBLIC', JPATH_ROOT);
1920
define('JPATH_CONFIGURATION', JPATH_ROOT);
2021
define('JPATH_ADMINISTRATOR', JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');
2122
define('JPATH_LIBRARIES', JPATH_ROOT . DIRECTORY_SEPARATOR . 'libraries');

administrator/includes/framework.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
|| (file_exists(JPATH_INSTALLATION . '/index.php') && (false === (new Version())->isInDevelopmentState()))
2323
) {
2424
if (file_exists(JPATH_INSTALLATION . '/index.php')) {
25-
header('Location: ../installation/index.php');
25+
if (JPATH_ROOT === JPATH_PUBLIC) {
26+
header('Location: ../installation/index.php');
27+
} else {
28+
echo 'Installation from a public folder is not supported, revert your Server configuration to point at the Joomla\'s root folder to continue.';
29+
}
2630

2731
exit();
2832
} else {

administrator/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
str_replace(
1818
'{{phpversion}}',
1919
JOOMLA_MINIMUM_PHP,
20-
file_get_contents(dirname(__FILE__) . '/../templates/system/incompatible.html')
20+
file_get_contents(dirname(dirname(__FILE__)) . '/includes/incompatible.html')
2121
)
2222
);
2323
}

api/includes/app.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
require_once JPATH_BASE . '/includes/defines.php';
2323
}
2424

25+
if (!defined('JPATH_PUBLIC')) {
26+
define('JPATH_PUBLIC', JPATH_ROOT);
27+
}
28+
2529
require_once JPATH_BASE . '/includes/framework.php';
2630

2731
// Set profiler start time and memory usage and mark afterLoad in the profiler.

api/includes/defines.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// Defines.
1717
define('JPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
1818
define('JPATH_SITE', JPATH_ROOT);
19+
define('JPATH_PUBLIC', JPATH_ROOT);
1920
define('JPATH_CONFIGURATION', JPATH_ROOT);
2021
define('JPATH_ADMINISTRATOR', JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');
2122
define('JPATH_LIBRARIES', JPATH_ROOT . DIRECTORY_SEPARATOR . 'libraries');

build/build-modules-js/error-pages.es6.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,12 @@ module.exports.createErrorPages = async (options) => {
147147
await mkdir(dirname(`${RootPath}${options.settings.errorPages[name].destFile}`), { recursive: true, mode: 0o755 });
148148
}
149149

150-
await writeFile(
151-
`${RootPath}${options.settings.errorPages[name].destFile}`,
152-
template,
153-
{ encoding: 'utf8', mode: 0o644 },
154-
);
150+
options.settings.errorPages[name].destFile.forEach(async (folder) => {
151+
await writeFile(`${RootPath}${folder}`, template, { encoding: 'utf8', mode: 0o644 });
155152

156-
// eslint-disable-next-line no-console
157-
console.error(`✅ Created the file: ${options.settings.errorPages[name].destFile}`);
153+
// eslint-disable-next-line no-console
154+
console.error(`✅ Created the file: ${folder}`);
155+
});
158156
};
159157

160158
Object.keys(options.settings.errorPages).forEach((name) => processPages.push(processPage(name)));

build/build-modules-js/settings.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,31 +798,31 @@
798798
"text": "It looks like you are trying to run Joomla! from our git repository. To do so requires you complete a couple of extra steps first.",
799799
"link": "J4.x:Setting_Up_Your_Local_Environment",
800800
"linkText": "More Details",
801-
"destFile": "/templates/system/build_incomplete.html"
801+
"destFile": ["/templates/system/build_incomplete.html"]
802802
},
803803
"unsupported": {
804804
"title": "Joomla: unsupported PHP version",
805805
"header": "Sorry, your PHP version is not supported",
806806
"text": "Your host needs to use PHP version {{phpversion}} or newer to run this version of Joomla!",
807807
"link": "J4.x:Unsupported_PHP_Version",
808808
"linkText": "Help me resolve this",
809-
"destFile": "/templates/system/incompatible.html"
809+
"destFile": ["/templates/system/incompatible.html", "/includes/incompatible.html"]
810810
},
811811
"noxml": {
812812
"title": "Joomla: Missing PHP-XML library",
813813
"header": "Sorry, your PHP is missing a vital library",
814814
"text": "Your host needs to use PHP with support for the XML library to run this version of Joomla!",
815815
"link": "J4.x:Missing_XML_Library",
816816
"linkText": "Help me resolve this",
817-
"destFile": "/media/system/html/noxml.html"
817+
"destFile": ["/media/system/html/noxml.html"]
818818
},
819819
"fatal": {
820820
"title": "An Error Occurred: {{statusText}}",
821821
"header": "Sorry, there was a problem we could not recover from.",
822822
"text": "The server returned a \"{{statusCode_statusText}}\"",
823823
"link": "J4.x:FatalError",
824824
"linkText": "Help me resolve this",
825-
"destFile": "/templates/system/fatal-error.html"
825+
"destFile": ["/templates/system/fatal-error.html"]
826826
}
827827
}
828828
}

cli/joomla.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
exit;
4444
}
4545

46+
if (!defined('JPATH_PUBLIC')) {
47+
define('JPATH_PUBLIC', JPATH_ROOT);
48+
}
49+
4650
// Check if installed
4751
if (
4852
!file_exists(JPATH_CONFIGURATION . '/configuration.php')

includes/app.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@
2222
require_once JPATH_BASE . '/includes/defines.php';
2323
}
2424

25+
if (!defined('JPATH_PUBLIC')) {
26+
define('JPATH_PUBLIC', JPATH_ROOT);
27+
}
28+
2529
// Check for presence of vendor dependencies not included in the git repository
26-
if (!file_exists(JPATH_LIBRARIES . '/vendor/autoload.php') || !is_dir(JPATH_ROOT . '/media/vendor')) {
27-
echo file_get_contents(JPATH_ROOT . '/templates/system/build_incomplete.html');
30+
if (!file_exists(JPATH_LIBRARIES . '/vendor/autoload.php') || !is_dir(JPATH_PUBLIC . '/media/vendor')) {
31+
echo file_get_contents(JPATH_BASE . '/templates/system/build_incomplete.html');
2832

2933
exit;
3034
}

0 commit comments

Comments
 (0)