After update from 3.6.5 to 3.7.0 I have several warnings in
administrator/index.php?option=com_cache (clear cache).
Notice: A non well formed numeric value encountered in /administrator/components/com_cache/views/cache/tmpl/default.php on line 70
759,00 kB
Notice: A non well formed numeric value encountered in /www/htdocs/w00f7959/relaunch-bs3.ghsvs.de/administrator/components/com_cache/views/cache/tmpl/default.php on line 70
24,00 kB
PHP 7.1
Linux dd1620 3.13.0-116-generic #163-Ubuntu SMP Fri Mar 31 14:13:22 UTC 2017 x86_64
MySQL 5.5.52-nmm1-log
Labels |
Added:
?
|
Category | ⇒ | com_cache |
Status | New | ⇒ | Information Required |
This is because the code is assuming that a file size can be discovered
This needs improving to only run math if a valid $item->size is passed
what kind of error reporting you have enabled?
Maximum. Nothing changed here. It was always Maximum.
can you confirm
Not really. It's clear that it would work without Notice then. But as you can see in my first post: After the notice there are sizes (759,00kB, 24,00kB). They are correct, maybe just nearly correct.
The invalid sizes come somewhere from Joomla. When I add line
<?php echo $item->size; ?>
I get these values
759,32
24,86
This is the way how the sizes are calculated:
step: PHP function filesize(...)
https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/cache/storage/file.php#L137-L140
step: PHP function number_format(...)
https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/cache/storage/helper.php#L66
===> I think the result is never an INT but a STRING (?). This HP is a German one. So, commas instead of dots.
Maybe the number_format() part should happen later ?
Status | Information Required | ⇒ | Discussion |
I came across with the same failure.
Yes, the number formatting should be done exclusively at the point of displaying the data only!
The line in
https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/cache/storage/helper.php#L66
This line should be only:
$this->size += $size;
And in the other files, within libraries/joomla/cache/storage/ I removed the division through 1024. That makes no sense to calculate with floating point and kilobytes.
Within the view (administrator/components/com_cache/views/cache/tmpl/default.php) the line is now:
<?php echo JHtml::_('number.bytes', $item->size); ?>
I will send a pull-request till tomorrow. On my test server it's working.
I'm not sure! Isn't this code that you created?
I've created a pull request #15964
In addition, if you use virtuemart or other 3rd party extension using cache JCacheStorage class extensions. The size can be adjusted in the file, eg. Virtuemart:
libraries/joomla/cache/storage/vmfile.php: line 107
//$item->updateSize(filesize($path . '/' . $folder . '/' . $file) / 1024);
$item->updateSize(filesize($path . '/' . $folder . '/' . $file));
@bertmert, I did work on the number.bytes
method. However that method expects an integer input which is not the case where this is failing. The warning is yet before the method is called. Reading the previous comments I see you guys are already at the right point.
PS: I don't get the * 1024
part. Why the multiplication?
@izharaazmi, @bertmert
The warning is created because of the multiplication e.g. "2,345.67" * 1024 (this is a string which was generated from that strange $item->updateSize() ) - The updating handled with kilobytes (float) instead of bytes (integer), so why the * 1024 part comes from. Please have a look into pull request #15964, test and vote for it.
@izharaazmi Thank you for clarification.
Closing here because we have a pr.
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-05-11 21:45:45 |
Closed_By | ⇒ | bertmert |
@bertmert what kind of error reporting you have enabled?