Lots of errors with Express Objects

Permalink
Hi,
I'm having hard time with express objects, I hope someone can help me out. I'm using Concrete version 8.5.2.

When I try to do anything little more complex with express objects or entities, it gives me this same fatal error:
Allowed memory size of 268435456 bytes exhausted (tried to allocate 199233536 bytes)
and it's pointing to
return htmlspecialchars(print_r($value, true));
in /concrete/vendor/filp/whoops/src/Whoops/Util/TemplateHelper.php

I'm frustrated because I don't know how I'm supposed to track that error, since it always points to that same line of code.

First I tried to add some filter and search options for Express object listing. Something bad happened, and it throwed that error. Now I can't access that object at all, and can't even delete it.

I tried to create new object, not touching the filter options anymore. It worked, and I have added 6 entries for it. Then I went to edit one entry's date field, and here we have the same error again.

So question is, how can I track what are these errors about, and maybe fix them?

1 Attachment

mandako
 
mnakalay replied on at Permalink Reply
mnakalay
Hello,

There could be several reasons for this to happen. I had this problem at some point because I had a search filter in place and then I modified the attribute and the search filter started throwing havoc.

That might be your case too or something similar.

What I did that worked for me was to edit this file concrete\src\Search\AbstractSearchProvider.php. Around line 46 you have this function:
public function getSessionCurrentQuery()
{
    $variable = 'search/' . $this->getSessionNamespace() . '/query';
    if ($this->session->has($variable)) {
        return $this->session->get($variable);
    }
}

Comment out the return line (line 50) like so
public function getSessionCurrentQuery()
{
    $variable = 'search/' . $this->getSessionNamespace() . '/query';
    if ($this->session->has($variable)) {
        // return $this->session->get($variable);
    }
}

Then go back to your result page and reload. then try to edit something.

Don't forget to put your file back the way it was when you're done.

If this doesn't work than it's a different problem but most likely linked to something in the Express object that was modified after it was used and fitered a few times.
dmeller replied on at Permalink Reply
I had the same issue. I was never able to use print_r on an express object without this error. I think it is just trying to fetch too much information within the object and hits a memory limit.

I had to basically work with the object(s) without print_r inspecting them.
mandako replied on at Permalink Reply
mandako
Thank you for answers.

I don't know what happened, but now when I went to express object there was no errors anymore and I was able to delete it. I cleared the cache before and that didn't help, so I'm not sure what did the trick now. Maybe I should've cleared my browser cache too.

I will try to set search and filter options again, and will try the fix mnakalay suggested if this error comes again. Thanks!
mandako replied on at Permalink Reply
mandako
If anyone else is struggling with these Express Object errors, try to empty your browsers cache.

I had the same errors again, when changing entity's date or topic attributes. I tried to empty site cache and even tried refresh entities here /index.php/dashboard/system/environment/entities/view (btw, this helped to another error I had with Express objects)
These did not help with "Allowed memory size..." error. Then I cleared my browsers (Chrome) cache and after that I had no errors.

I haven't tried other browsers, I'm wondering if this is only Chrome's problem.
tdausner replied on at Permalink Reply
tdausner
Hi mandako,

IMHO Express isn't the malicious one. I've noticed print_r causes this error when it tries to render deeply nested objects. That's why i use an own function instead of print_r:
function prar($m, $recurse = 9999, $in = '')
{
    if ($in == '') echo '<pre>';
    if (is_array($m)) $type = 'array';
    if (is_object($m)) $type = 'object';
    if ($type)
    {
        echo $type . "\n";
        if ($recurse-- >= 0)
        {
            echo $in . "(\n";
            foreach ($m as $k => $v)
            {
                echo $in . '    [' . $k . '] => ';
                prar($v, $recurse, $in . '    ');

instead of
print_r($someObject);

try
prar($someObject, 10);

to achieve output of your object until nest level 10.
terano replied on at Permalink Reply 2 Attachments
terano
I encountered the same error.

I followed the recommendations mentionned above
mnakalay (commenting line) and mandako (clearing caches)
but it didn't help, until I logged out and back in. Then it worked.

I can reproduce and repair the problem as following:

- create an object
- add an attribute, but make it not searchable, also not for advanced search.
- create a form / fieldset and add the attribute
- go to Express / View entries
- click the object
- click Advanced (search)
- Filters -> Add Field and add your created attributed under Other Attributes
- click Search, and you'll receive an exception error (see screenshot)
- cancel the error and Filter dialog
- go back to (Dashboard) Express / View Entries
- click again on your created object and you'll get the MemorySize error exception.

how to repair this?

- go back with your browser and when you're back in the Dashboard:
- go to (Dashboard) System&Settings / Express / Data objects
- click the concerning object
- go to Attributes and click on the created Attribute
- tick Field available in advanced search for all Attributes in your object (and Save)
-- now first Log out of C5
- only when you're back logged in to to (Dashboard) Express / View Entries
- click your object: now it will show without crashing
- even advanced search with your attribute as search filter works now