Closed bobbingwide closed 2 years ago
When attempting to debug this problem I came across another. When the ProductID is not valid then we get
Fatal error: Uncaught Error: Call to a member function get_sale_price() on boolean in
C:\apache\htdocs\wordpress\wp-content\plugins\advanced-gutenberg-blocks\public\templates\addtocart.php:9
Perhaps the AddToCart::render_block() in method should return early when the product no longer exists.
Note: This problem was produced by oik-clone not applying mappings of block attributes. The ProductID value of 1417 was OK on blocks.wp-a2z.org but not on blocks.wp.a2z, where it's 2184.
The problem with oik-loader-mu.php appears to occur when the requested permalink ($_REQUEST_URI) is not all lowercase.
e.g. /block/Add-to-cart-button-advanced-gutenberg-blocks-addtocart/
This permalink is created by the blocklist block. See https://github.com/bobbingwide/oik-blocks/issues/27
There's a similar problem to https://github.com/bobbingwide/oik-loader/issues/6#issuecomment-508668812 in the Product block
Fatal error: Uncaught Error: Call to a member function get_short_description() on boolean in
C:\apache\htdocs\wordpress\wp-content\plugins\advanced-gutenberg-blocks\classes\Blocks\Product.php:48
While attempting to edit this post, having retyped the Product search ( my fa.. ) I got a message box The editor has encountered an unexpected error.
Invariant Violation: Objects are not valid as a React child (found: object with keys {code, message, data}). If you meant to render a collection of children, use an array instead.
in p (created by t)
in div (created by t)
in t (created by t)
in div (created by t)
in t (created by ForwardRef(PanelBody))
in ForwardRef(PanelBody) (created by t)
in t (created by Context.Consumer)
in se (created by InspectorControlsSlot)
in InspectorControlsSlot
in div
in Unknown (created by n)
in n (created by Context.Consumer)
in WithSelect(Component)
in div (created by t)
in t (created by ForwardRef(PanelBody))
in ForwardRef(PanelBody)
in div (created by pn)
in pn
in div (created by hn)
in hn (created by n)
in div (created by n)
in n (created by Context.Consumer)
in Unknown (created by b)
in b
in t (created by Context.Consumer)
in se (created by SidebarSlot)
in SidebarSlot
in div (created by t)
in t
in Unknown (created by n)
in n (created by Context.Consumer)
in WithViewportMatch(Component) (created by NavigateRegions(WithViewportMatch(Component)))
in div (created by NavigateRegions(WithViewportMatch(Component)))
in NavigateRegions(WithViewportMatch(Component)) (created by r)
in r (created by Context.Consumer)
in WithDispatch(NavigateRegions(WithViewportMatch(Component))) (created by n)
in n (created by Context.Consumer)
in WithSelect(WithDispatch(NavigateRegions(WithViewportMatch(Component)))) (created by t)
in t (created by t)
in div (created by t)
in t (created by t)
in t (created by t)
in t (created by r)
in r (created by Context.Consumer)
in WithDispatch(t)
in Unknown (created by Context.Consumer)
in WithRegistryProvider(WithDispatch(t)) (created by t)
in t (created by r)
in r (created by Context.Consumer)
in WithDispatch(t) (created by n)
in n (created by Context.Consumer)
in WithSelect(WithDispatch(t)) (created by t)
in StrictMode (created by t)
in t (created by n)
in n (created by Context.Consumer)
in WithSelect(t)
at invariant (https://blocks.wp.a2z/wp-content/plugins/gutenberg/vendor/react-dom.165d5c53.js:49:15)
at throwOnInvalidObjectType (https://blocks.wp.a2z/wp-content/plugins/gutenberg/vendor/react-dom.165d5c53.js:11922:5)
at reconcileChildFibers (https://blocks.wp.a2z/wp-content/plugins/gutenberg/vendor/react-dom.165d5c53.js:12696:7)
at reconcileChildren (https://blocks.wp.a2z/wp-content/plugins/gutenberg/vendor/react-dom.165d5c53.js:14499:28)
at updateHostComponent (https://blocks.wp.a2z/wp-content/plugins/gutenberg/vendor/react-dom.165d5c53.js:14952:3)
at beginWork (https://blocks.wp.a2z/wp-content/plugins/gutenberg/vendor/react-dom.165d5c53.js:15738:14)
at performUnitOfWork (https://blocks.wp.a2z/wp-content/plugins/gutenberg/vendor/react-dom.165d5c53.js:19401:12)
at workLoop (https://blocks.wp.a2z/wp-content/plugins/gutenberg/vendor/react-dom.165d5c53.js:19441:24)
at renderRoot (https://blocks.wp.a2z/wp-content/plugins/gutenberg/vendor/react-dom.165d5c53.js:19524:7)
at performWorkOnRoot (https://blocks.wp.a2z/wp-content/plugins/gutenberg/vendor/react-dom.165d5c53.js:20431:7)
Edit the block using the code editor and manually replace the invalid ID with the correct one. Was 1417, should be 2184.
I found another problem with WPDM - Gutenberg blocks which is dependent upon WPDM ( WordPress Download Manager ). Analysis of the problem uncovered 2 things
Perhaps the AddToCart::render_block() in method should return early when the product no longer exists.
I made a local change in render_block()
if ( !$product ) {
return "Product does not exist";
}
and then corrected the productID
attribute.
The dependency logic appears to work for these blocks now.
I was going to raise a couple of issues against the plugin but discovered that it's no longer in the WordPress repository. I'll be closing this issue when I've released a new version of oik-loader.
New version of oik-loader v1.2.0 now installed in wp-a2z.org
Two blocks from the advanced-gutenberg-blocks plugin - add-to-cart and product - are dependent upon WooCommerce. When this is normally activated then they work in the editor but not the front end. When WooCommerce is activated by oik-loader-mu then the blocks appear to work randomly. Working in the editor but not on the front end.
Needs investigating. It looks like an issue with which plugin is being loaded first.