diff options
author | Mario <mario@mariovavti.com> | 2018-05-20 22:42:47 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2018-05-20 22:55:13 +0200 |
commit | 5b48eb3657a7cf6593b4c1f6ee17bf32eaa402af (patch) | |
tree | 5d8e11cb193526cbc4c165d9b5fce12ab26bc1db /Zotlabs | |
parent | 43f04e4bc0b041a4e6450f6aad3e9045fb5eb3cf (diff) | |
download | volse-hubzilla-5b48eb3657a7cf6593b4c1f6ee17bf32eaa402af.tar.gz volse-hubzilla-5b48eb3657a7cf6593b4c1f6ee17bf32eaa402af.tar.bz2 volse-hubzilla-5b48eb3657a7cf6593b4c1f6ee17bf32eaa402af.zip |
update oauth related tables to use bigint/int(10) for user_id column. this is to be more consistent with the rest of the tables and fixes issue #1180
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Module/Settings/Oauth2.php | 3 | ||||
-rw-r--r-- | Zotlabs/Update/_1214.php | 57 |
2 files changed, 59 insertions, 1 deletions
diff --git a/Zotlabs/Module/Settings/Oauth2.php b/Zotlabs/Module/Settings/Oauth2.php index 8db5c14aa..985095115 100644 --- a/Zotlabs/Module/Settings/Oauth2.php +++ b/Zotlabs/Module/Settings/Oauth2.php @@ -14,7 +14,8 @@ class Oauth2 { $key = $_POST['remove']; q("DELETE FROM tokens WHERE id='%s' AND uid=%d", dbesc($key), - local_channel()); + intval(local_channel()) + ); goaway(z_root()."/settings/oauth2/"); return; } diff --git a/Zotlabs/Update/_1214.php b/Zotlabs/Update/_1214.php new file mode 100644 index 000000000..06e5d96ed --- /dev/null +++ b/Zotlabs/Update/_1214.php @@ -0,0 +1,57 @@ +<?php + +namespace Zotlabs\Update; + +class _1214 { + + function run() { + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + q("START TRANSACTION"); + + $r1 = q("ALTER TABLE oauth_clients ALTER COLUMN user_id TYPE bigint USING user_id::bigint"); + $r2 = q("ALTER TABLE oauth_clients ALTER COLUMN user_id SET NOT NULL"); + $r3 = q("ALTER TABLE oauth_clients ALTER COLUMN user_id SET DEFAULT 0"); + + $r4 = q("ALTER TABLE oauth_access_tokens ALTER COLUMN user_id TYPE bigint USING user_id::bigint"); + $r5 = q("ALTER TABLE oauth_access_tokens ALTER COLUMN user_id SET NOT NULL"); + $r6 = q("ALTER TABLE oauth_access_tokens ALTER COLUMN user_id SET DEFAULT 0"); + + $r7 = q("ALTER TABLE oauth_authorization_codes ALTER COLUMN user_id TYPE bigint USING user_id::bigint"); + $r8 = q("ALTER TABLE oauth_authorization_codes ALTER COLUMN user_id SET NOT NULL"); + $r9 = q("ALTER TABLE oauth_authorization_codes ALTER COLUMN user_id SET DEFAULT 0"); + + $r10 = q("ALTER TABLE oauth_refresh_tokens ALTER COLUMN user_id TYPE bigint USING user_id::bigint"); + $r11 = q("ALTER TABLE oauth_refresh_tokens ALTER COLUMN user_id SET NOT NULL"); + $r12 = q("ALTER TABLE oauth_refresh_tokens ALTER COLUMN user_id SET DEFAULT 0"); + + + if($r1 && $r2 && $r3 && $r4 && $r5 && $r6 && $r7 && $r8 && $r9 && $r10 && $r11 && $r12) { + q("COMMIT"); + return UPDATE_SUCCESS; + } + else { + q("ROLLBACK"); + return UPDATE_FAILED; + } + } + else { + q("START TRANSACTION"); + + $r1 = q("ALTER TABLE oauth_clients MODIFY COLUMN user_id int(10) unsigned NOT NULL DEFAULT 0"); + $r2 = q("ALTER TABLE oauth_access_tokens MODIFY COLUMN user_id int(10) unsigned NOT NULL DEFAULT 0"); + $r3 = q("ALTER TABLE oauth_authorization_codes MODIFY COLUMN user_id int(10) unsigned NOT NULL DEFAULT 0"); + $r4 = q("ALTER TABLE oauth_refresh_tokens MODIFY COLUMN user_id int(10) unsigned NOT NULL DEFAULT 0"); + + if($r1 && $r2 && $r3 && $r4) { + q("COMMIT"); + return UPDATE_SUCCESS; + } + else { + q("ROLLBACK"); + return UPDATE_FAILED; + } + + } + } + +} |