Title: PHP 8.3+ error for gallery block
Last modified: June 25, 2026

---

# PHP 8.3+ error for gallery block

 *  [Sallie Goetsch](https://wordpress.org/support/users/wpfangirl/)
 * (@wpfangirl)
 * [1 week, 5 days ago](https://wordpress.org/support/topic/php-8-3-error-for-gallery-block/)
 * Bug Description
 * When attempting to transition from the legacy Document Gallery shortcode to the
   new Document Gallery Gutenberg Block, the site throws a PHP Fatal TypeError.
 * This happens because the block editor passes taxonomy data as a `stdClass` object
   instead of a comma-separated string to the `setTaxa()` method, which strict PHP
   8.3 types reject when handled by `explode()`. Environment
    - **WordPress Version:** 7.0
    - **PHP Version:** 8.3.x
    - **Plugin:** Document Gallery
 * Steps to Reproduce
    1. Ensure the site is running PHP 8.3+.
    2. Edit a page/post and add the Document Gallery Block (or convert an existing 
       shortcode to the block).
    3. Attempt to render or preview the block.
 * Error Log / Stack Trace
 *     ```wp-block-code
       [24-Jun-2026 22:38:23 UTC] PHP Fatal error:  Uncaught TypeError: explode(): Argument #2 ($string) must be of type string, stdClass given in /public_html/wp-content/plugins/document-gallery/src/inc/class-gallery.php:338Stack trace:#0 /public_html/wp-content/plugins/document-gallery/src/inc/class-gallery.php(338): explode(',', Object(stdClass))#1 /public_html/wp-content/plugins/document-gallery/src/inc/class-gallery.php(270): DG_Gallery->setTaxa(Array)#2 /public_html/wp-content/plugins/document-gallery/src/inc/class-gallery.php(244): DG_Gallery->getAttachments()#3 /public_html/wp-content/plugins/document-gallery/src/inc/class-document-gallery.php(26): DG_Gallery->__construct(Array)#4 /public_html/wp-content/plugins/document-gallery/document-gallery.php(149): DocumentGallery::doShortcode(Array)#5 /public_html/wp-includes/class-wp-block.php(596): document_gallery_block_render_callback(Array, '', Object(WP_Block))#6 /public_html/wp-includes/blocks.php(2438): WP_Block->render()#7 /public_html/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php(191): render_block(Array)#8 /public_html/wp-includes/rest-api/class-wp-rest-server.php(1287): WP_REST_Block_Renderer_Controller->get_item(Object(WP_REST_Request))#9 /public_html/wp-includes/rest-api/class-wp-rest-server.php(1120): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wp/v2/block-re...', Array, NULL)#10 /public_html/wp-includes/rest-api/class-wp-rest-server.php(435): WP_REST_Server->dispatch(Object(WP_REST_Request))#11 /public_html/wp-includes/rest-api.php(471): WP_REST_Server->serve_request('/wp/v2/block-re...')#12 /public_html/wp-includes/class-wp-hook.php(341): rest_api_loaded(Object(WP))#13 /public_html/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters('', Array)#14 /public_html/wp-includes/plugin.php(570): WP_Hook->do_action(Array)#15 /public_html/wp-includes/class-wp.php(418): do_action_ref_array('parse_request', Array)#16 /public_html/wp-includes/class-wp.php(821): WP->parse_request('')#17 /public_html/wp-includes/functions.php(1343): WP->main('')#18 /public_html/wp-blog-header.php(16): wp()#19 /public_html/index.php(17): require('/...')#20 {main}  thrown in /public_html/wp-content/plugins/document-gallery/src/inc/class-gallery.php on line 338
       ```
   
 * Technical Context from Gemini
 * In `src/inc/class-gallery.php` on line 338, the code assumes `$terms` is a string:
   `
   $terms = $this->getTermIdsByNames( $taxon, explode( ',', $terms ) );`
 * The developer likely needs to add a type-check or cast `$terms` before running
   it through `explode()` when it’s being invoked via `document_gallery_block_render_callback`.
   
   I was able to switch back to the shortcode as a temporary measure, but wanted
   to notify you about the problem.

Viewing 1 replies (of 1 total)

 *  Plugin Author [Dan Rossiter](https://wordpress.org/support/users/danrossiter/)
 * (@danrossiter)
 * [1 week ago](https://wordpress.org/support/topic/php-8-3-error-for-gallery-block/#post-18951593)
 * Hi [@wpfangirl](https://wordpress.org/support/users/wpfangirl/),
 * Thanks for this detailed report. I’ll investigate and circle back.
 * Best,
 * Dan

Viewing 1 replies (of 1 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-8-3-error-for-gallery-block%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/document-gallery/assets/icon.svg?rev=983329)
 * [Document Gallery](https://wordpress.org/plugins/document-gallery/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/document-gallery/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/document-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/document-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/document-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/document-gallery/reviews/)

## Tags

 * [blocks](https://wordpress.org/support/topic-tag/blocks/)
 * [errors](https://wordpress.org/support/topic-tag/errors/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 1 reply
 * 2 participants
 * Last reply from: [Dan Rossiter](https://wordpress.org/support/users/danrossiter/)
 * Last activity: [1 week ago](https://wordpress.org/support/topic/php-8-3-error-for-gallery-block/#post-18951593)
 * Status: not resolved