I have a patch request
-
I installed your plugin and it’s pretty awesome ??
Unfortunately it wasn’t updating the posts views(even after a couple of hours – I even made sure that the cron was actually running).
So, I looked at your code and I enabled debug and then I saw that cached data was returned to me – meaning I was only seeing stats for 2 posts, even though in the Jetpack stats I was seeing that more posts have views.
Initially I thought that the Jetpack Stats function is caching somewhere(even though the cache was never coming from the DB option cache), so I disabled the check for thestats_get_csv()
function so that the plugin would use your custom requests.Here comes another small issue that I found – you set the default value for the
blog_uri
option toget_bloginfo( 'wpurl' )
and that is different fromhome_url( '/' )
when you have your WordPress files in a different location. It seems though that Jetpack cares about the URL of the home page of the blog – so you should instead be usinghome_url( '/' )
.After playing around with the custom requests I noticed that I’m always getting the same exact result. The problem in this case was that you were always querying for days=-1 – and it seems like wordpress.com has a pretty sturdy caching system(that’s to be expected), so you never get new results.
What I did to make things easier was to add a new property to the class called
apiArgs
– it’s an array of key/value pairs and makes it much easier to construct URL’s, by utilizing WordPress’add_query_arg()
function ??So a couple of tweaks here and there and everything is working perfect on my end. Of course I don’t expect you to take my word for granted and I advise you on testing the code yourself, so that nothing goes wrong if you update the plugin and it suddenly breaks for someone.
You can find a diff of the latest version of the plugin(1.0.8) and my patched version here – https://www.diffchecker.com/gnc3km9f
If you have any questions about the patch, feel free to comment here.
- The topic ‘I have a patch request’ is closed to new replies.