• 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

    [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:338
    Stack 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)
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.