-
-
Notifications
You must be signed in to change notification settings - Fork 213
[BC BREAK] File::dirname is relative to TL_ROOT now #8325
Comments
|
The code does not convert the path, therefore I assume that you have passed in a relative path? preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', 'i/am/relative', $matches);
print_r($matches);
/*
Array
(
[0] => i/am/relative
[1] => i/am
[2] => relative
[3] => relative
[4] =>
)
*/preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', '/i/am/absolute', $matches);
dump($matches);
/*
Array
(
[0] => /i/am/absolute
[1] => /i/am
[2] => absolute
[3] => absolute
[4] =>
)
*/ |
|
@leofeyer just test something like var_dump((new \File('files/test.txt'))->dirname);In Contao 3.5.4 for example, the output is In Contao 3.5.12, the output is As backbone87 reported, the Could be that it was only the case under Windows maybe, I didn't test on Linux yet. |
|
This is because previously, the case 'dirname':
if (!isset($this->arrPathinfo[$strKey]))
{
$this->arrPathinfo = pathinfo(TL_ROOT . '/' . $this->strFile);
}
return $this->arrPathinfo['dirname'];
break;which returns the absolute path. Now however, the Thus, since Contao |
|
Fixed in 5062b96. |
|
Now this BREAK my extension!! As a workaroung I insert the same str_replace as in the bugfix a0df959 for 3.5.14. BC-Break or not, the path should stay relative!! If you need an absolute path you can add TL_ROOT. |
|
Your extension wouldn't have worked with previous versions. |
|
Sure, it worked. In my case I create more alternative image sizes inside my template with \picture::create and the path+name. This is not working with absolute paths anymore. Anyway, I don´t see the need for absolute paths. Never ever needed an absolute path inside contao (all file handling methods of contao are handling this for me). |
|
No, I meant your extension wouldn't work in any Contao Version other than Contao 3.5.10 and up. |
|
Yes, that would be the case. I am developing this extension [contentblocks] since half a year and starting with contao version 3.5.6. It was under heavy development (and still not fully feature complete) and I think I used the image-class inside templates after contao 3.5.10 was released. |
|
Then you can surely understand, why it was changed back. Also I don't see why your extension would not work with absolute image paths? |
|
I understand why we try to avoid BC-Breaks. But that was 4 month between switching back. |
|
What exception exactly? |
|
If I try to generate a image with the absolute path the following error is displayed: The image exists at that place. |
|
I would report that as a bug then instead. |
(new File($path))->dirnameis now relative to TL_ROOT, but was an absolute path in contao <= 3.5.9#8295
https://github.com/contao/core/blob/master/system/modules/core/library/Contao/File.php#L918
The text was updated successfully, but these errors were encountered: