?
avatar bertmert
bertmert
25 Apr 2017

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

26-04-_2017_01-33-33

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

avatar bertmert bertmert - open - 25 Apr 2017
avatar joomla-cms-bot joomla-cms-bot - change - 25 Apr 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 25 Apr 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 26 Apr 2017
Category com_cache
avatar zero-24
zero-24 - comment - 26 Apr 2017

@bertmert what kind of error reporting you have enabled?

avatar franz-wohlkoenig franz-wohlkoenig - change - 26 Apr 2017
Status New Information Required
avatar PhilETaylor
PhilETaylor - comment - 26 Apr 2017

This is because the code is assuming that a file size can be discovered

https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_cache/views/cache/tmpl/default.php#L70

This needs improving to only run math if a valid $item->size is passed

avatar zero-24
zero-24 - comment - 26 Apr 2017

So just a

if (is_int($item->size))
{
echo JHtml::_('number.bytes', $item->size*1024);
}
else
{
echo 'error'
}

does the trick? can you confirm @bertmert ?

avatar bertmert
bertmert - comment - 26 Apr 2017

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:

  1. step: PHP function filesize(...)
    https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/cache/storage/file.php#L137-L140

  2. 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.

  1. step with Notice
    https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_cache/views/cache/tmpl/default.php#L70
avatar bertmert
bertmert - comment - 26 Apr 2017

Maybe the number_format() part should happen later ?

avatar franz-wohlkoenig franz-wohlkoenig - change - 9 May 2017
Status Information Required Discussion
avatar oe1tkt
oe1tkt - comment - 11 May 2017

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.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15554.
avatar bertmert
bertmert - comment - 11 May 2017

@izharaazmi

I'm not sure! Isn't this code that you created?

avatar oe1tkt
oe1tkt - comment - 11 May 2017

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));
avatar izharaazmi
izharaazmi - comment - 11 May 2017

@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?

avatar oe1tkt
oe1tkt - comment - 11 May 2017

@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.

avatar bertmert
bertmert - comment - 11 May 2017

@izharaazmi Thank you for clarification.

avatar bertmert
bertmert - comment - 11 May 2017

Closing here because we have a pr.

avatar bertmert bertmert - change - 11 May 2017
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2017-05-11 21:45:45
Closed_By bertmert
avatar bertmert bertmert - close - 11 May 2017

Add a Comment

Login with GitHub to post a comment