Feature Language Change PR-5.0-dev Pending

User tests: Successful: Unsuccessful:

avatar dgrammatiko
dgrammatiko
25 Aug 2023

Pull Request for Issue # .

Summary of Changes

  • Added 1 new command on the main joomla.php CLI:
site
  site:create-public-folder       Create a public folder
  • Added one more step on the CLI installation (will do nothing if nothing inserted):
 Please enter the absolute path to the public folder:
  • The code is requiring #41570

3rd Part Devs impact:

  • If you have no direct Entry Point (similar to index.php) you're not affected. But since there might be legitimate cases (backup script, auditing scripts, etc) that boot their own app instead of Joomla there's this idea to make life easier:

Hmm, now that I'm thinking about 3rd PD maybe a simple XML line like the following is all that's needed. We parse all the admin component manifests and symlink the entry points

<exposed-entrypoints>
  <path>administrator/components/com_foo/dangerous-entry.php</path>
  <path>administrator/components/com_foo/another-dangerous-entry.php</path>
</exposed-entrypoints>
  • Another possible conflict might be that most folders in the public folder would get by default an htaccess file with <files>deny from all</files>, meaning NO MORE PHP FILES inside media, images and any other media manager storage folder. If your extension is placing PHP files in these folders you're doing it very wrong, please consider moving them to their appropriate folder.

  • Have some input? Please share it..

Testing Instructions

Testing a NEW installation

  • Apply this PR, ie check out this PR
  • go to the installation folder in your root Joomla installation: cd installation
  • run the command: php joomla.php install
  • insert the FULL path for the public folder, ie
Screenshot 2023-08-25 at 16 35 02
  • Switch your server to the new directory.

Testing an EXISTING installation

  • Download the package for the GitHub or check out this PR

  • go to the cli folder in your root Joomla installation: cd cli

  • run the command: php joomla.php site:create-public-folder

  • insert the FULL path for the public folder, ie Screenshot 2023-08-25 at 16 35 02

  • Switch your server to the new directory.

Actual result BEFORE applying this Pull Request

Expected result AFTER applying this Pull Request

Link to documentations

WIP

@SniperSister @HLeithner @wilsonge thoughts?

@Hackwar I would appreciated some fixes here and some help for the installation CLI

avatar joomla-cms-bot joomla-cms-bot - change - 25 Aug 2023
Category Libraries
avatar dgrammatiko dgrammatiko - open - 25 Aug 2023
avatar dgrammatiko dgrammatiko - change - 25 Aug 2023
Status New Pending
avatar dgrammatiko dgrammatiko - change - 25 Aug 2023
The description was changed
avatar dgrammatiko dgrammatiko - edited - 25 Aug 2023
avatar dgrammatiko dgrammatiko - change - 25 Aug 2023
Labels Added: PR-5.0-dev
avatar joomla-cms-bot joomla-cms-bot - change - 25 Aug 2023
Category Libraries Administration com_admin Libraries
avatar joomla-cms-bot joomla-cms-bot - change - 25 Aug 2023
Category Libraries Administration com_admin Administration com_admin Installation Libraries
avatar dgrammatiko dgrammatiko - change - 25 Aug 2023
The description was changed
avatar dgrammatiko dgrammatiko - edited - 25 Aug 2023
avatar joomla-cms-bot joomla-cms-bot - change - 25 Aug 2023
Category Libraries Administration com_admin Installation Installation Libraries
avatar dgrammatiko dgrammatiko - change - 25 Aug 2023
Title
[5.0] Introduce CLI option to create a public folder
[5.0] Introduce a CLI UI for creating a public folder
avatar dgrammatiko dgrammatiko - edited - 25 Aug 2023
avatar dgrammatiko dgrammatiko - change - 26 Aug 2023
The description was changed
avatar dgrammatiko dgrammatiko - edited - 26 Aug 2023
avatar dgrammatiko dgrammatiko - change - 3 Sep 2023
The description was changed
avatar dgrammatiko dgrammatiko - edited - 3 Sep 2023
e5aafd8 3 Sep 2023 avatar dgrammatiko CS
0a87bf5 3 Sep 2023 avatar dgrammatiko text
bdc29a6 3 Sep 2023 avatar dgrammatiko CS
10f6d6b 3 Sep 2023 avatar dgrammatiko cs
avatar HLeithner
HLeithner - comment - 4 Sep 2023

Here is my reference implementation with the update pr #41570

Root index.php

<?php

