aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Settings/Oauth2.php3
-rw-r--r--Zotlabs/Update/_1214.php57
-rwxr-xr-xboot.php2
-rw-r--r--install/schema_mysql.sql8
-rw-r--r--install/schema_postgres.sql8
5 files changed, 68 insertions, 10 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;
+ }
+
+ }
+ }
+
+}
diff --git a/boot.php b/boot.php
index 64d5bae4c..3e3dc532a 100755
--- a/boot.php
+++ b/boot.php
@@ -54,7 +54,7 @@ define ( 'STD_VERSION', '3.4' );
define ( 'ZOT_REVISION', '6.0a' );
-define ( 'DB_UPDATE_VERSION', 1213 );
+define ( 'DB_UPDATE_VERSION', 1214 );
define ( 'PROJECT_BASE', __DIR__ );
diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql
index 9bf91fc51..9685a878e 100644
--- a/install/schema_mysql.sql
+++ b/install/schema_mysql.sql
@@ -1606,14 +1606,14 @@ CREATE TABLE if not exists oauth_clients (
redirect_uri VARCHAR(2000),
grant_types VARCHAR(80),
scope VARCHAR(4000),
- user_id VARCHAR(80),
+ user_id int(10) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (client_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE if not exists oauth_access_tokens (
access_token VARCHAR(40) NOT NULL,
client_id VARCHAR(80) NOT NULL,
- user_id VARCHAR(255),
+ user_id int(10) unsigned NOT NULL DEFAULT 0,
expires TIMESTAMP NOT NULL,
scope VARCHAR(4000),
PRIMARY KEY (access_token)
@@ -1622,7 +1622,7 @@ CREATE TABLE if not exists oauth_access_tokens (
CREATE TABLE if not exists oauth_authorization_codes (
authorization_code VARCHAR(40) NOT NULL,
client_id VARCHAR(80) NOT NULL,
- user_id VARCHAR(255),
+ user_id int(10) unsigned NOT NULL DEFAULT 0,
redirect_uri VARCHAR(2000),
expires TIMESTAMP NOT NULL,
scope VARCHAR(4000),
@@ -1633,7 +1633,7 @@ CREATE TABLE if not exists oauth_authorization_codes (
CREATE TABLE if not exists oauth_refresh_tokens (
refresh_token VARCHAR(40) NOT NULL,
client_id VARCHAR(80) NOT NULL,
- user_id VARCHAR(255),
+ user_id int(10) unsigned NOT NULL DEFAULT 0,
expires TIMESTAMP NOT NULL,
scope VARCHAR(4000),
PRIMARY KEY (refresh_token)
diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql
index 3fba5b546..4584e4f2e 100644
--- a/install/schema_postgres.sql
+++ b/install/schema_postgres.sql
@@ -1620,14 +1620,14 @@ CREATE TABLE oauth_clients (
redirect_uri VARCHAR(2000),
grant_types VARCHAR(80),
scope VARCHAR(4000),
- user_id VARCHAR(80),
+ user_id bigint NOT NULL DEFAULT '0',
PRIMARY KEY (client_id)
);
CREATE TABLE oauth_access_tokens (
access_token VARCHAR(40) NOT NULL,
client_id VARCHAR(80) NOT NULL,
- user_id VARCHAR(255),
+ user_id bigint NOT NULL DEFAULT '0',
expires TIMESTAMP NOT NULL,
scope VARCHAR(4000),
PRIMARY KEY (access_token)
@@ -1636,7 +1636,7 @@ CREATE TABLE oauth_access_tokens (
CREATE TABLE oauth_authorization_codes (
authorization_code VARCHAR(40) NOT NULL,
client_id VARCHAR(80) NOT NULL,
- user_id VARCHAR(255),
+ user_id bigint NOT NULL DEFAULT '0',
redirect_uri VARCHAR(2000),
expires TIMESTAMP NOT NULL,
scope VARCHAR(4000),
@@ -1647,7 +1647,7 @@ CREATE TABLE oauth_authorization_codes (
CREATE TABLE oauth_refresh_tokens (
refresh_token VARCHAR(40) NOT NULL,
client_id VARCHAR(80) NOT NULL,
- user_id VARCHAR(255),
+ user_id bigint NOT NULL DEFAULT '0',
expires TIMESTAMP NOT NULL,
scope VARCHAR(4000),
PRIMARY KEY (refresh_token)