Forum

Thread tagged as: Problem, Addons, Blog

Cannot delete last item from repeater

I have a problem where I cannot delete the last repeater item in a blog post.

I believe it is the same issue that others have reported in the forum.

Some additional context:

  • I added a repeater to an existing blog
  • I used with the repeater in at least one blog post but most did not
  • I have since updated the template but to my knowledge the id for the repeater didn't change
  • New blog posts created after I updated the template behave as expected
  • Posts that were already present always seem to have three items. Against each item I see:
Warning: Invalid argument supplied for foreach() in /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/apps/content/PerchContent_Util.class.php on line 509
  • If I delete any item this message disappears
  • I can delete two repeater items but the last one persists

In my local development environment I have debug turned on and see what looks like to be the same error message:

Array
(
    [type] => 2
    [message] => Invalid argument supplied for foreach()
    [file] => /Applications/MAMP/htdocs/personal/portfolio/perch/core/apps/content/PerchContent_Util.class.php
    [line] => 509
)A

Diagnostic information

Perch: 3.0.14, PHP: 7.1.5, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.0.14), assets (3.0.14), categories (3.0.14), perch_blog (5.6.1), perch_forms (1.9.1), perch_kraken (1.1)
App runtimes: <?php $apps_list = array( 'perch_blog', 'perch_forms', ); ?>
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/sites/a/alexanderblackman.co.uk/public_html/perch
PERCH_CORE: /var/sites/a/alexanderblackman.co.uk/public_html/perch/core
PERCH_RESFILEPATH: /var/sites/a/alexanderblackman.co.uk/public_html/assets
Image manipulation: GD
PHP limits: Max upload 100M, Max POST 100M, Memory: 128M, Total max file upload: 100M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
DOCUMENT_ROOT: /var/sites/a/alexanderblackman.co.uk/public_html
HTTP_HOST: alexanderblackman.co.uk
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php

post.html

<header class="container  pt-7">
    <div class="row">
        <div class="col-13  offset-1  col-sm-11  offset-sm-4  col-lg-10  offset-lg-5">
            <nav role="navigation" aria-label="breadcrumb">
                <ol class="breadcrumb  small">
                    <li class="breadcrumb-item"><a href="/">Home</a></li>
                    <li class="breadcrumb-item"><a href="/articles">Writing</a></li>
                    <li class="breadcrumb-item  active" aria-current="page"><perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" /></li>
                </ol>
            </nav>
        </div>
    </div>
</header>

<article class="container  pb-7  c-post" role="main">
    <div class="row">
        <div class="col-13  offset-1  col-sm-11  offset-sm-4  col-lg-4  offset-lg-0  text-lg-right">
            <h1 class="h1"><perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" /></h1>
            <p class="font-italic  font-weight-light  text-middle">
                <time datetime="<perch:blog id="postDateTime" type="date" label="Publish Date" native="true" divider-before="Publishing" />">
                    <perch:blog id="postDateTime" type="date" label="Publish Date" native="true" divider-before="Publishing" format="%e %B %Y" /> 
                </time>
            </p>
        </div>
        <div class="col-13  offset-1  col-sm-11  offset-sm-4  col-lg-10  offset-lg-1  mb-7" style="margin-top: 0.25em;">
            <div class="c-post">
                <perch:blog id="postDescHTML" type="textarea" label="Post" order="2" editor="simplemde" markdown="true" size="xxl autowidth" required="true" html="true" />
            </div>
            <perch:if exists="authorGivenName">
                <div class="text-right  mt-3  mb-7">
                    —&thinsp;<perch:blog id="authorGivenName" type="hidden" /> <perch:blog id="authorFamilyName" type="hidden" />
                </div>
            </perch:if>
            <perch:if exists="footnotes">
                <aside class="pt-7  mb-7  small" id="footnotes">
                    <h2 class="sr-only">By the way</h2>
                    <perch:repeater id="footnotes" label="By the way" order="3">
                        <perch:before><ol></perch:before>
                        <li id="footnote:<perch:blog id="perch_item_index" type="hidden" />" aria-label="footnote <perch:blog id="perch_item_index" type="hidden" />">
                            <perch:blog id="footnote-text" type="textarea" label="Note" markdown="true" html="true" size="m autowidth" /> <a href="#footnote-ref-<perch:blog id="perch_item_index" type="hidden" />" class="footnote-ref" aria-label="Back to content">↩</a>
                        </li>
                        <perch:after></ol></perch:after>
                    </perch:repeater>
                </aside>
            </perch:if>
        </div>
    </div>
</article>
Alex Blackman

Alex Blackman 0 points

  • 2 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you tried with the current version of the software?

Oh, sorry I thought I was... I can see there is version 3.1.2 so I'll update and check.

Doesn't Perch prompt to update?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, if you go to Settings and Diagnostics it will tell you if an update is available.

Updated but unfortunately I get the same behaviour as before.

Diagnostics

Perch: 3.1.2, PHP: 7.1.5, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.1.2), assets (3.1.2), categories (3.1.2), perch_blog (5.6.1), perch_forms (1.9.1), perch_kraken (1.1)
App runtimes: <?php $apps_list = array( 'perch_blog', 'perch_forms', ); ?>
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/sites/a/alexanderblackman.co.uk/public_html/perch
PERCH_CORE: /var/sites/a/alexanderblackman.co.uk/public_html/perch/core
PERCH_RESFILEPATH: /var/sites/a/alexanderblackman.co.uk/public_html/assets
Image manipulation: GD
PHP limits: Max upload 100M, Max POST 100M, Memory: 128M, Total max file upload: 100M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
DOCUMENT_ROOT: /var/sites/a/alexanderblackman.co.uk/public_html
HTTP_HOST: alexanderblackman.co.uk
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php

Not sure if this will help, but when I delete all items from a repeater in one go and click Save I get a load of warnings:

Warning: Invalid argument supplied for foreach() in /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/lib/PerchRepeater.class.php on line 55

Warning: Cannot modify header information - headers already sent by (output started at /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/lib/PerchRepeater.class.php:55) in /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/lib/PerchUtil.class.php on line 1405

Warning: Cannot modify header information - headers already sent by (output started at /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/lib/PerchRepeater.class.php:55) in /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/lib/PerchUtil.class.php on line 1406

Warning: Cannot modify header information - headers already sent by (output started at /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/lib/PerchRepeater.class.php:55) in /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/lib/PerchUtil.class.php on line 1407

Warning: Cannot modify header information - headers already sent by (output started at /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/lib/PerchRepeater.class.php:55) in /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/lib/PerchUtil.class.php on line 1410

Warning: Cannot modify header information - headers already sent by (output started at /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/lib/PerchRepeater.class.php:55) in /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/lib/PerchUtil.class.php on line 1413

Warning: Cannot modify header information - headers already sent by (output started at /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/lib/PerchRepeater.class.php:55) in /var/sites/a/alexanderblackman.co.uk/public_html/perch/core/inc/top.php on line 17
Drew McLellan

Drew McLellan 2638 points
Perch Support

We'll take a look into it - thanks.