pierobot / mangapie

This is a self-hosted server for archived manga.
BSD 3-Clause "New" or "Revised" License
63 stars 9 forks source link

Stale references in lists #188

Closed donotos closed 4 years ago

donotos commented 4 years ago

Hi!

When i go to user menu > lists > planned i get an error 500. all the other lists works fine.

Thanks.

pierobot commented 4 years ago

Do you have a log? I don't get an error on my end.

donotos commented 4 years ago

ok i'll activate dev mod and come back with more infos.

donotos commented 4 years ago
ErrorException (E_ERROR)
Trying to get property 'name' of non-object (View: /var/www/mangapie/resources/views/lists/planned.blade.php)

/var/www/mangapie/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php
     *
     * @param  string  $__path
     * @param  array   $__data
     * @return string
     */
    protected function evaluatePath($__path, $__data)
    {
        $obLevel = ob_get_level();

        ob_start();

        extract($__data, EXTR_SKIP);

        // We'll evaluate the contents of the view inside a try/catch block so we can
        // flush out any stray output that might get out before an error occurs or
        // an exception is thrown. This prevents any partial views from leaking.
        try {
            include $__path;
        } catch (Exception $e) {
            $this->handleViewException($e, $obLevel);
        } catch (Throwable $e) {
            $this->handleViewException(new FatalThrowableError($e), $obLevel);
        }

        return ltrim(ob_get_clean());
    }

    /**
     * Handle a view exception.
     *
     * @param  \Exception  $e
     * @param  int  $obLevel
     * @return void
     *
     * @throws \Exception
     */
    protected function handleViewException(Exception $e, $obLevel)
    {
        while (ob_get_level() > $obLevel) {
            ob_end_clean();
Arguments
ErrorException {#617 ▶}
1
pierobot commented 4 years ago

I don't think I'll need it in this case but try to provide the call stack in the future.

What happens if you run this in php artisan tinker?

Planned::whereDoesntHave('manga')->get();
donotos commented 4 years ago
[!] Aliasing 'Planned' to 'App\Planned' for this Tinker session.
=> Illuminate\Database\Eloquent\Collection {#3206
     all: [
       App\Planned {#3210
         id: 4,
         user_id: 2,
         manga_id: 278,
         created_at: "2020-05-13 14:22:17",
         updated_at: "2020-05-13 14:22:17",
       },
       App\Planned {#3200
         id: 6,
         user_id: 2,
         manga_id: 340,
         created_at: "2020-05-13 15:05:11",
         updated_at: "2020-05-13 15:05:11",
       },
     ],
   }
pierobot commented 4 years ago

Okay. Looks like some stale references to manga that no longer exists. Do

Planned::whereDoesntHave('manga')->forceDelete();

I'll eventually make it so this doesn't happen.

donotos commented 4 years ago

it deleted 2 entries. works fine now.