Skip to content

Conversation

@jaakkolehtonen
Copy link
Contributor

In WordPress 6.8, there was a change in how the Gutenberg block registration system handles the parent property. According to this forum thread, the parent property must now be either an array or undefined - passing null causes block registration to fail with the error: Uncaught TypeError: Cannot read properties of undefined (reading 'attributes')

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jaakkolehtonen, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request addresses a compatibility issue with WordPress 6.8 related to how block parent properties are handled in the Gutenberg block registration system. The change ensures that the parent property is either an array or undefined, as passing null now causes block registration to fail. I've modified the Block.php file to accommodate this change.

Highlights

  • WordPress 6.8 Compatibility: The code is updated to be compatible with the changes in WordPress 6.8 regarding Gutenberg block registration.
  • Parent Property Handling: The parent property is now handled to ensure it's either an array or undefined, preventing block registration failures.

Changelog

  • src/Block.php
    • Modified the register_block function to handle the parent property correctly.
    • Ensured that the parent property is only added to the $args array if it's not empty.
    • Moved the post_types assignment into a conditional block to mirror the parent property handling.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A block's parent,
A tricky update it seems,
WP six point eight.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an important compatibility issue with WordPress 6.8 regarding the parent property in Gutenberg block registration. The changes appear to be straightforward and effective in resolving the reported error. However, there are a few minor points to consider.

Merge Readiness

The changes in this pull request seem necessary to ensure compatibility with WordPress 6.8. Given the relatively low severity of the comments, and the fact that the changes are targeted to address a specific bug, I would recommend merging this pull request. However, I am unable to directly approve the pull request, and other reviewers should review and approve this code before merging.

@HPiirainen HPiirainen merged commit d570c87 into devgeniem:master Apr 23, 2025
@HPiirainen
Copy link
Contributor

Thanks again @jaakkolehtonen 👌

@HPiirainen
Copy link
Contributor

Version 1.41.4 released

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.

2 participants