pluginkollektiv / statify

Statify – statistics plugin for WordPress
https://wordpress.org/plugins/statify/
GNU General Public License v3.0
76 stars 22 forks source link

do not return NULL, if database is empty #273

Closed stklcode closed 10 months ago

stklcode commented 10 months ago

Null causes trouble during further processing, i.e. PHP warnings in the API processing and later on problems building the dashboard widget in Javascript, because all methods expect the array to have all keys.

Move the caching (transient) directive into the conditional, so we still do not cache empty results and so not return NULL anymore.


This part will produce a couple of warnings, if get_stats() returns null: https://github.com/pluginkollektiv/statify/blob/0ec5f693bc01f584a8c13f1ddb2911c79211e1ff/inc/class-statify-api.php#L127-L129

And this part will fail: https://github.com/pluginkollektiv/statify/blob/0ec5f693bc01f584a8c13f1ddb2911c79211e1ff/js/dashboard.js#L161-L166

sonarcloud[bot] commented 10 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication