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

Advanced-gutenberg-blocks requiring WooCommerce working randomly #6

Closed
bobbingwide opened this issue Jul 3, 2019 · 7 comments
Closed
Assignees
Labels
help wanted Extra attention is needed

Comments

@bobbingwide
Copy link
Owner

bobbingwide commented Jul 3, 2019

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.

@bobbingwide bobbingwide added the help wanted Extra attention is needed label Jul 3, 2019
@bobbingwide bobbingwide self-assigned this Jul 3, 2019
@bobbingwide
Copy link
Owner Author

bobbingwide commented Jul 5, 2019

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.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Jul 5, 2019

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 bobbingwide/oik-blocks#27

@bobbingwide
Copy link
Owner Author

There's a similar problem to #6 (comment) 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)

Workaround

Edit the block using the code editor and manually replace the invalid ID with the correct one.
Was 1417, should be 2184.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Nov 22, 2021

I found another problem with WPDM - Gutenberg blocks which is dependent upon WPDM ( WordPress Download Manager ).
Analysis of the problem uncovered 2 things

  1. It appears that WPDM - Gutenberg blocks is checking on a constant which is not being defined
  2. Once that's resolved the dependent plugin is being loaded after WPDM Gutenberg Blocks, so the constant is still not defined when the plugin is loaded.

Solutions

  • Fix WPDM Gutenberg blocks
  • Change the logic so that the dependent plugins are loaded first

@bobbingwide
Copy link
Owner Author

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.

@bobbingwide
Copy link
Owner Author

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.

bobbingwide added a commit that referenced this issue Jan 20, 2022
@bobbingwide
Copy link
Owner Author

New version of oik-loader v1.2.0 now installed in wp-a2z.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant