Forum

Thread tagged as: Problem, Blog

perch_blog_sections() Inconsistent behavior

I'm trying to work with perch_blog_sections(). Using:

$sectionsArray = perch_blog_sections(array(
                          'skip-template' => true,
                  ));
var_dump($sectionsArray);

On first load I get an array like this:

array(2) {
    [0]=> array(7) {
        ["sectionID"]=> string(2) "10"
        ["sectionTitle"]=> string(5) "Bikes"
        ["sectionSlug"]=> string(5) "bikes"
        ["sectionPostCount"]=> string(1) "1"
        ["sectionDynamicFields"]=> string(2) "[]"
        ["_id"]=> string(2) "10"
        ["qty"]=> string(1) "1"
    }
    [1]=> array(7) {
        ["sectionID"]=> string(2) "11"
        ["sectionTitle"]=> string(4) "Life"
        ["sectionSlug"]=> string(4) "life"
        ["sectionPostCount"]=> string(1) "3"
        ["sectionDynamicFields"]=> string(2) "[]"
        ["_id"]=> string(2) "11"
        ["qty"]=> string(1) "3"
    }
}

^ This makes sense and is something I'm trying to work with. However, when I refresh the page or otherwise revisit the page I get this output:

string(10) "ArrayArray"

Which is not useful. If I shut down my local server and reopen the page I get the first array again. Then upon revisiting I just get a string again.

ANy thoughts on what is going on? Thanks!

Nicholas Nelson

Nicholas Nelson 0 points

  • 7 years ago

Just looked into the perch_blog_categories() function and it seems to behave in the same manner.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Could be a bug with the caching. Does it happen if your site is in development mode?

Sorry for my ignorance, what do you mean by development mode?

Drew McLellan

Drew McLellan 2638 points
Perch Support

In your config.php file, set

define('PERCH_PRODUCTION_MODE', PERCH_DEVELOPMENT);

https://docs.grabaperch.com/docs/installing-perch/configuration/perch/

Interesting. I dropped that into the config file, and it seems to work now. What does this mean? Is there a course of action I should take? Does setting this disable caching?

Drew McLellan

Drew McLellan 2638 points
Perch Support

That setting disabled caching. It sounds like a caching bug, and I'll look into it.

Hey there, just thought I'd put it out there that I updated to perch 2.6 and this issue hasn't changed. Perhaps it is a blog update issue??

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, the code is in Blog. We're working on an update for that.