Skip to content
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 Warning - Google API Key 400 Bad Request #27

Open
codejp3 opened this issue Oct 6, 2022 · 0 comments
Open

PHP Warning - Google API Key 400 Bad Request #27

codejp3 opened this issue Oct 6, 2022 · 0 comments
Labels

Comments

@codejp3
Copy link

codejp3 commented Oct 6, 2022

I've been testing my last pull request today by throwing a bunch of junk data at the plugin to see how it handles it. Found an issue affecting every "file_get_contents" function call. Here's an example when a bad API Key string is supplied:

file_get_contents (wp-content/plugins/acf-typography-field/includes/functions.php => 45)
file_get_contents(https://www.googleapis.com/webfonts/v1/webfonts?key=BAD_API_KEY_STRING): failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request

I'm already patching this. PR will also include this patch.

In admin_settings.php:
It will now check the key against the Google API Key URL. If it encounters any errors, a message will be displayed showing the response header error message.

In functions.php:
Every "file_get_contents" function will suppress displaying error messages publicly and only process the output if there was no error message.

Idea / Enhancement - Possibly add a debug log and an "enable/disable debugging" admin setting to capture file and URL read/write errors?

This was referenced Oct 7, 2022
@mujahidi mujahidi added the bug label Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants