?
avatar nextend
nextend
23 Nov 2018

Steps to reproduce the issue

Tested on PHP 7.2.3
You need a unix based server.
Install Joomla in the root path: /
Absolute paths:
/index.php
/administrator/
etc...
Ps.: I know it is strange, but I think there are special context when this can happen.

Expected result

JPATH contants should contain a path without the ending directory separator

Actual result

JPATH constants contains the directory separator

Additional comments

In this environment __DIR__ constant holds / in the root folder. Normally the __DIR__ constant holds the path without the ending directory separator like /public_html

includes/defines.php

// Global definitions
$parts = explode(DIRECTORY_SEPARATOR, JPATH_BASE);

// Defines.
define('JPATH_ROOT',          implode(DIRECTORY_SEPARATOR, $parts));
define('JPATH_SITE',          JPATH_ROOT);
define('JPATH_CONFIGURATION', JPATH_ROOT);

So all of this constants will be / instead of empty string.

Possible solution:

Probably __DIR__ holds the not expected value which should be fixed in index.php

define('JPATH_BASE', __DIR__ === DIRECTORY_SEPARATOR ? '' : __DIR__);

Is it a __DIR__ bug in PHP itself?

I do not think so, PHP describes __DIR__ constant with the following:

The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(FILE). This directory name does not have a trailing slash unless it is the root directory.

http://php.net/manual/en/language.constants.predefined.php

avatar nextend nextend - open - 23 Nov 2018
avatar joomla-cms-bot joomla-cms-bot - change - 23 Nov 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 23 Nov 2018
avatar nextend nextend - change - 23 Nov 2018
The description was changed
avatar nextend nextend - edited - 23 Nov 2018
avatar nextend nextend - change - 23 Nov 2018
The description was changed
avatar nextend nextend - edited - 23 Nov 2018
avatar nextend nextend - change - 23 Nov 2018
The description was changed
avatar nextend nextend - edited - 23 Nov 2018
avatar PhilETaylor
PhilETaylor - comment - 23 Nov 2018

Install Joomla in the root path: /

I would say this is a VERY fringe case right? I cannot think of a situation when someone would ever want to do that ?

avatar nextend
nextend - comment - 23 Nov 2018

I think that server had some kind of special chroot jail environment, where every virtualhost on the shared server has their own simulated empty root folder where the owner can put the PHP files.

This bug report based on a support of my extension and I do not have access to it anymore. Also the user probably just an end user who paid for the shared hosting, so probably he does not have any more info about the technological details. I'm not sure if it helps, but the site was hosted at https://home.pl

avatar Quy Quy - change - 23 Nov 2018
Status New Closed
Closed_Date 0000-00-00 00:00:00 2018-11-23 16:01:10
Closed_By Quy
avatar joomla-cms-bot joomla-cms-bot - change - 23 Nov 2018
Closed_By Quy joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 23 Nov 2018
avatar joomla-cms-bot
joomla-cms-bot - comment - 23 Nov 2018

Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/23148

avatar Quy
Quy - comment - 23 Nov 2018

Closing per PR #23149.

@nextend It is not necessary to open an issue if you have a pull request for the issue. Just create the PR along with the issue information. Thanks.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23148.

Add a Comment

Login with GitHub to post a comment