humanmade / humanmade/hm-top-posts
Refactor: add_options explicitly as autoload=no
- Dominant language
- PHP
- Stars
- 29
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
I just now came across @rmccue's reported Core bug [#28701](https://core.trac.wordpress.org/ticket/28701)(Deleted option is not deleted if value was ever null) in the wild, specifically here in `hm-top-posts`. The password had been changed for the Google Account, and so this notice was appearing on every admin page:
> Top Posts by Google Analytics Error: GAPI: Failed to authenticate user. Error: "Error=BadAuthentication "
Now, this notice is stored in the option `hmtp_top_posts_error_message` and it is supposed to get deleted after it is shown. However, it was not getting deleted. It was persisting. It seems that the problem is that this option gets set to null at some point, and since it is an auto-loaded option (since it is not declared otherwise with `add_option`), any `delete_option` calls result in a no-op.
I don't think that these Top Posts options actually should be autoloaded, so I suggest that they get registered up-front via `add_option` and pass the `$autoload` argument as `no`.
Contributor guide
Assessment
This issue has not been assessed yet.