Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

New or Edit redirect // "SQL uid cannot be NULL" #99

Closed
alangreenwood opened this issue Jul 26, 2019 · 8 comments
Closed

New or Edit redirect // "SQL uid cannot be NULL" #99

alangreenwood opened this issue Jul 26, 2019 · 8 comments

Comments

@alangreenwood
Copy link

When editing a site redirect.
Site redirects > Change Destination URL > Save

The Stack Trace shows the error:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'uid' cannot be null
The SQL being executed was: UPDATE elements SET enabled=1, archived=0, dateUpdated='2019-07-26 10:15:49', uid=NULL WHERE id=6615

Craft
Image driver & version | Imagick 3.4.3RC2 (ImageMagick 6.9.7-4)
Craft Pro 3.2.7
Yii version 2.0.21
Twig version 2.11.3
Guzzle version 6.3.3
Imagine version 1.2.3-dev
Plugins:
Cookies version 1.1.11
Freeform version 3.2.3
Redactor version 2.3.3.2
Redirect plugin for Craft 3 version 1.0.23

@xwz
Copy link

xwz commented Aug 22, 2019

diff --git a/src/controllers/SettingsController.php b/src/controllers/SettingsController.php
index 64cba0b..8220c6a 100644
--- a/src/controllers/SettingsController.php
+++ b/src/controllers/SettingsController.php
@@ -323,6 +323,7 @@ class SettingsController extends Controller
         $request = Craft::$app->getRequest();
         $redirect = new Redirect();
         $redirect->id = $request->getBodyParam('redirectId');
+        $redirect->uid = $request->getBodyParam('uid');
         $redirect->sourceUrl = $request->getBodyParam('sourceUrl');
         $redirect->destinationUrl = $request->getBodyParam('destinationUrl');
         $redirect->statusCode = $request->getBodyParam('statusCode');
diff --git a/src/templates/edit.twig b/src/templates/edit.twig
index f1cbeaf..c6503cd 100644
--- a/src/templates/edit.twig
+++ b/src/templates/edit.twig
@@ -15,6 +15,7 @@
     {{ redirectInput('settings/redirect') }}
 
     {% if redirect.id %}<input type="hidden" name="redirectId" value="{{ redirect.id }}">{% endif %}
+    {% if redirect.uid %}<input type="hidden" name="uid" value="{{ redirect.uid }}">{% endif %}
     <div class="readable">
         <p>{{ "You can use the Redirect plugin to redirect simple routes but also use it for more advanced route matches with parameters"|t('redirect') }}
             .<br><a target="_blank"

@alangreenwood
Copy link
Author

Hi @xwz,

This is very interesting. I'm sorry, but I have no idea what it means or what I should do with it though. Is it the script to resolve the issue or should I wait for a push into a plugin update?

I am not a web developer, I am only admin of the Craft site itself. It is something which I have inherited from a predecessor.

Thank you for your time.

@xwz
Copy link

xwz commented Aug 22, 2019

Those are the code changes required. Best wait for the a new build that incorporate a fix.

@alangreenwood
Copy link
Author

Thank you Wei. Fantastic.

@darylknight
Copy link

This is still happening, any chance of the fix being deployed soon as apparently the code changes are already available at source?

barbarj added a commit to barbarj/craft3-plugin-redirect that referenced this issue Oct 7, 2019
johanzandstra added a commit that referenced this issue Oct 7, 2019
@jamessy
Copy link

jamessy commented Oct 15, 2019

When I try using Composer it keeps reverting back to version 1.0.23 and not seeing any package version 1.0.24.

@alangreenwood
Copy link
Author

Honestly, we got tired of waiting for a new build and switched to Retour. https://plugins.craftcms.com/retour which is working for us.

@darylknight
Copy link

darylknight commented Oct 15, 2019

We switched too. It's great this is free, but it's clearly not actively maintained, and it's currently pretty much broken - along with their Sitemap and SEO plugins too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants