User tests: Successful: Unsuccessful:
Reaveal a trimmed path on an error message produced in /libraries/loader.php instead of the actual real path
None
In Protostar's index.php after defined('_JEXEC') or die; add this code (one at a time):
JLoader::registerPrefix('XY', JPATH_PLATFORM . '/notfound');
and
JLoader::registerNamespace('XYZ', JPATH_LIBRARIES . '/notagain');
The error should be:
500 Library path /libraries/notfound cannot be found.
and
500 Library path /libraries/notagain cannot be found.
Labels |
Added:
?
|
Category | ⇒ | Code style Libraries |
Do not know about the practical aspect, but @test is ok.
In Protostar's index.php
after defined('_JEXEC') or die;
I've added this code:
JLoader::registerPrefix('XY', JPATH_PLATFORM . '/notfound');
and
JLoader::registerNamespace('XYZ', JPATH_LIBRARIES . '/notagain');
And the error was as described:
500 Library path /libraries/notfound cannot be found.
and
500 Library path /libraries/notagain cannot be found.
This comment was created with the J!Tracker Application at http://issues.joomla.org/.
One more thing to notice. I would add a blank line before throw
:
// Verify the library path exists.
if (!file_exists($path))
{
$path = str_replace(JPATH_ROOT, '', $path);
throw new RuntimeException('Library path ' . $path . ' cannot be found.', 500);
}
```<br /><br />*This comment was created with the <a href="https://github.com/joomla/jissues">J!Tracker Application</a> at <a href="http://issues.joomla.org/">http://issues.joomla.org/</a>.*
Nice. Agree that adding a blank line before the throw would be better
@b2z @infograf768 Thanks for the tests. Empty line added!
Hmm... But if I am trying to regsiter the library outside JPATH_ROOT
? Then str_replace(JPATH_ROOT, '', $path);
will do nothing. Anyway it is better then nothing ;)
This comment was created with the J!Tracker Application at http://issues.joomla.org/.
@b2z Is that even possible? I mean JPATH_ROOT is the public folder of the site, you mean if you have a library installed in a lower directory? I don’t know if that will work altogether with joomla and certainly is way of the standard procedures of the cms to handle stuff, I think...
This comment was created with the J!Tracker Application at http://issues.joomla.org/.
When you add something to our autoloader, it's done through an absolute path. So yes, it'd be possible to autoload files outside the root install of the CMS.
I like that we show the path to the library folder except the full path of course. How about showing the path from the document root when the library is under the document root and only the last folder when it is above the document root? We get something like this:
$cleanpath = str_replace(JPATH_ROOT, '', $path);
if ($cleanpath == $path)
{
$cleanpath = basename($path);
}
throw new RuntimeException('Library path ' . $cleanpath . ' cannot be found.', 500);
Just a suggestion :)
@dgt41 If you are OK with it, can you make the changes to the PR?
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4317.
@roland-d I just updated the code with your suggestion. Thanks!
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4317.
Could someone please give an example like b2z asked?
I am at Joomladay UK at Bug Squad patch testing session and we are trying to reproduce the error.
E.g. rename some /library/cms/ folders like menu/search, but where not able to reproduce the error
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4317.
@pe7er Try the same procedure as @b2z describes few comments above:
In Protostar's index.php after defined('_JEXEC') or die; I've added this code:
JLoader::registerPrefix('XY', JPATH_PLATFORM . '/notfound’);
and
JLoader::registerNamespace('XYZ', JPATH_LIBRARIES . '/notagain’);
or this #4317 (comment)
PS you have to test one line at the time
@test: Works as expected, the full path is no longer shown.
We need one more test since the PR was changed since the previous tests.
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4317.
@test one more time with the new code! Success. Good job.
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4317.
Two good tests thanks - setting to RTC
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4317.
Status | Pending | ⇒ | Ready to Commit |
Looks like this might be submitted from the wrong branch. There's a ton of other people's commits.
Status | Ready to Commit | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-10-17 11:51:23 |
Ok
Rel_Number | ⇒ | 4770 | |
Relation Type | ⇒ | Related to |
Yeah that looks much better
Can you give an example of library to rename?
This comment was created with the J!Tracker Application at http://issues.joomla.org/.