ACF Builder - Problem with WP_CLI with specific fields structure

Hello :wink:
I have some problem and probably temporary solution. Its not problem with Sage 10 or Sage 9, it’s a problem with ACF Builder.

I find some problem with specific ACF Fields structure.
I use ACF Flex Builder and when i created structure like this:

<?php

namespace App\Fields;

use App\Fields\Partials\PageBuilder;
use Log1x\AcfComposer\Field;
use StoutLogic\AcfBuilder\FieldsBuilder;

class CarrersPage extends Field
{
    /**
     * The field group.
     *
     * @return array
     */
    public function fields()
    {
        $carrerspage = new FieldsBuilder('carrerspage', ['title' => 'Oferty pracy']);

        $carrerspage
            ->setLocation('page_template', '==', 'template-carrer.blade.php')
            ->setGroupConfig('hide_on_screen', [ 'the_content', 'block_editor' ]);

        $carrerspage
            ->addTab('content', ['label' => 'Zawartość strony'])
            ->addTab('builder-tab', ['label' => 'Struktura strony'])
                ->addFields($this->get(PageBuilder::class))
        ;

        return $carrerspage->build();
    }
}
<?php

namespace App\Fields\Partials;

use Log1x\AcfComposer\Partial;
use StoutLogic\AcfBuilder\FieldsBuilder;

class PageBuilder extends Partial {
  /**
   * The partial field group.
   *
   * @return \StoutLogic\AcfBuilder\FieldsBuilder
   */
  public function fields() {
    $pageBuilder = new FieldsBuilder( 'page_builder' );

    $pageBuilder
      ->addFlexibleContent( 'builder', [ 'label' => 'Sekcje strony', 'button_label' => 'Dodaj sekcje' ] )
      ->addLayout( $this->get( IconList::class ) )
      ->endFlexibleContent();

    return $pageBuilder;
  }
}
<?php

namespace App\Fields\Partials;

use Log1x\AcfComposer\Partial;
use StoutLogic\AcfBuilder\FieldsBuilder;

class IconList extends Partial {
  /**
   * The partial field group.
   *
   * @return \StoutLogic\AcfBuilder\FieldsBuilder
   */
  public function fields() {
    $iconList = new FieldsBuilder( 'icon_list', [ 'label' => 'Lista ikon' ] );

    $iconList
      ->addGroup( 'icon_list', [ 'label' => 'Lista ikon' ] )
          ->addSelect( 'bg-color', [ 'label'         => 'Kolor tła',
                                     'choices'       => [ 'bg-white' => 'Biały', 'bg-light-300' => 'Szary' ],
                                     'default_value' => 'white'
          ] )
          ->addWysiwyg( 'title', [ 'label'        => 'Tytuł',
                                   'required'     => 1,
                                   'media_upload' => 0,
                                   'delay'        => 1,
                                   'tabs'         => 'all',
                                   'wrapper'      => [ 'width' => '50' ]
          ] )
          ->addRepeater( 'list', [ 'label' => 'Lista ikon', 'button_label' => 'Dodaj ikonę', 'layout' => 'row' ] )
              ->addImage( 'icon', [ 'label'         => 'Ikona',
                                    'return_format' => 'id',
                                    'preview_size'  => 'thumbnail',
                                    'library'       => 'all',
                                    'mime_types'    => 'svg'
              ] )
              ->addText( 'text', [ 'label' => 'Tekst' ] )
          ->endRepeater()
      ->endGroup();

    return $iconList;
  }
}

I cant use wp-cli, because i have segmentation error or blank response.
If i remove SELECT FIELD from GROUP in Icon List - wp-cli works fine.

Often i have this problem when i have Select Field in Group, but if group is defined in other class and select is added with ->addFileds() - work’s fine.

I have the same problem when i have php error, like no ‘;’ on end of file.

OS:
MacOs Catalina
Ubuntu 21

PHP
8.0
8.1

I created also issue on github: WP-CLI Error : Segmentation fault · Issue #179 · StoutLogic/acf-builder · GitHub

Any idea? :wink:

What is the text of the actual error you see in WP-CLI?

Only ‘Segmentation fault’ or blank response. No php errors. Fields works in wp admin.

The code looks good to me. My guess would be a stack overflow, likely infinite recursion somewhere.

If you can get a backtrace, it would be useful. Following the backtrace should show you the path to the OS sending a SIGSEGV.

It’ll be either:

  • Heavy call stack recursion / stack blown
  • Incorrectly compiled / linked PHP runtime or extension(s)

In my experience, I’ve only ever encountered this when I’ve got uncontrolled recursion going on. It’s unlikely to be a bug in PHP / extensions.