? Success

User tests: Successful: Unsuccessful:

avatar phproberto
phproberto
15 Aug 2015

Description

Currently the automatic component detection in JLayout is based in the constant JPATH_COMPONENT and in explode the path that it contains with:

$parts = explode('/', JPATH_COMPONENT);

But actually Windows paths can be something like:

C:\Xamp\htdocs\joomla-cms\components\com_content

So the explode will return the full path instead of the expected com_content and then the component won't be found enqueuing a system message with something like:

WARNING: Error component not found: com_content

Instead of applying a patch based in fixing detection based in JPATH_COMPONENT I have opted for using JApplicationHelper which I think is more reliable.

Testing

You need a windows machine for it. I'm not even sure this happens in all the Windows systems (linux user here). Any layout rendered should show the error message.

B/C issues

This is a bug fix that shouldn't cause any B/C issue.

avatar phproberto phproberto - open - 15 Aug 2015
avatar phproberto phproberto - change - 15 Aug 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 15 Aug 2015
Labels Added: ?
avatar zero-24
zero-24 - comment - 15 Aug 2015

I'm unable to replicate any issues on Windows (local with XAMPP) but i can confirm that both ways return the same value so i can count me as successfull test.

A dirty test

Add the following code to the index.php of your template

if (defined('JPATH_COMPONENT'))
{
    $parts = explode('/', JPATH_COMPONENT);
    $component_old = end($parts);
}

$component_new = JApplicationHelper::getComponentName();
echo $component_new;
echo '/'
echo $component_old;
exit;

and confirm that you have a output like com_content/com_content

avatar zero-24 zero-24 - test_item - 15 Aug 2015 - Tested successfully
avatar joomdonation
joomdonation - comment - 16 Aug 2015

JPATH_COMPONENT is defined at https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/component/helper.php#L344. As we can see, the separator between the path and the component name is / character, so the original code is valid and there is no bug like @phproberto said.

However, this change is still OK. +1 for getting it merged.

avatar Fedik
Fedik - comment - 16 Aug 2015

@joomdonation it defined there only if (!defined('JPATH_COMPONENT')) :wink:

avatar zero-24 zero-24 - change - 16 Aug 2015
Category Layout Libraries
avatar phproberto
phproberto - comment - 16 Aug 2015

Yes the issue is when is defined using things like __DIR__ or other settings by third part extensions. Anyway I think is better to relay in one single core method and avoid depending on JPATH_COMPONENT.

avatar Fedik Fedik - test_item - 16 Aug 2015 - Tested successfully
avatar Fedik
Fedik - comment - 16 Aug 2015

I cannot test on Windows,
but after patch it still works as expected, and as fix looks valid I set test ok

avatar zero-24 zero-24 - change - 16 Aug 2015
Status Pending Ready to Commit
avatar zero-24
zero-24 - comment - 16 Aug 2015

RTC. Thanks @phproberto @Fedik and @joomdonation


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

avatar joomla-cms-bot joomla-cms-bot - change - 16 Aug 2015
Labels Added: ?
avatar wilsonge wilsonge - change - 16 Aug 2015
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2015-08-16 15:19:15
Closed_By wilsonge
avatar wilsonge wilsonge - close - 16 Aug 2015
avatar joomla-cms-bot joomla-cms-bot - close - 16 Aug 2015
avatar wilsonge wilsonge - reference | bfc5c95 - 16 Aug 15
avatar wilsonge wilsonge - merge - 16 Aug 2015
avatar wilsonge wilsonge - close - 16 Aug 2015
avatar joomla-cms-bot joomla-cms-bot - change - 16 Aug 2015
Labels Removed: ?
avatar zero-24 zero-24 - change - 17 Aug 2015
Milestone Added:
avatar phproberto phproberto - head_ref_deleted - 3 Nov 2015

Add a Comment

Login with GitHub to post a comment