?
avatar drewgg
drewgg
10 Feb 2017

Steps to reproduce the issue

  • Turn caching on
  • Visit a few pages until any cache group has more than 1Mb of files cached
  • Check the Size column in System > Clear Cache

Expected result

  • The size should grow fairly large (10's or 100's of megs) for some cache groups as more and more files are cached.

Actual result

  • The size values never go above 999Kb.

System information (as much as possible)

Joomla 3.6.5
PHP 5.6
Apache/Lightspeed

Additional comments

This bug was fixed in #1872 but reintroduced in #3202 .

/libraries/joomla/cache/storage/helper.php

The working code was:

$this->size = number_format((float) $this->size + (float) $size, 2, '.', '');

This was changed to the current code:

$this->size = number_format((float) $this->size + (float) $size, 2, JText::_('DECIMALS_SEPARATOR'), JText::_('THOUSANDS_SEPARATOR'));

This change was done for numeric localization reasons, however, the number at this point is not an end-user facing number. It's just a numeric value being stored/modified. Because of the casting from(float) $this->size there will be issues...

This is the issue with using the thousands separator, the number will get cut off at the first comma found:

$this->size = "1,234.56"; // number with a thousands separator
$this->size = (float)$this->size;
echo $this->size; // outputs: 1

This is the issue for the decimal separator:

$this->size = "1.234,56"; // localized number format
$this->size = (float)$this->size;
echo $this->size; // outputs: 1.234

For the second issue, I believe this is the case because the (float) casting does not take the localization into account (ie, I believe it always assumes the decimal separator is a period). See http://php.net/manual/en/language.types.float.php (particularly the "formal" definition near the top that has the algorithm). That could just be a simplified definition though and there is in fact localization support in the underlying code, I don't know.

For those reasons I believe the code should go back to:

$this->size = number_format((float) $this->size + (float) $size, 2, '.', '');

I'm not really sure why number_format() is even being used here. It might actually be better to change it to $this->size += $size.

The place for localization of the value should be when being outputted:

<?php echo JHtml::_('number.bytes', $item->size*1024); ?>

number.bytes does not do the localization either but that is the logical place for it (IMO); Final calculations on the value are being done and then the value is formatted to a string for display.

I can make a pull request for both files/issues but I wanted input first. If someone else wants to do it that's fine too.

avatar drewgg drewgg - open - 10 Feb 2017
avatar joomla-cms-bot joomla-cms-bot - change - 10 Feb 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 10 Feb 2017
avatar drewgg drewgg - edited - 10 Feb 2017
avatar drewgg drewgg - change - 10 Feb 2017
The description was changed
avatar drewgg drewgg - edited - 10 Feb 2017
avatar joomla-cms-bot joomla-cms-bot - change - 10 Feb 2017
The description was changed
avatar joomla-cms-bot joomla-cms-bot - edited - 10 Feb 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 30 Mar 2017
Category Cache
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Apr 2017

@drewgg can you please confirm Issue on latest staging?


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

avatar joomla-cms-bot joomla-cms-bot - change - 5 Apr 2017
The description was changed
avatar joomla-cms-bot joomla-cms-bot - edited - 5 Apr 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Apr 2017
Status New Information Required
avatar franz-wohlkoenig franz-wohlkoenig - change - 27 May 2017
Status Information Required Closed - No Reply
Closed_Date 0000-00-00 00:00:00 2017-05-27 10:34:43
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 27 May 2017
The description was changed
Status Closed - No Reply Information Required
avatar joomla-cms-bot joomla-cms-bot - edited - 27 May 2017
avatar joomla-cms-bot joomla-cms-bot - change - 27 May 2017
Status Information Required Closed
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 27 May 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 27 May 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 27 May 2017

This has been closed due to lack of response to the requests above – it can always be reopened in the future if it is updated.

avatar Melvine9
Melvine9 - comment - 2 Jun 2017

same issue when i removed a component

picture
php 7.1.5
Joomla 3.7.2
Best Regards
Melvine

Add a Comment

Login with GitHub to post a comment