Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontenberg PHP Fatal Errors in Jetpack 6.7 via missing Jetpack_React_Page #10558

Closed
tomjn opened this issue Nov 7, 2018 · 3 comments
Closed
Assignees
Labels
[Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Type] Bug When a feature is broken and / or not performing as intended
Milestone

Comments

@tomjn
Copy link
Contributor

tomjn commented Nov 7, 2018

An update to Jetpack v6.7 has broken frontenberg, causing the following PHP fatal error:

<b>Fatal error</b>: Uncaught Error: Class 'Jetpack_React_Page' not found in /srv/www/tomjn.com/htdocs/wp-content/plugins/jetpack/class.jetpack-gutenberg.php:208
Stack trace:
#0 /srv/www/tomjn.com/htdocs/wp-includes/class-wp-hook.php(286): Jetpack_Gutenberg::enqueue_block_editor_assets('')
#1 /srv/www/tomjn.com/htdocs/wp-includes/class-wp-hook.php(310): WP_Hook-&gt;apply_filters('', Array)
#2 /srv/www/tomjn.com/htdocs/wp-includes/plugin.php(453): WP_Hook-&gt;do_action(Array)
#3 /srv/www/tomjn.com/htdocs/wp-content/plugins/gutenberg/lib/client-assets.php(1664): do_action('enqueue_block_e...')
#4 /srv/www/tomjn.com/htdocs/wp-includes/class-wp-hook.php(286): gutenberg_editor_scripts_and_styles('')
#5 /srv/www/tomjn.com/htdocs/wp-includes/class-wp-hook.php(310): WP_Hook-&gt;apply_filters(NULL, Array)
#6 /srv/www/tomjn.com/htdocs/wp-includes/plugin.php(453): WP_Hook-&gt;do_action(Array)
#7 /srv/www/tomjn.com/htdocs/wp-includes/script-loader.php(1447): do_action('wp_enqueue_scri...')
#8 /srv/www/tomjn.com/htdocs/wp-includes/class-wp-hook.php(286): in <b>/srv/www/tomjn.com/htdocs/wp-content/plugins/jetpack/class.jetpack-gutenberg.php</b> on line <b>208</b><br />

I have corrected the issue by modifying class.jetpack-gutenberg.php on line 208 to include a class_exists check, which brought the site back, but I do not know what excluding this will have broken.

                if ( class_exists( 'Jetpack_React_Page' ) ) {
                        $jp_react_page = new Jetpack_React_Page();
                        wp_localize_script(
                                'jetpack-blocks-editor',
                                'Jetpack_Initial_State',
                                $jp_react_page->get_initial_state()
                        );
                }
                Jetpack::setup_wp_i18n_locale_data();

I'm expecting that Jetpack_React_Page is only loaded if is_admin is true, which is not the case in frontenberg and its child themes

@tomjn tomjn added [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Type] Bug When a feature is broken and / or not performing as intended labels Nov 7, 2018
@simison
Copy link
Member

simison commented Nov 7, 2018

CC @Automattic/poseidon

@tomjn tomjn changed the title Frontenberg Fatal Errors in Jetpack via Jetpack_React_Page Frontenberg PHP Fatal Errors in Jetpack 6.7 via missing Jetpack_React_Page Nov 7, 2018
@kraftbj
Copy link
Contributor

kraftbj commented Nov 7, 2018

We only need the React page class for get_initial_state. Should just extract that function to the Jetpack class or something like that.

@kraftbj kraftbj added this to the 6.8 milestone Nov 7, 2018
@kraftbj
Copy link
Contributor

kraftbj commented Nov 7, 2018

When working on this, we should also resolve #10495 to knock out two birds with one stone.

@kraftbj kraftbj modified the milestones: 6.8, 6.7.1 Nov 8, 2018
jeherve pushed a commit that referenced this issue Nov 9, 2018
…activated (#10566)

Fixes #10548
Fixes #10495
Fixes #10558

#### Changes proposed in this Pull Request:
* Instead of using `get_initial_state()` to shorthand how we get module activation data for block visibility this PR manually builds the needed data.
* `get_initial_state()` calls `get_modules` from `Jetpack_Core_API_Module_List_Endpoint` which doesn't respect module activation and [includes modules files](https://github.com/Automattic/jetpack/blame/496bebd5b1890666afe4fc79f52fd94353d88539/_inc/lib/class.core-rest-api-endpoints.php#L2813) which enqueues JS files ¯\_(ツ)_/¯ 

#### Testing instructions:
* Follow the steps in #10548
* Ideally you wont see any JS errors

#### Proposed changelog entry for your changes:
* Fixes an issue where deactivating ATD causes the post editor to throw JS errors
jeherve pushed a commit that referenced this issue Nov 9, 2018
…activated (#10566)

Fixes #10548
Fixes #10495
Fixes #10558

#### Changes proposed in this Pull Request:
* Instead of using `get_initial_state()` to shorthand how we get module activation data for block visibility this PR manually builds the needed data.
* `get_initial_state()` calls `get_modules` from `Jetpack_Core_API_Module_List_Endpoint` which doesn't respect module activation and [includes modules files](https://github.com/Automattic/jetpack/blame/496bebd5b1890666afe4fc79f52fd94353d88539/_inc/lib/class.core-rest-api-endpoints.php#L2813) which enqueues JS files ¯\_(ツ)_/¯ 

#### Testing instructions:
* Follow the steps in #10548
* Ideally you wont see any JS errors

#### Proposed changelog entry for your changes:
* Fixes an issue where deactivating ATD causes the post editor to throw JS errors
@jeherve jeherve modified the milestones: 6.7.1, 6.8 Nov 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

No branches or pull requests

5 participants