soberwp/controller

@code outputs invalid variable reference for cloned repeater

runofthemill opened this issue · 4 comments

Given the following ACF structure:

screen shot 2018-08-28 at 9 56 54 am
screen shot 2018-08-28 at 9 58 22 am

@code produces the following output:

  @if ($annual_report->docs)
  @foreach ($annual_report->docs as $item)
    @if ($item->doc->ID)
      {{ $item->doc->ID }}
    @endif
    @if ($doc->id)
      {{ $doc->id }}
    @endif
    @if ($doc->title)
      {{ $doc->title }}
    @endif
    @if ($doc->filename)
      {{ $doc->filename }}
    @endif
    @if ($doc->filesize)
      {{ $doc->filesize }}
    @endif
    @if ($doc->url)
      {{ $doc->url }}
    @endif
    @if ($doc->link)
      {{ $doc->link }}
    @endif
    @if ($doc->alt)
      {{ $doc->alt }}
    @endif
    @if ($doc->author)
      {{ $doc->author }}
    @endif
    @if ($doc->description)
      {{ $doc->description }}
    @endif
    @if ($doc->caption)
      {{ $doc->caption }}
    @endif
    @if ($doc->name)
      {{ $doc->name }}
    @endif
    @if ($doc->status)
      {{ $doc->status }}
    @endif
    @if ($doc->uploaded_to)
      {{ $doc->uploaded_to }}
    @endif
    @if ($doc->date)
      {{ $doc->date }}
    @endif
    @if ($doc->modified)
      {{ $doc->modified }}
    @endif
    @if ($doc->menu_order)
      {{ $doc->menu_order }}
    @endif
    @if ($doc->mime_type)
      {{ $doc->mime_type }}
    @endif
    @if ($doc->type)
      {{ $doc->type }}
    @endif
    @if ($doc->subtype)
      {{ $doc->subtype }}
    @endif
    @if ($doc->icon)
      {{ $doc->icon }}
    @endif
    @if ($item->year)
      {{ $item->year }}
    @endif
  @endforeach
@endif

The first if statement correctly references the cloned field ($item->doc->ID) but all subsequent ones don't.

@runofthemill thanks, I'll take a look at this. @code is def still pretty experimental so let me know if you pick up anything else.

will do!

I wonder how often users are using @code and if it's worth maintaining vs dropping in favour of @debug. I myself don't use it much these days. Thoughts?

Hard to say...I haven't been actively working on any Sage 9 projects for the past few months. Maybe add a deprecation notice with a vague timeline, just to let people know it'll be removed "in the future"?