0

This question already has an answer here:

I am getting the error in the image below. It is not always generated by the same file (in this case ".../IOHelper.php").

enter image description here

I can't quite figure out what is causing this, Can anyone provide some insight into what can cause this error specifically (I understand there is a memory issue) and maybe point to where I could be looking as far as a culprit.

My hunch is it could be due to this relational query being done on users (team is what it is called here).

{% set relatedDepartment = craft.entries.section('departments').relatedTo({
     sourceElement: teamEntry,
     field: 'departmentLabel'
}) %}

My understanding is this is set up correctly and should only pull the department information related to that entry in the loop?

the whole block looks like this

{% for teamEntry in craft.entries.section('team').order('title').find() %}

    {% set relatedDepartment = craft.entries.section('departments').relatedTo({
        sourceElement: teamEntry,
        field: 'departmentLabel'
    }) %}

      <div class="photo team-photo col-xs-6 col-sm-4 col-md-3 col-lg-2 team-photo-{% for department in teamEntry.departmentLabel %}{{ department.id }}{% endfor %} all" data-department-id="{% for department in teamEntry.departmentLabel %}{{ department.id }}{% endfor %}" data-border-color="{% for department in relatedDepartment %}{{ department.departmentColor }}{%endfor%}">

        {% set mad = teamEntry.imgMad.first() %}
        {% set disgusted = teamEntry.imgDisgusted.first() %}
        {% set sad = teamEntry.imgSad.first() %}
        {% set neutral = teamEntry.imgNeutral.first() %}
        {% set content = teamEntry.imgContent.first() %}
        {% set happy = teamEntry.imgHappy.first() %}

        {% if neutral | length>0 %}
          <img src="{{ neutral.url }}" class="image mood team-{% for department in teamEntry.departmentLabel %}{{ department.id }}{% endfor %}"/>
        {% else %}
          <img src="/img/nophoto.png" class="team-{% for department in teamEntry.departmentLabel %}{{ department.id }}{% endfor %} image" alt="no photo for {{ teamEntry.title }}"/>
        {% endif %}

        <div class="names">{{ teamEntry.title }}<br><span>{% for department in teamEntry.departmentLabel %}{{ department.title }}{% endfor %}</span></div>

        <div class="hovertext t3modal" href="#modalContent" data-slug-url="/people/detail?q={{ teamEntry.slug }}" data-slug="{{ teamEntry.slug }}" >
          <div class="inhover">
            <span class="title">View Profile</span>
          </div>
        </div>
      </div>
 {% endfor %}

marked as duplicate by RitterKnight, Brad Bell, Luke Pearce, Lindsey D Aug 16 '16 at 16:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Voting to close this. If you're running out of memory, the only real solution is to increase the allocation to PHP. See also: Fatal error: Allowed memory size of 134mb exhausted – RitterKnight Aug 12 '16 at 19:48
  • The question as asked is a duplicate, and will be closed as such. However, the real question should be "why is this code so inefficient?". I highly recommend looking into eager loading to vastly improve your load time here. – Lindsey D Aug 16 '16 at 16:45

Browse other questions tagged or ask your own question.