accessibility-exchange / platform

The Accessibility Exchange platform.
https://github.com/orgs/accessibility-exchange/projects/2/views/8
BSD 3-Clause "New" or "Revised" License
4 stars 10 forks source link

foreach() argument must be of type array|object, null given #1711

Open jobara opened 1 year ago

jobara commented 1 year ago

ErrorException

foreach() argument must be of type array|object, null given

:dart: Illuminate\Foundation\Bootstrap\HandleExceptions::handleError :page_facing_up: /app/resources/views/components/translation-manager.blade.php

1  <div>
2      <x-expander level="2" :summary="__('Edit page translations')" x-data>
3*         @foreach ($model->languages as $language)
4              <div x-data="modal()">
5                  <p class="repel">{{ get_language_exonym($language) }}@if (count($model->languages) > 1)

Open in Flare

jobara commented 1 year ago

I haven't been able to reproduce this year, as the models passed to translation-manager include the languages. That being said, the translation-manager doesn't guard against this case, and at least the projects model does allow for the languages to be null in the database.

jobara commented 1 year ago

In working on #1444 I accidentally reproduced the issue. What seems to be the problem is if you go directly to the projects.create route instead of first going through the projects.show-language-selection route. I experienced this by using the wrong route to create a link, but a user could encounter this by navigating directly to a link like https://staging.accessibilityexchange.ca/lsq/projects/8/edit?step=1. For example if they saved this link elsewhere or typed it into the address bar.