statamic-redirect icon indicating copy to clipboard operation
statamic-redirect copied to clipboard

Redirects stopped working with 3.9.4

Open morhi opened this issue 9 months ago • 14 comments

I noticed that with Version 3.9.4 redirects don't work anymore, because the new source_md5 field is not working correctly. I couldn't really find out why, but source_md5 is set correctly in save@RedirectRepository, but if I run a query on the Stache store, it is set to null for all redirects and thus does not find any item.

Downgrading to 3.9.3 fixes the issue.

Thanks for looking into that!

morhi avatar Mar 31 '25 09:03 morhi

I think we ran into the same problem and got a lot of "table errors has no column named url_md5" errors after updating to the latest version of this addon.

heidkaemper avatar Apr 01 '25 06:04 heidkaemper

Sorry about this, I'll try to take a look today (just moved house so the past weeks were a bit hectic)

riasvdv avatar Apr 01 '25 06:04 riasvdv

No worries @riasvdv, thanks for your work! 🙏

morhi avatar Apr 01 '25 06:04 morhi

This specific bug should be fixed in 3.9.5, let me know if it works!

riasvdv avatar Apr 03 '25 09:04 riasvdv

Hey the Bug is still there. I have to downgrade also to the 3.9.3

HannesEURESA avatar Apr 03 '25 11:04 HannesEURESA

Just updating from 3.9.4 which wasn't working to the latest version 3.10.3 and composer throws error

 Error

  Call to a member function source_md5() on null

  at vendor/rias/statamic-redirect/src/UpdateScripts/IncreaseUrlSizeOnRedirects.php:21
     17▕     {
     18▕         $redirectConnection = config('statamic.redirect.redirect_connection');
     19▕
     20▕         if ($redirectConnection === 'stache') {
  ➜  21▕             return ! Redirect::all()->first()->source_md5();
     22▕         }
     23▕
     24▕         if ($redirectConnection === 'default') {
     25▕             $redirectConnection = config('database.default');

      +1 vendor frames

  2   [internal]:0
      Statamic\UpdateScripts\Manager::{closure:Statamic\UpdateScripts\Manager::runUpdatableScripts():83}(Object(Rias\StatamicRedirect\UpdateScripts\IncreaseUrlSizeOnRedirects))
      +20 vendor frames

  23  artisan:13
      Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))

Script @php artisan statamic:install --ansi handling the post-autoload-dump event returned with error code 1

atomicjam avatar Apr 07 '25 09:04 atomicjam

@atomicjam Looks like I forgot the edge case of having no redirects yet, let me know if the latest release fixes this for you https://github.com/riasvdv/statamic-redirect/releases/tag/3.10.4

riasvdv avatar Apr 07 '25 09:04 riasvdv

still throws for me on 3.10.4

Running update script [Rias\StatamicRedirect\UpdateScripts\IncreaseUrlSizeOnRedirects]

   Error

  Call to a member function source_md5() on null

  at vendor/rias/statamic-redirect/src/UpdateScripts/IncreaseUrlSizeOnRedirects.php:41
     37▕     {
     38▕         $redirectConnection = config('statamic.redirect.redirect_connection');
     39▕
     40▕         if ($redirectConnection === 'stache') {
  ➜  41▕             if (Redirect::all()->first()->source_md5()) {
     42▕                 return;
     43▕             }
     44▕
     45▕             Redirect::all()->each(function (\Rias\StatamicRedirect\Data\Redirect $redirect) {

      +20 vendor frames

  21  artisan:13
      Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))

Script @php artisan statamic:install --ansi handling the post-autoload-dump event returned with error code 1

atomicjam avatar Apr 07 '25 09:04 atomicjam

Ah, that's a different line, try 3.10.5, sorry about that

riasvdv avatar Apr 07 '25 09:04 riasvdv

Perfect 3.10.5 worked

atomicjam avatar Apr 07 '25 09:04 atomicjam

@riasvdv Not sure if this is related to this issue, one of our clients also noticed that their redirects suddenly stopped working.

After updating to 3.10.5 the redirects still didn't work for us.

Then I found out that it's most likely because IncreaseUrlSizeOnRedirects never ran on our production server, since we use composer install instead of composer update in our deploy script.

Is there any chance this is the issue?

swen4 avatar Apr 09 '25 08:04 swen4

You can try to run php artisan statamic:install which should run the update scripts as well

riasvdv avatar Apr 09 '25 08:04 riasvdv

You can try to run php artisan statamic:install which should run the update scripts as well

Just tried this as well, but it doesn't seem to run the update script. Only composer update seems to work.

swen4 avatar Apr 09 '25 09:04 swen4

In our Case was, that the migrations were created and running multiple times after updating. We had to delete all migrations except the last one with the source_md5.

HannesEURESA avatar Apr 09 '25 12:04 HannesEURESA