EnlighterJS / Plugin.WordPress

:package: Official WordPress Plugin of EnlighterJS
http://wordpress.org/plugins/enlighter/
GNU General Public License v2.0
115 stars 17 forks source link

Crashing page/post editor 100% of the time #325

Closed theDanielJLewis closed 3 years ago

theDanielJLewis commented 3 years ago

I'm running WordPress 5.6 with Enlighter 4.4.1 CE on PHP 7.3.5 and 7.4.1.

With nothing by Twenty Twenty theme and Enlighter enabled, my Gutenberg page/post editor crashes and won't let me edit or create anything.

If I edit an existing page, clicking anywhere in the contents will crash the editor.

If I'm creating a new page, the editor crashes after typing only a few characters.

This happens only with Enlighter enabled (and nothing else).

Here's the official error the WP editor gives me:

TypeError: r is not a function
    at https://podcastindustryinsights.local/wp-includes/js/dist/components.min.js?ver=df4b16e21104c0e1043e9c0a0eeedd94:7:311955
    at Bh (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:126:456)
    at Dj (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:162:476)
    at unstable_runWithPriority (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react.min.js?ver=16.13.1:25:260)
    at Da (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:60:280)
    at xb (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:162:231)
    at mk.Events.current (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:236:102)
    at Ei (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:41:59)

But I see more in my browser console:

data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2 An error occurred while running 'mapSelect': Cannot read property 'replace' of undefined
We @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
(anonymous) @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
we @ react-dom.min.js?ver=16.13.1:84
zj @ react-dom.min.js?ver=16.13.1:226
Th @ react-dom.min.js?ver=16.13.1:152
tj @ react-dom.min.js?ver=16.13.1:152
Te @ react-dom.min.js?ver=16.13.1:146
(anonymous) @ react-dom.min.js?ver=16.13.1:61
unstable_runWithPriority @ react.min.js?ver=16.13.1:25
Da @ react-dom.min.js?ver=16.13.1:60
Pg @ react-dom.min.js?ver=16.13.1:61
ha @ react-dom.min.js?ver=16.13.1:60
Ja @ react-dom.min.js?ver=16.13.1:224
ch @ react-dom.min.js?ver=16.13.1:93
e @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
(anonymous) @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
(anonymous) @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
o @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
(anonymous) @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
p @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
(anonymous) @ redux-routine.min.js?ver=8ec41c688c5daad1d264d85374a1c8b0:2
(anonymous) @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
(anonymous) @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
(anonymous) @ block-editor.min.js?ver=5f6a75cdc59f1a900e9d4bcfb43bddba:12
(anonymous) @ block-editor.min.js?ver=5f6a75cdc59f1a900e9d4bcfb43bddba:7
(anonymous) @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
d @ block-editor.min.js?ver=5f6a75cdc59f1a900e9d4bcfb43bddba:12
react-dom.min.js?ver=16.13.1:125 Error: An error occurred while running 'mapSelect': Cannot read property 'replace' of undefined
The error may be correlated with this previous error:
TypeError: Cannot read property 'replace' of undefined
    at Module.f (https://podcastindustryinsights.local/wp-includes/js/dist/escape-html.min.js?ver=5241b8bf5a5db2d44897e649c1e253ef:2:1685)
    at save (https://podcastindustryinsights.local/wp-content/plugins/enlighter/resources/gutenberg/enlighterjs.gutenberg.min.js?ver=4.4.1:2:5723)
    at Qt (https://podcastindustryinsights.local/wp-includes/js/dist/blocks.min.js?ver=65abb57f00d1d2ab3d3b16331cbbf560:3:114343)
    at Xt (https://podcastindustryinsights.local/wp-includes/js/dist/blocks.min.js?ver=65abb57f00d1d2ab3d3b16331cbbf560:3:114820)
    at https://podcastindustryinsights.local/wp-includes/js/dist/block-editor.min.js?ver=5f6a75cdc59f1a900e9d4bcfb43bddba:12:64853
    at https://podcastindustryinsights.local/wp-includes/js/dist/hooks.min.js?ver=54e7683a4c0aafac0448bb95dc8d53ba:2:5031
    at qr (https://podcastindustryinsights.local/wp-includes/js/dist/blocks.min.js?ver=65abb57f00d1d2ab3d3b16331cbbf560:3:125237)
    at Gr (https://podcastindustryinsights.local/wp-includes/js/dist/blocks.min.js?ver=65abb57f00d1d2ab3d3b16331cbbf560:3:126288)
    at https://podcastindustryinsights.local/wp-includes/js/dist/blocks.min.js?ver=65abb57f00d1d2ab3d3b16331cbbf560:3:127885
    at Array.reduce (<anonymous>)

Original stack trace:
    at We (https://podcastindustryinsights.local/wp-includes/js/dist/data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2:29695)
    at https://podcastindustryinsights.local/wp-includes/js/dist/data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2:30251
    at we (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:84:293)
    at He (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:97:464)
    at zj (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:228:406)
    at Th (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:152:223)
    at tj (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:152:152)
    at Te (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:146:151)
    at https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react-dom.min.js?ver=16.13.1:61:68
    at unstable_runWithPriority (https://podcastindustryinsights.local/wp-includes/js/dist/vendor/react.min.js?ver=16.13.1:25:260)
Me @ react-dom.min.js?ver=16.13.1:125
Jh.f.componentDidCatch.c.callback @ react-dom.min.js?ver=16.13.1:139
Wg @ react-dom.min.js?ver=16.13.1:67
oj @ react-dom.min.js?ver=16.13.1:127
Aj @ react-dom.min.js?ver=16.13.1:160
unstable_runWithPriority @ react.min.js?ver=16.13.1:25
Da @ react-dom.min.js?ver=16.13.1:60
ab @ react-dom.min.js?ver=16.13.1:154
Te @ react-dom.min.js?ver=16.13.1:146
(anonymous) @ react-dom.min.js?ver=16.13.1:61
unstable_runWithPriority @ react.min.js?ver=16.13.1:25
Da @ react-dom.min.js?ver=16.13.1:60
Pg @ react-dom.min.js?ver=16.13.1:61
ha @ react-dom.min.js?ver=16.13.1:60
Ja @ react-dom.min.js?ver=16.13.1:224
ch @ react-dom.min.js?ver=16.13.1:93
e @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
(anonymous) @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
(anonymous) @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
o @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
(anonymous) @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
p @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
(anonymous) @ redux-routine.min.js?ver=8ec41c688c5daad1d264d85374a1c8b0:2
(anonymous) @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
(anonymous) @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
(anonymous) @ block-editor.min.js?ver=5f6a75cdc59f1a900e9d4bcfb43bddba:12
(anonymous) @ block-editor.min.js?ver=5f6a75cdc59f1a900e9d4bcfb43bddba:7
(anonymous) @ data.min.js?ver=777f925bfe1a2aea2a86b7b9ae6aed25:2
d @ block-editor.min.js?ver=5f6a75cdc59f1a900e9d4bcfb43bddba:12
theDanielJLewis commented 3 years ago

Repeatable in Chrome, Brave, and Firefox.

When creating a new page, it doesn't crash until I move my mouse after typing in the page contents.

I tried deleting the enlighter-options row and that didn't make a difference.

AndiDittrich commented 3 years ago

Hi Daniel.

it seems to be a duplicate of https://github.com/EnlighterJS/Plugin.Gutenberg/issues/30 - which is caused by empty codeblocks.

would you like to try a hotfix for the Gutenberg plugin ? just replace the files in wp-content/plugins/enlighter/resources/gutenberg and clear the browser cache/disable caching. As a side effect, previously created empty blocks become invalid - this doesn't affect existing blocks with code

technical background: the build-in escape function of gutenberg doesn't handle null values which are returned by empty blocks..

enlighter-gutenberg-v1.1.1.zip

theDanielJLewis commented 3 years ago

I think I got it worked before I read your message. I did two things that fixed the console errors, and only one was directly connected to Enlighter.

  1. When the editor crashed, I copied the contents and simply pasted them into the database entry for that post's contents. That seems to have fixed Enlighter.
  2. I think the other problem above (or at least that I was then seeing in the console) was because I had a reusable block that contained a "template" I had made with a different code-highlighter plugin that I had since removed.

So I think everything is working again now, but I'll know better as I work with it more. If I still have problems, I'll try your hotfix unless it's merged into a plugin update.

Thanks!