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

Mute warnings thrown by LoadHTML() #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Dan0sz
Copy link

@Dan0sz Dan0sz commented Mar 3, 2022

Mute warnings for invalid HTML tags.

Description

I only added libxml_use_internal_errors(true); right above the LoadHTML() to mute any warnings it throws.

Motivation and Context

In its current state, the plugin fills the log with warnings like these:

PHP message: PHP Warning: DOMDocument::loadHTML(): Tag template invalid in Entity, line: 12

How Has This Been Tested?

Didn't feel it was necessary.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

Dan0sz added 2 commits March 3, 2022 22:06
Update class-gistpress.php
@Dan0sz Dan0sz changed the title Master Mute warnings thrown by LoadHTML() Mar 3, 2022
@bradyvercher
Copy link
Owner

Thanks @Dan0sz! If you can make a few updates, I'll go ahead and get this merged:

  1. Can you add some spaces around the argument to conform to the WordPress coding standards?
  2. I'm thinking this may need to be reversed after any DOM processing so it doesn't cause unintended side effects in other plugins. So add libxml_use_internal_errors( false ); toward the end of that function.
  3. Can you submit the PR against the develop branch?

salcode added a commit to salcode/gistpress that referenced this pull request Nov 24, 2023
Temporarily suspend PHP Warnings on invalid tags when processing Gist
HTML by setting the libxml_use_internal_errors() value to true.

The original value for libxml_use_internal_errors() is restored when the
processing is complete.

props @Dan0sz

See bradyvercher#80

Resolves bradyvercher#81
@salcode
Copy link
Contributor

salcode commented Nov 24, 2023

I've opened a new PR (#82) that implements @bradyvercher's requested changes.

bradyvercher pushed a commit that referenced this pull request Nov 24, 2024
Temporarily suspend PHP Warnings on invalid tags when processing Gist
HTML by setting the libxml_use_internal_errors() value to true.

The original value for libxml_use_internal_errors() is restored when the
processing is complete.

props @Dan0sz

See #80

Resolves #81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants