equalizedigital / accessibility-checker

GNU General Public License v2.0
14 stars 8 forks source link

Auto-draft on a new post triggers a scan resulting in an error #539

Closed pattonwebz closed 4 months ago

pattonwebz commented 5 months ago

Please give us a description of what happened.

When you create a new post in the block editor a scan is triggered on the auto draft resulting in an an error that causes the password protected message to appear until a post is saved and a scan on a valid page is successful.

Please describe what you expected to happen and why.

No scan is triggered on an autodraft with no content.

How can we reproduce this behavior?

  1. Create a new post
  2. See message in error logs
  3. Notice the password protected site message banner appears till a post is published or it's otherwise cleared.

Technical info

pattonwebz commented 5 months ago

There is a function in the plugin that triggers a frontend validation scan on a post. It's triggered by template_redirect hook.

The block editor, when opened, makes a call to determine the available templates the post_type can use which triggers that action and the validation scan. If the editor is opened for a new post it will be an auto-draft and have no accessible page yet so the validate fails resulting in a logged error and then the plugin makes the assumption that the site is password protected.

Error that is thrown:

[19-Mar-2024 18:08:33 UTC] PHP Warning:  file_get_contents(http://local.testsite.test/?p=62642&edac_cache=1710871710): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /var/www/html/wp-content/plugins/accessibility-checker/includes/simplehtmldom/simple_html_dom.php on line 79
SteveJonesDev commented 5 months ago

Related issue: https://github.com/equalizedigital/accessibility-checker/issues/476