Comments (15)
Fun times: https://3v4l.org/i82FN
from autoptimize.
should be fixed with commit 258bf00
from autoptimize.
This is weird, I don't have this commit applied and when dumping data just to test quickly by editing autoptimizeToolbar.php after L60:
var_dump($stats, $bytes, $class, $size, $percentage); exit;
which results in this output:
array (size=3)
0 => int 0
1 => int 0
2 => int 1464706737
int 0
int 0
string '0.00 B' (length=6)
float 0
And I get no such warning anywhere... The warning means the divisor is 0, not the dividend? Or?
(which would mean $class
ended up being 0
?)
Or I might be reading things wrong after a full days work...
from autoptimize.
problem is that the divider is based on $class, which is based on log( $bytes , 1024 ). so if $bytes is 0, things indeed might not always go down well :)
from autoptimize.
It's platform dependant, core issue is in use of min()
and/or int casting, see: https://3v4l.org/iPdnC
from autoptimize.
Oops! Thanks you @zytzagoo
another way to fix that, maybe could be:
$bytes = $stats[1]|1;
from autoptimize.
I'll let you guys agree on the best approach, you're a lot more knowledgeable :-)
from autoptimize.
Don't believe it, maybe all depends on the coffee cups number ;-)
sorry, is better add the condition in this line (for $bytes does not remain with 1):
$class = min( (int) log( $bytes|1 , 1024 ), count( $si_prefix ) - 1 );
BTW: We would also have to change the ceil
by floor
$percentage = floor( $bytes / $max_size * 100 );
What do you think?
from autoptimize.
so @zytzagoo, @pablocusto, what is your preferred solution? :-)
from autoptimize.
My fork is using what I've committed above until you guys settle on whatever :)
(at which point I'll change my fork to match upstream if needed [so that I can keep up with future updates more easily])
from autoptimize.
did the tests and @zytzagoo method has better performance.
this is the test: https://3v4l.org/ZJ0ss
but I think we should change the ceil
by floor
to round the percentage value.
from autoptimize.
Great, @zytzagoo could you issue a PR with just this specific fix?
from autoptimize.
Didn't touch ceil
since it's an unrelated change really (should be a separate commit/pr/issue basically).
Not really sure which is better -- my gut says to stay with ceil since it "errors up" and this is about percentages shown to the users (meaning if they're close to full cache, it's better to be notified "sooner" rather than "later" -- but it's nitpicking, I mean, we're talking 1% up/down difference in the worst case, no?)
Plus, ceil
doesn't require any further code changes and I'm lazy like that :)
from autoptimize.
thanks for the PR, merged! :)
I prefer to stick with ceil
, as it's weird to have 0% when you have e.g. 10 files 312KB.
from autoptimize.
You're right, I had not thought that.
That just to 5 Mb are 1%.
from autoptimize.
Related Issues (20)
- Undefined offset autoptimizeStyles.php HOT 3
- autoptimizecriticalcsscron PHP array key warnings HOT 5
- Avif support broken HOT 6
- Minified JS broken with private class identifiers HOT 4
- Disable emoji dns-prefetch in ClassicPress HOT 1
- PHP8 Warning HOT 1
- Optimized JS and inline script order HOT 3
- Problem with media="print" HOT 3
- Inline "background" not replaced with shortpixel HOT 5
- Security risk reported by Kaspersky HOT 6
- Proposal: stronger default settings HOT 9
- Optimised Google Fonts still blocking for 1.3s according to PageSpeed HOT 2
- Add: option to enable WebP as default output format HOT 1
- PHP Warning in cronjob: Trying to access array offset on value of type int in autoptimizeCacheChecker.php HOT 3
- Creation of dynamic property in autoptimizeProTab.php HOT 4
- Proposal: add Plugin Check workflow HOT 6
- Autoptimize deletes all subfolders in /cache/ HOT 3
- Incorrect cache size triggering unnecessary email warnings HOT 4
- WP CLI command does not take multisite into acocunt HOT 1
- Deprecation warning in jsmin.php HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autoptimize.