From f9e3ff4b55e930c020649a578738b0c9c74abe50 Mon Sep 17 00:00:00 2001
From: Philipp Holzer <admin+github@philipp.info>
Date: Sat, 9 Nov 2019 21:46:50 +0100
Subject: [PATCH] Remove unnecessary hash function. - Was introduced for
 getting the last inserted ID before "lastInstertID()" was possible - See
 https://github.com/duthied/Free-Friendika/commit/b821399f001cd4082707ba9fb6df9c419e0b8e5e#diff-a8e86a3c07531e66a3b0b4c8b4b07879R148

---
 database.sql                  |  2 --
 include/enotify.php           | 10 +---------
 static/dbstructure.config.php |  4 +---
 3 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/database.sql b/database.sql
index d42f61f902..b09b8290e0 100644
--- a/database.sql
+++ b/database.sql
@@ -793,7 +793,6 @@ CREATE TABLE IF NOT EXISTS `manage` (
 --
 CREATE TABLE IF NOT EXISTS `notify` (
 	`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
-	`hash` varchar(64) NOT NULL DEFAULT '' COMMENT '',
 	`type` smallint unsigned NOT NULL DEFAULT 0 COMMENT '',
 	`name` varchar(255) NOT NULL DEFAULT '' COMMENT '',
 	`url` varchar(255) NOT NULL DEFAULT '' COMMENT '',
@@ -810,7 +809,6 @@ CREATE TABLE IF NOT EXISTS `notify` (
 	`name_cache` tinytext COMMENT 'Cached bbcode parsing of name',
 	`msg_cache` mediumtext COMMENT 'Cached bbcode parsing of msg',
 	 PRIMARY KEY(`id`),
-	 INDEX `hash_uid` (`hash`,`uid`),
 	 INDEX `seen_uid_date` (`seen`,`uid`,`date`),
 	 INDEX `uid_date` (`uid`,`date`),
 	 INDEX `uid_type_link` (`uid`,`type`,`link`(190))
diff --git a/include/enotify.php b/include/enotify.php
index a8090e35f8..2f3b6b49b2 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -503,17 +503,9 @@ function notification($params)
 
 	if ($show_in_notification_page) {
 		Logger::log("adding notification entry", Logger::DEBUG);
-		do {
-			$dups = false;
-			$hash = Strings::getRandomHex();
-			if (DBA::exists('notify', ['hash' => $hash])) {
-				$dups = true;
-			}
-		} while ($dups == true);
 
 		/// @TODO One statement is enough
 		$datarray = [];
-		$datarray['hash']  = $hash;
 		$datarray['name']  = $params['source_name'];
 		$datarray['name_cache'] = strip_tags(BBCode::convert($params['source_name']));
 		$datarray['url']   = $params['source_link'];
@@ -536,7 +528,7 @@ function notification($params)
 		}
 
 		// create notification entry in DB
-		$fields = ['hash' => $datarray['hash'], 'name' => $datarray['name'], 'url' => $datarray['url'],
+		$fields = ['name' => $datarray['name'], 'url' => $datarray['url'],
 			'photo' => $datarray['photo'], 'date' => $datarray['date'], 'uid' => $datarray['uid'],
 			'link' => $datarray['link'], 'iid' => $datarray['iid'], 'parent' => $datarray['parent'],
 			'type' => $datarray['type'], 'verb' => $datarray['verb'], 'otype' => $datarray['otype'],
diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php
index 53f8a8ed44..e87a84ef92 100755
--- a/static/dbstructure.config.php
+++ b/static/dbstructure.config.php
@@ -34,7 +34,7 @@
 use Friendica\Database\DBA;
 
 if (!defined('DB_UPDATE_VERSION')) {
-	define('DB_UPDATE_VERSION', 1323);
+	define('DB_UPDATE_VERSION', 1324);
 }
 
 return [
@@ -868,7 +868,6 @@ return [
 		"comment" => "notifications",
 		"fields" => [
 			"id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
-			"hash" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
 			"type" => ["type" => "smallint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
 			"name" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
 			"url" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
@@ -887,7 +886,6 @@ return [
 		],
 		"indexes" => [
 			"PRIMARY" => ["id"],
-			"hash_uid" => ["hash", "uid"],
 			"seen_uid_date" => ["seen", "uid", "date"],
 			"uid_date" => ["uid", "date"],
 			"uid_type_link" => ["uid", "type", "link(190)"],
-- 
2.39.5