Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bramcou's avatar

Strange bug: Illuminate\Database\Eloquent\ModelNotFoundException "favicon.ico"

Hi all,

I have a rather strange bug which I just can't figur out, despite quite some efforts. Googled it and can't find any other cases. The bug turns up every few days and the website's used by 50-100 unique users a day. We use Sentry as bugtracker so we have access to a lot of supplementary information if needed.

I'll describe one particular case which happened a few times: Users click a link which directs them to:

http://xxx.yyy.zzz/ddwv/afmelden-vliegdag/7

Where 7 is the ID of a Model. That controller's code is:

/**
 * Leave a DDWV day
 *
 * @param  integer $ddwv_id
 * @return Redirect
 */
public function leave($ddwv_id)
{
    //get DDWV
    $ddwv_day = Ddwv::with('users')->findOrFail($ddwv_id);

    //authorize
    $this->authorize('leave', $ddwv_day);

    //user is actually already signed up
    if (! $ddwv_day->users->contains($this->user)) {

        //add usernotification
        UserNotification::store('danger', 'U kunt zich niet afmelden voor deze vliegdag want u bent niet aangemeld voor deze vliegdag.');

        //redirect
        return redirect('/ddwv/vliegdag/' . $ddwv_id);
    }

    //remove user from DDWV day
    $ddwv_day->users()->detach($this->user);

    //notifcation
    UserNotification::store('success', 'U bent succesvol afgemeld voor de vliegdag van: ' . $ddwv_day->flyday_date->formatLocalized('%A %e %B %Y'));

    //redirect
    return redirect('/ddwv');
}

Then, somehow they end up getting redirected to the following URL: http://xxx.yyy.zzz/ddwv/afmelden-vliegdag/favicon.ico

Some data from Sentry:

  • The above URL is the "referer" header.
  • It happens on any type of device, OS, browser etc.
  • Laravel 5.4, PHP7, MySQL, Shared hosting
  • Stacktrace, top part:
Illuminate\Database\Eloquent\ModelNotFoundException: No query results for model [App\Models\Ddwv] favicon.ico
#51 vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(302): findOrFail
#50 app/Http/Controllers/Flightops/DdwvController.php(226): leave
#49 [Anonymous function](0): call_user_func_array
#48 vendor/laravel/framework/src/Illuminate/Routing/Controller.php(55): callAction

Any thoughts? If more (specific) info is required, please just ask.

Thanks!

Bram

0 likes
1 reply

Please or to participate in this conversation.