-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP Fatal error in rates.php on line 168 #5
Comments
Current L168 in rates.php is a blank line in master branch https://github.com/nekojira/wp-currencies/blob/master/includes/rates.php#L168 |
if it's the latest version from WordPress - there was a minor commit in between on Github - so it could be actually this line for the version on WordPress.org https://github.com/nekojira/wp-currencies/blob/master/includes/rates.php#L174 I'm not sure if wp_remote_get() returns an instance of WP_Error if it can't fetch results. how frequent does it happen in logs? at the same interval it fetches currencies? do the currencies get updated in your db? do the requests on the stats on openexchangerates.org seem to match the requests that WP Currencies should make? |
Oh wow... are you on a free account and getting these all from a single installation of WP Currencies or from elsewhere? Have you disclosed the API key somewhere? I think you're generating a bit less than a request per second on a day and the most WP Currencies should make is 1 request per hour... |
just investigating. no, nothing else than wp-currencies should use the API. Cron is set to run hourly (even double checked the crons in the options table... all correct). |
It's very likely, probably I need to make it fail more gracefully in such cases. I never run out of quota so I'm not sure what Openexchangerates returns in case of quota failure to pass the error message in WordPress. If you published the API key somewhere, it's possible that someone used it as well. I double checked on cron.php that the most frequent interval in seconds is 1 day. I don't think currently the update method in the Rates class is called elsewhere other than cron. Unless it's called specifically in some custom code or the cron job is forced to run more frequently (or the cron is misconfigured on the server?). If it's caused by WP Currencies, you should see that error at every second at least, like thousands of lines of the same error in your logs. You could try to get a new app ID (the key) and see if the problem persist. |
I did not knowingly publish it. As long as I'm over quota we could try to implement a better fail. Suggestions, where to have a look? |
(i don't think the huge amount of requests is caused by wp-currencies, either) |
To quickly fix the warnings issue I have made a new commit just now. It checks if the requests fails and if it's WP_Error won't proceed. About your specific problem with the exceeded quota limit I'm not sure. But you can try changing the App ID to begin with. |
Well, i deactivate wp-currencies and the flood of requests stopped. Could be coincidence - but I guess not. Trying to debug it later today. |
I think the error originated from WP Currencies. I'm going to fix this asap. |
Can I help you in any way? Put log-statements to some crucial places? Do you want my API-key for testing purposes? |
I am very sorry. This happened only in 1.4.0. I had set a hook to update the currencies every time a new interval was saved in options. But instead of using hook 'updated_option_ I used 'update_option' a small typo, but made a big difference because it was being fired every time you called WP Currencies. This is now fixed with the last commit and I'm going to update the WordPress svn as well. |
Nothing to be sorry about. Shit happens. Thanks for fixing :) |
Please let me know how it goes with the plugin. I need to come up with a way to write proper tests for it by passing a key every time or in a local configuration file, since I don't want to put an API key in the repo. |
I uninstalled the old version via wp gui, uploaded and installed the new version, added the api key, changed to hourly upates. Result: 3 entries in wp-cron:
No data yet in wp-currencies table. Maybe first update will take an hour if set to hourly updates? Also, you should probably check for old cron-jobs before creating new ones (and remove them on deactivation and deletion!) |
Uhm. On deactivation wp_clear_scheduled_hook( 'wp_currencies_update' ) it should be fired: https://github.com/nekojira/wp-currencies/blob/master/includes/install.php#L53 Now I'm also clearing it before rescheduling (in case of settings change): https://github.com/nekojira/wp-currencies/blob/master/includes/settings.php#L218 A few lines below you can see what happens when one saves the settings, it should schedule or reschedule the event (actually since few lines above it was cleared, that conditional wouldn't even be needed, but I'm leaving it there just in case). From what I understood |
mhhhh okey. Request flood has started again, too. Weird. I'll clear the crons manually now and see what happens. |
Okey i inserted a debug message right before the requests for currency lists and rates.
So it definitely is wp-currencies making all these requests. |
but even after the latest updates from yesterday? I changed the action hook - I don't understand why the two methods in rates.php are being called even when the site is not moving update_rates is the callback for the wp cron job defined in cron.php - the Cron class schedules the action hook wp_currencies_update and it should only fire the first time it's set (or options updated) and then at the set interval frequency (hourly, weekly, etc). what's your idea? |
The only possibility that I'm still using the wrong action hook - I chose options_updated, which should be fired only when... options are updated - and the callback for it has a wrapper that checks if the $option passed is wp_currencies_settings, ie. it's WP Currencies options that are saved. |
to be honest even the previous action hook looked like correct - 'update_option_wp_currency_settings', it should have fired only when wp_currency_settings is updated and saved to db... but I thought it was the wrong hook |
ok I reverted to the previous hook after checking WP codebase... it was fine instead, I'm trying now to wrap the cron action callback with a wrapper that checks if WordPress is doing a cron job: although I think that wasn't necessary, this would stop running the update unless it's a cron job caveats:
|
we are continuing this discussion on #6 where I posted the latest updates |
@extrapixel please try with the latest plugin version I think the issue is finally solved |
PHP Fatal error: Cannot use object of type WP_Error as array in (...)/wp-content/plugins/wp-currencies/includes/rates.php on line 168
I don't know when this happens... but it's popping up in my error log sometimes.
The text was updated successfully, but these errors were encountered: