• Resolved sunstate

    (@sunstate)


    TypeError: Cannot read properties of undefined (reading 'lightbox')
    at migrate (https://flatsun2.com/wp-includes/js/dist/block-library.min.js?ver=875919a30abea6016ef8:14:185125)
    at https://flatsun2.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:35725
    at Zn (https://flatsun2.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:35870)
    at https://flatsun2.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:35030
    at Array.map (<anonymous>)
    at Zn (https://flatsun2.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:35022)
    at https://flatsun2.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:35030
    at Array.map (<anonymous>)
    at Zn (https://flatsun2.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:35022)
    at https://flatsun2.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:36374

    After updating WordPress, when I try to create or edit a post in the editor, I get the following error: I deactivated the simple lightbox plugin, but it still doesn’t work. Do you have any information that might help?

Viewing 15 replies - 1 through 15 (of 20 total)
  • Hello! What version of WordPress are you upgrading from?

    If you’re able to go into your database, would you be able to send the markup for one of the posts?

    Also, do you run into the same issue when using the Site Editor and inserting an image?

    Thread Starter sunstate

    (@sunstate)

    After upgrading to version 6.4, when I enter Add New Post and then enter the Editor screen, I get this error, I checked functions.php and it seems to be caused by the following code I put in function.php before $metadata[‘attributes’][‘align’][‘default’] = ‘center’; when I use that part, I start getting errors from 6.3 and the rest of the code doesn’t seem to be a problem I think I just need to change one line to 6.3 compatible code, do you know anything about it?

    add_filter( 'block_type_metadata', 'set_image_auto_centre' );
    
    function set_image_auto_centre( $metadata ) {
      if ( 'core/image' !== $metadata['name'] ) {
        return $metadata;
      }
      $metadata['attributes']['align']['default'] = 'center';
    
      return $metadata;
    }

    Thread Starter sunstate

    (@sunstate)

    the same code works fine for headings and paragraphs, but core/image seem to have a problem, I’ve attached the code I used in the same way

    if ( ! function_exists( 'add_newheading_edit_block_metadata' ) ) {
    	function add_newheading_edit_block_metadata($metadata) {
    		// Center core/heading
    		if ($metadata['name'] == 'core/heading') {
    			$metadata['attributes']['textAlign']['default'] = 'center';
    		}		
    		return $metadata;
    	}
    }		
    add_filter('block_type_metadata', 'add_newheading_edit_block_metadata', 10, 2);
    
    if ( ! function_exists( 'addedlovely_edit_block_metadata' ) ) {
    	function addedlovely_edit_block_metadata($metadata) {
    		// Center core/paragraph
    		if ($metadata['name'] == 'core/paragraph') {
    			$metadata['attributes']['align']['default'] = 'center';
    		}		
    		return $metadata;
    	}
    }		
    add_filter('block_type_metadata', 'addedlovely_edit_block_metadata', 10, 2);
    

    This may have to do with the image’s deprecated.js — that’s the link to the file in Gutenberg, but I’m not sure where it ends up in WordPress core. Am looking now.

    The fact that the error message mentions migrate and that a native lightbox was just added to core is tipping me in this direction, though am not sure.

    Hello, same here.

    It seems older posts with older editor are affected.

    Newer post that were made up to 1 year ago work fine. But I can’t edit older posts. Just clicking within the post returns in error

    UPDATE: Now all posts are affected. Can’t edit.

    TypeError: Cannot read properties of undefined (reading 'map') at https://websitename.com/wp-includes/js/dist/block-editor.min.js?ver=f0bb1e364b792257eb17:26:68033 at Array.map (<anonymous>) at Pt (https://websitename.com/wp-includes/js/dist/block-editor.min.js?ver=f0bb1e364b792257eb17:26:67938) at https://websitename.com/wp-includes/js/dist/block-editor.min.js?ver=f0bb1e364b792257eb17:26:68635 at l (https://websitename.com/wp-includes/js/dist/block-editor.min.js?ver=f0bb1e364b792257eb17:26:53216) at https://websitename.com/wp-includes/js/dist/block-editor.min.js?ver=f0bb1e364b792257eb17:26:69165 at l (https://websitename.com/wp-includes/js/dist/block-editor.min.js?ver=f0bb1e364b792257eb17:26:53216) at https://websitename.com/wp-includes/js/dist/block-editor.min.js?ver=f0bb1e364b792257eb17:26:69477 at l (https://websitename.com/wp-includes/js/dist/block-editor.min.js?ver=f0bb1e364b792257eb17:26:53216) at https://websitename.com/wp-includes/js/dist/block-editor.min.js?ver=f0bb1e364b792257eb17:26:70058
    • This reply was modified 11 months, 2 weeks ago by bla2e.

    @sunstate I’ve taken a closer look at this and indeed, modifying the meta attributes appears to cause the migration function to run unexpectedly, causing the error.

    I’m currently consulting with some other contributors to find the best path forward.

    Thread Starter sunstate

    (@sunstate)

    @artemiosans Thank you, and I look forward to a resolution.

    Same issue.

    The edit post link just takes you to a blank page. Here’s the error message I get from the console:

    TypeError: Cannot read properties of undefined (reading 'lightbox')
        at migrate (block-library.min.js?ver=875919a30abea6016ef8:14:185125)
        at blocks.min.js?ver=7204d43123223474471a:10:35725
        at Zn (blocks.min.js?ver=7204d43123223474471a:10:35870)
        at blocks.min.js?ver=7204d43123223474471a:10:35030
        at Array.map (<anonymous>)
        at Zn (blocks.min.js?ver=7204d43123223474471a:10:35022)
        at blocks.min.js?ver=7204d43123223474471a:10:36374
        at Array.reduce (<anonymous>)
        at Xn (blocks.min.js?ver=7204d43123223474471a:10:36350)
        at core-data.min.js?ver=99b262137df116eb6013:2:50646

    EDIT: In my case, it was in part being caused by a function I added to change the default image alignment: Change default image alignment to center https://www.intelliwolf.com/auto-set-image-alignment-wp-block-editor/ But it’s still happening

    Same issue here. Shows the post editor page, and I get the error page “The editor has encountered an unexpected error.” as soon as I click into the post somewhere. Was able to stop the error by excluding my themes folder, but not my plugins folder.

    TypeError: Cannot read properties of undefined (reading 'lightbox')
        at migrate (https://example.com/wp-includes/js/dist/block-library.min.js?ver=875919a30abea6016ef8:14:185125)
        at https://example.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:35725
        at Zn (https://example.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:35870)
        at https://example.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:35030
        at Array.map (<anonymous>)
        at Zn (https://example.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:35022)
        at https://example.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:35030
        at Array.map (<anonymous>)
        at Zn (https://example.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:35022)
        at https://example.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:36374
        at Array.reduce (<anonymous>)
        at Xn (https://example.com/wp-includes/js/dist/blocks.min.js?ver=7204d43123223474471a:10:36350)
        at https://example.com/wp-includes/js/dist/block-editor.min.js?ver=f0bb1e364b792257eb17:26:68387
        at l (https://example.com/wp-includes/js/dist/block-editor.min.js?ver=f0bb1e364b792257eb17:26:53216)
        at https://example.com/wp-includes/js/dist/block-editor.min.js?ver=f0bb1e364b792257eb17:26:68733
        at Array.map (<anonymous>)

    • This reply was modified 11 months, 2 weeks ago by awideman.
    • This reply was modified 11 months, 2 weeks ago by awideman.

    Update: Ignore my reply – was just sent an update from my theme to fix the issue with the lightbox.

    Hi all, I’ve created a Github issue to discuss this bug more in depth, along with a proposed fix here.

    Please feel free to chime in with any additional thoughts on the issue or pull request. We can hopefully get a fix in for the next minor release, WordPress 6.4.2.

    In the meantime, as a temporary fix, you can add the following code to the image block’s v8 migrate function in one of two places. If taking this approach, please make sure to create a backup of your files and note that any changes here will be overridden when you update Gutenberg or WordPress.

    if ( ! attributes.behaviors?.lightbox ) {
    	return attributes;
    }
    1. if you have Gutenberg installed and activated, you can add the code to packages/block-library/src/image/deprecated.js around line 1049.
    2. If you’re running WordPress without Gutenberg, you can add the code to wp-includes/js/dist/block-library.js around line 23678

    Thank you!

    Paolo Beccari

    (@paolobeccari)

    I’m experiencing similar issues when trying to launch the editor via an out-to-date browser (Firefox 78.15.0esr 64 bit) on an out-to-date Mac under El Capitan 10.11.6.
    Everything seems to work fine if I edit the same installation with more recent software / hardware.
    Also a test with Chrome 98.0.4758.102 on my old Mac seems to work fine.
    Hopefully this can help.

    Thread Starter sunstate

    (@sunstate)

    @artemiosans

    I’ve updated to WordPress 6.4.2, but I’m still getting the same error, is it possible that the fix hasn’t been implemented yet?

    Hi, I’m getting this same error when trying to create a new post or edit an existing one:

    TypeError: Cannot read properties of undefined (reading ‘lightbox’)
    at migrate (https://bigcupofcoffee.com/wp-includes/js/dist/block-library.min.js:14:185125)
    at https://MYURL.com/wp-includes/js/dist/blocks.min.js:10:35725
    at Zn (https://MYURL.com/wp-includes/js/dist/blocks.min.js:10:35870)
    at https://MYURL.com/wp-includes/js/dist/blocks.min.js:10:35030
    at Array.map ()
    at Zn (https://MYURL.com/wp-includes/js/dist/blocks.min.js:10:35022)
    at https://MYURL.com/wp-includes/js/dist/blocks.min.js:10:35030
    at Array.map ()
    at Zn (https://MYURL.com/wp-includes/js/dist/blocks.min.js:10:35022)
    at https://MYURL.com/wp-includes/js/dist/blocks.min.js:10:36374

    I fixed it by removing the default image centering code I had in my custom functions file:

    // changing default gutenberg image block alignment to “center”
    function change_default_gutenberg_image_block_options (){
    ? $block_type = WP_Block_Type_Registry::get_instance()->get_registered( “core/image” );
    ? $block_type->attributes[‘align’][‘default’] = ‘center’;
    }

    add_action( ‘init’, ‘change_default_gutenberg_image_block_options’);

    • This reply was modified 10 months, 1 week ago by theguitarlesson. Reason: Added code

    @sunstate I just tested in WordPress 6.4.2 and indeed, it seems the issue is still present. As far as I can tell though, the fix was supposed to be merged.

    I’m currently checking on this to see what happened. Thanks for following up!

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘wordpress editor The editor has encountered an unexpected error.’ is closed to new replies.