PR-5.0-dev Pending

User tests: Successful: Unsuccessful:

avatar HLeithner
HLeithner
3 Sep 2023

Useful for public folder for example or only partial overrides.

Followup Pull Request for #40509 and prepare Pull Request for #41446.

Summary of Changes

Allow each JPATH constant to be overridden individually which allow us to only define 3 constants in the public folder index.php or any other bootstrap file.

Remove the need of _JDEFINED if custom constants have been defined.

SiteRouter uses now the JPATH_PUBLIC constant instead of the JPATH_SITE constant to find the index.php in the path to removes it from the request uri object.

@dgrammatiko @wilsonge

Testing Instructions

joomla frontend, backend and api should work normally, with and without public folder

Actual result BEFORE applying this Pull Request

Works
More files in public folder

Expected result AFTER applying this Pull Request

Works
Only index.php and extract.php in public folder.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar joomla-cms-bot joomla-cms-bot - change - 3 Sep 2023
Category Administration Libraries
avatar HLeithner HLeithner - open - 3 Sep 2023
avatar HLeithner HLeithner - change - 3 Sep 2023
Status New Pending
avatar HLeithner HLeithner - change - 3 Sep 2023
Labels Added: PR-5.0-dev
avatar Fedik
Fedik - comment - 4 Sep 2023

TBH, looks dirty to me.

For #41446 we can do similar to if (file_exists(dirname(__DIR__) . '/defines.php')):

if (file_exists(__DIR__ . '/defines-public-folder.php')) {
    include_once __DIR__ . '/defines-public-folder.php';
}

And you only check for

defined('JPATH_ROOT') || define('JPATH_ROOT', implode(DIRECTORY_SEPARATOR, $parts));
defined('JPATH_SITE') || define('JPATH_SITE', JPATH_ROOT);
defined('JPATH_PUBLIC') || define('JPATH_PUBLIC', JPATH_ROOT);

Then CLI script should generate only defines-public-folder.php not index.php

app.php then will be like:

...
if (file_exists(dirname(__DIR__) . '/defines.php')) {
    include_once dirname(__DIR__) . '/defines.php';
}
if (file_exists(__DIR__ . '/defines-public-folder.php')) {
    include_once __DIR__ . '/defines-public-folder.php';
}

if (!defined('_JDEFINES')) {
    define('JPATH_BASE', dirname(__DIR__));
    require_once JPATH_BASE . '/includes/defines.php';
}
...

Or we better call it defines-generated.php or defines-custom.php

avatar HLeithner
HLeithner - comment - 4 Sep 2023

I never understood way I only can override one variable or all in defines...
Because this means we broke all sites that uses it own defines file when we added the JPATH_API constant.

That's the reason I simple allow to override any constant for simplicity.

avatar dgrammatiko
dgrammatiko - comment - 4 Sep 2023

Then CLI script should generate only defines-public-folder.php not index.php

That was my initial approach to have only a custom defines (well I actually did a bit more) but I also like this take. It's simpler IMHO

avatar Fedik
Fedik - comment - 4 Sep 2023

Well, I wrote what I not like ?

At least please avoid hacking of index.php. create a separated file for generated defines.

avatar dgrammatiko
dgrammatiko - comment - 4 Sep 2023

I'm ok with either approaches, just make up your mind and let me know what will it be ?

avatar HLeithner HLeithner - change - 4 Sep 2023
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2023-09-04 09:35:54
Closed_By HLeithner
avatar HLeithner HLeithner - close - 4 Sep 2023
avatar HLeithner HLeithner - merge - 4 Sep 2023
avatar HLeithner
HLeithner - comment - 4 Sep 2023

I'm merging this for beta1 so we see any site effects and as it is needed as preparation for #41446

Add a Comment

Login with GitHub to post a comment