Title: Fatal error saving table – DOMDocument ValueError on PHP 8
Last modified: October 9, 2025

---

# Fatal error saving table – DOMDocument ValueError on PHP 8

 *  [smartfinds](https://wordpress.org/support/users/smartfinds/)
 * (@smartfinds)
 * [8 months ago](https://wordpress.org/support/topic/fatal-error-saving-table-domdocument-valueerror-on-php-8/)
 * Hi WP Table Builder Team,
 * We’re encountering a fatal error when saving a table on our WordPress site (**
   smartfindsmarketing.com**). The issue occurs via `admin-ajax.php` when performing
   a “Save Table” action.
 * Below is the relevant error excerpt from our `debug.log` file:
 *     ```wp-block-code
       PHP Fatal error:  Uncaught ValueError: DOMDocument::loadHTML(): Argument #1 ($source) must not be empty
       in /wp-content/plugins/wp-table-builder/vendor/rhukster/dom-sanitizer/src/DOMSanitizer.php:326
       Stack trace:
       #0 /wp-content/plugins/wp-table-builder/vendor/rhukster/dom-sanitizer/src/DOMSanitizer.php(326): DOMDocument->loadHTML('')
       #1 /wp-content/plugins/wp-table-builder/inc/Shortcode_Element.php(147): DOMSanitizer->sanitize('')
       #2 /wp-content/plugins/wp-table-builder/inc/TableRenderer.php(234): Shortcode_Element->render()
       #3 /wp-content/plugins/wp-table-builder/inc/Admin_Menu.php(429): TableRenderer->render_cell()
       #4 /wp-includes/class-wp-hook.php(308): Admin_Menu->save_table()
       #5 /wp-admin/admin-ajax.php(203): do_action('wp_ajax_save_table')
       ```
   
 * **What we’ve already checked:**
    - Running PHP 8.0.
    - Confirmed no database errors.
    - The error triggers when a table includes a shortcode or possibly an empty 
      cell.
    - Other unrelated plugin warnings (“Add Search to Menu”) are present but not
      the root cause.
 * **Hypothesis:**
   It appears the plugin’s DOM sanitizer attempts to call `DOMDocument::
   loadHTML()` on an empty string, which PHP 8+ now treats as a `ValueError`. This
   may need a guard to skip empty input before sanitization.
 * **Questions:**
    1. Can you confirm if this is a known issue with WP Table Builder on PHP 8.x?
    2. Is there a patch or temporary fix (e.g., conditional check) to prevent this 
       error until an update is released?
    3. Would you like me to provide a sample table export or exact steps to reproduce
       it?
 * Thank you for your time and for maintaining a great plugin!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Contributor [Saad](https://wordpress.org/support/users/protibimbok/)
 * (@protibimbok)
 * [7 months, 4 weeks ago](https://wordpress.org/support/topic/fatal-error-saving-table-domdocument-valueerror-on-php-8/#post-18676030)
 * Thank you for your detailed report.
   1. No, it is not a known issue.2. You can
   replace the part in `/wp-content/plugins/wp-table-builder/inc/Shortcode_Element.
   php` with
 * `$shortcode = trim($props['shortcode'] ?? '');
   if (empty($shortcode)) { $code
   = '';} else { $sanitizer = new DOMSanitizer(DOMSanitizer::HTML); $code = $sanitizer-
   >sanitize($shortcode, [ 'remove-html-tags' => false, ]);}3. Checking the instruction
   2 would be more helpful.Thank you for sticking with us.
 *  Thread Starter [smartfinds](https://wordpress.org/support/users/smartfinds/)
 * (@smartfinds)
 * [7 months, 4 weeks ago](https://wordpress.org/support/topic/fatal-error-saving-table-domdocument-valueerror-on-php-8/#post-18676170)
 * Hi Saad,
 * Thanks again for your earlier help with the PHP 8.0 `ValueError` issue. We followed
   your instructions to add the guard around the sanitizer, but wanted to note that
   the file path you provided (`/inc/Shortcode_Element.php`) does not exist in the
   current plugin version.
 * In our installation, the correct file was located at:
   `/inc/admin/element-classes/
   elements/shortcode-element.php`
 * We implemented the guard there, and it did stop the original `DOMDocument::loadHTML()`
   fatal error on PHP 8.0. However, after applying the change, we were no longer
   able to access WP Table Builder in WP Admin — it displayed “Sorry, you are not
   allowed to access this page.”
 * We’ve since reverted the file to its original version, and the admin access issue
   disappeared immediately.
   So while the proposed guard fixes the fatal error itself,
   it appears to introduce a secondary issue in the current version of the plugin.
 * Would you be able to review this behavior and confirm the correct placement or
   logic for the guard? We’d be happy to test a corrected version or updated build
   if you release one.
 * Thanks again for your assistance,

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Fatal error saving table – DOMDocument ValueError on PHP 8’ is closed
to new replies.

 * ![](https://ps.w.org/wp-table-builder/assets/icon-256x256.png?rev=2404323)
 * [WP Table Builder – Drag & Drop Table Builder](https://wordpress.org/plugins/wp-table-builder/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-table-builder/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-table-builder/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-table-builder/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-table-builder/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-table-builder/reviews/)

## Tags

 * [admin-ajax](https://wordpress.org/support/topic-tag/admin-ajax/)
 * [domdocument](https://wordpress.org/support/topic-tag/domdocument/)
 * [fatal error](https://wordpress.org/support/topic-tag/fatal-error/)

 * 2 replies
 * 2 participants
 * Last reply from: [smartfinds](https://wordpress.org/support/users/smartfinds/)
 * Last activity: [7 months, 4 weeks ago](https://wordpress.org/support/topic/fatal-error-saving-table-domdocument-valueerror-on-php-8/#post-18676170)
 * Status: not resolved