Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] wrong component detection in some Windows servers #7693

Merged
merged 1 commit into from
Aug 16, 2015

Conversation

phproberto
Copy link
Contributor

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.

@zero-24
Copy link
Contributor

zero-24 commented Aug 15, 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

@joomdonation
Copy link
Contributor

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.

@Fedik
Copy link
Member

Fedik commented Aug 16, 2015

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

@phproberto
Copy link
Contributor Author

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.

@Fedik
Copy link
Member

Fedik commented Aug 16, 2015

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

@zero-24
Copy link
Contributor

zero-24 commented Aug 16, 2015

RTC. Thanks @phproberto @Fedik and @joomdonation


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Aug 16, 2015
wilsonge added a commit that referenced this pull request Aug 16, 2015
[fix] wrong component detection in some Windows servers
@wilsonge wilsonge merged commit bfc5c95 into joomla:staging Aug 16, 2015
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Aug 16, 2015
@zero-24 zero-24 added this to the Joomla! 3.4.4 milestone Aug 17, 2015
@phproberto phproberto deleted the jlayout-component-windows branch November 3, 2015 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants