aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Update/_1261.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-03-22 08:37:29 +0000
committerMario <mario@mariovavti.com>2024-03-22 08:37:29 +0000
commit1aeb05628b6a2a069c46980efbe628362c9e3e74 (patch)
treee9aed15d0cd74e0c23dcb05c7be8fe9541efdf36 /Zotlabs/Update/_1261.php
parent5b7387459cf4de8f7354d81cb0392c4225714d94 (diff)
parentb464fae3bf22585888c5f3def8eded76fd48ed16 (diff)
downloadvolse-hubzilla-1aeb05628b6a2a069c46980efbe628362c9e3e74.tar.gz
volse-hubzilla-1aeb05628b6a2a069c46980efbe628362c9e3e74.tar.bz2
volse-hubzilla-1aeb05628b6a2a069c46980efbe628362c9e3e74.zip
Merge branch '9.0RC'9.0
Diffstat (limited to 'Zotlabs/Update/_1261.php')
-rw-r--r--Zotlabs/Update/_1261.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/Zotlabs/Update/_1261.php b/Zotlabs/Update/_1261.php
new file mode 100644
index 000000000..43fd0b098
--- /dev/null
+++ b/Zotlabs/Update/_1261.php
@@ -0,0 +1,58 @@
+<?php
+namespace Zotlabs\Update;
+
+use Zotlabs\Lib\Multibase;
+
+class _1261 {
+ public function run() {
+
+ $has_sodium = function_exists('sodium_crypto_sign_keypair');
+ $has_bcmath = function_exists('bcadd');
+ $has_gmp = function_exists('gmp_add');
+
+ if (!$has_sodium) {
+ return UPDATE_FAILED;
+ }
+
+ if (!($has_gmp || $has_bcmath)) {
+ return UPDATE_FAILED;
+ }
+
+ dbq("START TRANSACTION");
+
+ if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
+ $r1 = dbq("ALTER TABLE xchan ADD xchan_epubkey text NOT NULL DEFAULT ''");
+ $r2 = dbq("ALTER TABLE xchan ADD xchan_updated timestamp NOT NULL DEFAULT '0001-01-01 00:00:00'");
+ }
+ else {
+ $r1 = dbq("ALTER TABLE xchan ADD xchan_epubkey text NOT NULL");
+ $r2 = dbq("ALTER TABLE xchan ADD xchan_updated datetime NOT NULL DEFAULT '0001-01-01 00:00:00'");
+ }
+
+ $channels = dbq("select * from channel where true");
+ if ($channels) {
+ foreach ($channels as $channel) {
+ $epubkey = (new Multibase())->publicKey($channel['channel_epubkey']);
+ q("update xchan set xchan_epubkey = '%s' where xchan_url = '%s'",
+ dbesc($epubkey),
+ dbesc(channel_url($channel))
+ );
+ }
+ }
+
+ if ($r1 && $r2) {
+ dbq("COMMIT");
+ return UPDATE_SUCCESS;
+ }
+
+ dbq("ROLLBACK");
+ return UPDATE_FAILED;
+
+ }
+
+ public function verify() {
+ $columns = db_columns('xchan');
+ return in_array('xchan_epubkey', $columns) && in_array('xchan_updated', $columns);
+ }
+}
+