Log1x / acf-composer

Compose ACF Fields, Blocks, Widgets, and Option Pages with ACF Builder on Sage 10.
https://github.com/Log1x/acf-composer
MIT License
417 stars 57 forks source link

ACF Block Stuck Loading (Internal Server Error in admin-ajax.php) #235

Closed Tartamata closed 6 months ago

Tartamata commented 6 months ago

Hello @Log1x , I'm writing to report an issue I'm experiencing with ACF-Composer. When I create a custom ACF block and try to add it to the editor, the block gets stuck loading with a spinning icon.

In the browser's developer console, I see an error message like this:

POST https://website.local/wp-admin/admin-ajax.php 500 (Internal Server Error)
load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-hooks&ver=6.4.3:2 

Do you have any suggestions on how to troubleshoot or fix this error ?

Thank you.

WordPress Version: 6.4.3 ACF Version: 6.2.5

Log1x commented 6 months ago

Are there any logs from Acorn? They can typically be found in wp-content/uploads/cache/framework/logs or in your theme's storage directory if you dumped it with Acorn's CLI.

Tartamata commented 6 months ago

Thank you @Log1x for your reply,

I've identified the potential cause of the issue! It seems the problem only occurs when I edit the block name from "Abc Block" to "ABC Block".

Works:

class AbcBlock extends Block
{
    /**
     * The block name.
     *
     * @var string
     */
    public $name = 'Abc Block'; 
...

Doesn't work:

class AbcBlock extends Block
{
    /**
     * The block name.
     *
     * @var string
     */
    public $name = 'ABC Block'; 
...
Log1x commented 6 months ago

Gotcha, it looks like it is due to the slug becoming a-b-c-block making it fail to find a-b-c-block.blade.php.

A way to fix this would be to set the slug yourself:

/**
 * The block slug.
 *
 * @var string
 */
public $slug = 'abc-block';
Log1x commented 6 months ago

I'm going to close this but will think on it in the future. I have to tread carefully since I do not want to do anything that could potentially change/break existing slugs.