Issue with Acorn 2.0.1 on Sage 10 vendors not published

Hi
I tried to update to acorn 2.0.1 (was on 2.0.0 before). Acorn is loaded in Bedrock.

when I update, I get this error on one page:

htmlspecialchars(): Argument #1 ($string) must be of type string

It was working fine with v2.0.0, but not anymore.
Here is the line that triggers the error:
<a href="<?php echo e(get_term_link($show)); ?>"
And in the blade template:

 <a href="{{ get_term_link($show) }}"
                                        class="btn btn--white btn--arrow-right w-max">{{ __('Discover all', 'sage') }}</a>

Is there something I’m doing wrong?

Hi there, I’m trying to reproduce this with Acorn v2.0.1 and I’m not able to.

It seems like whatever is populating your $show variable is causing this, but you haven’t provided the details for us to understand the value of that is.

If you can provide more info we can try to take a deeper look.

Hi,
Yes, sure.

Here is the blade template:

@php
global $post;
$shows_on_top = get_field('shows_on_top', 'option');
@endphp

<div id="top-shows">
    @if ($shows_on_top)
        <div id="top-shows-list" class="pl-4 sm:pl-2">
            @foreach ($shows_on_top as $show)
                @php
                    $first_line = get_field('first_line_title', $show);
                    $second_line = get_field('second_line_title', $show);
                @endphp
                <div>
                    <div>
                        <a href="{{ get_term_link($show) }}"><span>{{ __('View all', 'sage') }}</span></a>
                    </div>

                    @php
                        $episodes = new WP_Query([
                            'posts_per_page' => 4,
                            'post_type' => 'videos',
                            'facetwp' => false,
                            'tax_query' => [
                                [
                                    'taxonomy' => 'shows',
                                    'field' => 'slug',
                                    'terms' => $show->slug,
                                ],
                            ],
                        ]);
                    @endphp
                    <div data-snap-slider="{{ $show->slug }}">
                        @posts($episodes)
                        <div id="post-{{ $post->ID }}">
                            @include('partials.common.preview-video')
                        </div>
                        @endposts

                        <div>

                            <div class="uppercase font-bold text-center">Wanna see more</br>
                                {{ $show->name }} episodes?</div>

                            <a href="{{ get_term_link($show) }}">{{ __('Discover all', 'sage') }}</a>

                        </div>
                    </div>

                </div>
            @endforeach
        </div>
    @endif


</div>

show_on_top is an ACF taxonomy field, returning object
Edit: just cleaned the code for clarity

get_term_link() returns a WP_Error if it fails: get_term_link() | Function | WordPress Developer Resources Looks like your $show argument isn’t a valid term.

I just tried to replace it with the ACF doc example:

@php
global $post;
$terms = get_field('shows_on_top', 'option');
if( $terms ): ?>
    <ul>
    <?php foreach( $terms as $term ): ?>
        <li>
            <h2><?php echo esc_html( $term->name ); ?></h2>
            <p><?php echo esc_html( $term->description ); ?></p>
            <a href="<?php echo esc_url( get_term_link( $term ) ); ?>">View all '<?php echo esc_html( $term->name ); ?>' posts</a>
        </li>
    <?php endforeach; ?>
    </ul>
<?php endif; ?>
@endphp

But I still get the issue. So I checked on the option page, and it says that no custom fields can be found for this option page.

It looks like my option page is not displayed with Acorn 2.0.1

Yeah, no more acf fields or option page or block. Weird^^

I’m trying to understand why

How are you registering your ACF fields?

Have you checked your server error logs or sage.log?

I had the same after updating to 2.0.1 and deploying. I’m using acf-composer for adding fields and poet for registering my post types. Both we’re missing

Did you manage to solve it?

I use acf-composer, poet, and most of the blocks were registered using acorn.

All are in sage > app > Blocks / Fields /Options

Yes by rolling back to 2.0.0…
Not the answer you we’re hoping for, sorry

Haha, it’s not. But yes, I did that. Now, let’s hope we understand why it’s doing that

Do you have the postAutoloadDump somewhere in your composer.json like described here?

I do (at Bedrock level)

In the scripts key right?

Yes, it seems so:

    "scripts": {
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "test": [
            "phpcs"
        ],
        "post-autoload-dump": [
            "Roots\\Acorn\\ComposerScripts::postAutoloadDump"
        ]
    }

Yeah I can’t get it working either…
I don’t think the acf-composer or poet vendors get published correctly in Acorn version 2.0.1?
When I try to run this command with Acorn 2.0.1:

wp @staging acorn vendor:publish

I don’t see the providers listed?

  [0] Publish files from all providers and tags listed below
  [1] Provider: Roots\Acorn\Providers\AcornServiceProvider
  [2] Tag: acorn

When I run it with Acorn 2.0.0, they do show up:

  [0] Publish files from all providers and tags listed below
  [1] Provider: Log1x\AcfComposer\Providers\AcfComposerServiceProvider
  [2] Provider: Log1x\Poet\PoetServiceProvider
  [3] Provider: Roots\Acorn\Providers\AcornServiceProvider
  [4] Tag: acorn
  [5] Tag: config

I don’t know what is causing this in the 2.0.1 version, but I also noticed warnings about psr-4 autoloading of some of my files in the theme app folder.

1 Like

Same here but no bedrock environment.
Downgrade Acorn to 2.0.0 helped me to run provider and use acf-composer.