Forum

Thread tagged as: Problem, Error, Addons

PHP Fatal Error with multiple categories on single admin page

(EDIT: It's probably worth checking the next reply first, Drew, before diving too far into this. I was able to fix the error, although I'm not sure what I did to cause it.)

I'm getting a PHP "white screen of death" in the Perch admin on regions that utilize more than one perch:categories set. I can see the interface for all sets just fine, but when I click "Save" I get the blank screen.

So, with a single set, I can save the page as expected, using this code:

<perch:categories id="attributes" label="Attributes" set="attributes">
    <perch:before><p class="label">Song Attributes</p><ul class="listing clearfix"></perch:before>
        <li class="link<perch:if exists="perch_item_first"> alpha</perch:if>"><a href="/filter.html?cat=<perch:category id="catPath" />"><perch:category id="catTitle" /></a></li>
    <perch:after></ul></perch:after>
</perch:categories>

But when saving the page with multiples sets, I get the white screen, such as when using this code:

<perch:categories id="attributes" label="Attributes" set="attributes">
    <perch:before><p class="label">Song Attributes</p><ul class="listing clearfix"></perch:before>
        <li class="link<perch:if exists="perch_item_first"> alpha</perch:if>"><a href="/filter.html?cat=<perch:category id="catPath" />"><perch:category id="catTitle" /></a></li>
    <perch:after></ul></perch:after>
</perch:categories>

<perch:categories id="genres" label="Genres" set="genres">
    <perch:before><p class="label">Song Genres</p><ul class="listing clearfix"></perch:before>
        <li class="link<perch:if exists="perch_item_first"> alpha</perch:if>"><a href="/filter.html?cat=<perch:category id="catPath" />"><perch:category id="catTitle" /></a></li>
    <perch:after></ul></perch:after>
</perch:categories>

The resulting error in the PHP log is as follows (there is an entry for each attempt to "save" the page):

[25-Aug-2014 01:52:08 UTC] PHP Fatal error:  Call to a member function catPath() on a non-object in /path/to/site/admin/core/lib/PerchFieldTypes.class.php on line 1949

The line of code referenced is:

$out[] = array('key'=>'_category', 'value'=>$Cat->catPath());

Working mainly in Chrome 36.0.1985.143, but get the same results using Safari. I've tried removing all other markup in the template except the two perch:categories calls, but the page still whites-out upon saving.

Other observations:

  • Upon manually reloading the white-screen page, the data is intact (that is, the choices made both category sets are remembered)
  • Restarting the server did not help
  • Restarting/clearing the browser(s) did not help
  • Using the default set.html and category.html templates

And the diagnostics:

SUMMARY INFORMATION

Perch: 2.6, PHP: 5.4.4, MySQL: 5.5.25, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (2.6), assets (2.6), categories (2.6)
App runtimes: <?php $apps_list = array( 'content', 'categories', );
PERCH_LOGINPATH: /admin
PERCH_PATH: /path/to/site/library.naturalgrowth.ca/admin
PERCH_CORE: /path/to/site/library.naturalgrowth.ca/admin/core
PERCH_RESFILEPATH: /path/to/site/library.naturalgrowth.ca/admin/resources
Image manipulation: GD
PHP limits: Max upload 128M, Max POST 128M, Memory: 512M, Total max file upload: 128M
Resource folder writeable: Yes
HTTP_HOST: library.naturalgrowth.ca
DOCUMENT_ROOT: /path/to/site/library.naturalgrowth.ca
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php

Let me know if I can supply anything else.

Richard Terrick

Richard Terrick 3 points

  • 7 years ago

Ok, it seems like it's an issue specifically with this block:

<perch:categories id="genres" label="Genres" set="genres">
    <perch:before><p class="label">Song Genres</p><ul class="listing clearfix"></perch:before>
        <li class="link<perch:if exists="perch_item_first"> alpha</perch:if>"><a href="/filter.html?cat=<perch:category id="catPath" />"><perch:category id="catTitle" /></a></li>
    <perch:after></ul></perch:after>
</perch:categories>

Even by itself, as the only item in the entire template, it's causing the white-screen on save.

I can fix the issue in one of two ways:

  1. Changing the ID of "genres" to anything else (ex: id="foo")
  2. Changing the category set itself (in admin) to something else (ex: "Genre", singular) and using id="genre" and set="genre"

I had assumed that id="foo" and set="foo" had to match, based on the documentation (which perhaps uses the same values out of coincidence), so I suppose that's the wrong assumption. I think I will go ahead and use namespaced values for all the IDs using the perch:categories code and see if I run into the issue again.

So, I guess that's fixed, since I can now save the page without the white screen, but I have no idea what I did to break it in the first place. I'm not using "genres" as an ID anywhere else in the site. Is "genres" some sort of reserved word? Am I being cursed for working on a Sunday? Hm. I need a drink.

Drew McLellan

Drew McLellan 2638 points
Perch Support

The tag ID and set ID do not need to be the same, but often they will be, naturally. There's nothing reserved about genres.

I'm not sure what's happening there, but I've added checks to prevent the error killing everything.

Just bizarre. I'm sure at one point it was working with the id="genres" and set="genres" category set, which is why I was led to (falsely) assume it was an issue with the multiple category sets on a single page.

The only other thing that comes to mind: I had an "abrupt" power-down while working on that project (I didn't notice my fan stopped spinning and the CPU heated to the point of tripping the safety). It's conceivable that I was actually saving a record to the database when the shut-down occurred, so maybe something went wonky there? The timeline of the shutdown sort of makes sense, in any case.

Anyway, no further problems with categories to report, so I'm chalking this one up to an act of God.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Update to 2.6.2 as well, see if that helps.

The 2.6.2 update did help.

As a test I reverted the offending set to be named "Genres" and confirmed that using id="genres" and set="genres" no longer produces the blank white screen, as it did before the update.

Thanks again, Drew.