/**
 * @package    Joomla.Site
 *
 * @copyright  (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

define('JPATH_ROOT', "/web/joomla.domain.tld");
define('JPATH_BASE', JPATH_ROOT);
define('JPATH_PUBLIC', "/web/joomla.domain.tld/public");

require_once JPATH_BASE . '/index.php';

Administrator and API index.php

<?php

/**
 * @package    Joomla.Site
 *
 * @copyright  (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

define('JPATH_ROOT', "/web/joomla.domain.tld");
define('JPATH_BASE', JPATH_ROOT . "/administrator"); // -->> change this to api for api folder <<--
define('JPATH_PUBLIC', "/web/joomla.domain.tld/public");

require_once JPATH_BASE . '/index.php';

additional to this you only have the symlink to extract.php in admin/com/com_joomlaupdate/extract.php and the the media and image folder in root.

.htaccess, robots.txt of course make sense too.

that's it everything else can be removed.

avatar HLeithner
HLeithner - comment - 4 Sep 2023

btw. it's also possible to do this from web installation and afterwards in the global configuration.

Additionally this could be configure able from .htaccess with a simple rewrite rule, but that's not untested by me.

RewriteEngine On
RewriteRule ^(.*)$ public/$1
avatar dgrammatiko
dgrammatiko - comment - 4 Sep 2023

Here is my reference implementation

Applied. Just as a recap the helper is:

  • symlinking the extract.php

  • symlinking the media folder

  • symlinking all the folders defined in the filesystem-local plugin

  • creating the entry points index.php, administrator/index.php and api/index.php

  • copying .htaccess or htaccess.txt and robots.txt

avatar Fedik
Fedik - comment - 4 Sep 2023

As I commented in adjacent PR, it would be better to do it in separated file, instead of in index.php.

The index.php may be updated at some point, and there no way to run the CLI after update, again (I mean automaticaly from update script).

avatar dgrammatiko
dgrammatiko - comment - 4 Sep 2023

@Fedik the updates are covered as the generated indexes containing only the extra defines and a require to the actual index: https://github.com/joomla/joomla-cms/pull/41446/files#diff-c56b0e04d98c726402852cab3f325feb5e87f42c934256fac6ba2458100365a7R104-R117

avatar HLeithner
HLeithner - comment - 4 Sep 2023

new index.php suggestion:

<?php

/**
 * @package    Joomla.Site
 *
 * @copyright  (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

$applicationPath = '/administrator'; // site application is an empty string and api application is '/api'

require_once dirname(__DIR__) . '/defines.php';

require_once JPATH_BASE . '/index.php';

new defines.php in public root folder suggestion:

<?php

/**
 * @package    Joomla.Site
 *
 * @copyright  (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

define('JPATH_ROOT', "/web/joomla.domain.tld");
define('JPATH_BASE', JPATH_ROOT . $applicationPath);
define('JPATH_PUBLIC', "/web/joomla.domain.tld/public");

unset($applicationPath);

I would like to avoid add more then one place with the pathes, because at the moment if you move a joomla site from one server to another you need exactly zero changes to the config (at least then it runs). Now you should need to touch 3 files and a symlink...

avatar dgrammatiko
dgrammatiko - comment - 4 Sep 2023

@Fedik are you ok with the last comment from Harald?

avatar HLeithner
HLeithner - comment - 4 Sep 2023

maybe unset the variable in the index.php instead of the defines.php.... would be cleaner

avatar Fedik
Fedik - comment - 4 Sep 2023

Ah wait, I misunderstood everything, sorry.

The index is only for publick folder, not core one.
Then can stay as you already made.

avatar Fedik
Fedik - comment - 4 Sep 2023

Sorry for disturbing :)

avatar dgrammatiko
dgrammatiko - comment - 4 Sep 2023

maybe unset the variable in the index.php instead of the defines.php.... would be cleaner

I missed that

0821e04 4 Sep 2023 avatar dgrammatiko oops
6fe810b 4 Sep 2023 avatar dgrammatiko cs
avatar dgrammatiko dgrammatiko - change - 4 Sep 2023
Labels Added: Feature
avatar joomla-cms-bot joomla-cms-bot - change - 4 Sep 2023
Category Libraries Installation Installation Language & Strings Libraries
avatar HLeithner HLeithner - change - 4 Sep 2023
Labels Added: Language Change
avatar HLeithner HLeithner - change - 5 Sep 2023
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2023-09-05 08:07:14
Closed_By HLeithner
avatar HLeithner HLeithner - close - 5 Sep 2023
avatar HLeithner HLeithner - merge - 5 Sep 2023
avatar HLeithner
HLeithner - comment - 5 Sep 2023

Thanks, documentation needed and some improvement, but I would like to have this in beta1 so people could test this feature.

avatar dgrammatiko
dgrammatiko - comment - 5 Sep 2023

@HLeithner should I do the docs on a deployment category or something else (security?)

avatar HLeithner
HLeithner - comment - 5 Sep 2023

migration in the manual, and installation and if we have already something it good to mention it in security

Add a Comment

Login with GitHub to post a comment