aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-08-07 17:29:26 -0700
committerFriendika <info@friendika.com>2011-08-07 17:29:26 -0700
commit8812b7f4caa99d01ae0e082c0b29a2ee24aed67d (patch)
tree0a5988272c513e7bcc789e7864f145f26a3bbfb0
parent1eec10329a4764f132b159e7b1bbf37added6c8a (diff)
downloadvolse-hubzilla-8812b7f4caa99d01ae0e082c0b29a2ee24aed67d.tar.gz
volse-hubzilla-8812b7f4caa99d01ae0e082c0b29a2ee24aed67d.tar.bz2
volse-hubzilla-8812b7f4caa99d01ae0e082c0b29a2ee24aed67d.zip
item guids
-rw-r--r--boot.php2
-rw-r--r--database.sql2
-rw-r--r--include/items.php2
-rw-r--r--include/text.php2
-rw-r--r--mod/item.php8
-rw-r--r--update.php5
6 files changed, 16 insertions, 5 deletions
diff --git a/boot.php b/boot.php
index 3bdbe2db2..27adea086 100644
--- a/boot.php
+++ b/boot.php
@@ -9,7 +9,7 @@ require_once("include/pgettext.php");
define ( 'FRIENDIKA_VERSION', '2.2.1065' );
define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
-define ( 'DB_UPDATE_VERSION', 1078 );
+define ( 'DB_UPDATE_VERSION', 1079 );
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
diff --git a/database.sql b/database.sql
index 152129337..89c4b4267 100644
--- a/database.sql
+++ b/database.sql
@@ -160,6 +160,7 @@ CREATE TABLE IF NOT EXISTS `intro` (
CREATE TABLE IF NOT EXISTS `item` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `guid` char(64) NOT NULL,
`uri` char(255) NOT NULL,
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`contact-id` int(10) unsigned NOT NULL DEFAULT '0',
@@ -208,6 +209,7 @@ CREATE TABLE IF NOT EXISTS `item` (
`deleted` tinyint(1) NOT NULL DEFAULT '0',
`last-child` tinyint(1) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
+ KEY `guid` (`guid`),
KEY `uri` (`uri`),
KEY `uid` (`uid`),
KEY `contact-id` (`contact-id`),
diff --git a/include/items.php b/include/items.php
index 4c0e8312c..50d7bd68c 100644
--- a/include/items.php
+++ b/include/items.php
@@ -747,6 +747,8 @@ function item_store($arr,$force_parent = false) {
}
}
+ $arr['guid'] = get_guid();
+
call_hooks('post_remote',$arr);
dbesc_array($arr);
diff --git a/include/text.php b/include/text.php
index 297383602..adc94b458 100644
--- a/include/text.php
+++ b/include/text.php
@@ -881,7 +881,7 @@ function return_bytes ($size_str) {
function generate_user_guid() {
$found = true;
do {
- $guid = substr(random_string(),0,16);
+ $guid = random_string(16);
$x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1",
dbesc($guid)
);
diff --git a/mod/item.php b/mod/item.php
index fd5d405ff..884e730e6 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -506,6 +506,9 @@ function item_post(&$a) {
if($orig_post)
$datarray['edit'] = true;
+ else
+ $datarray['guid'] = get_guid();
+
call_hooks('post_local',$datarray);
@@ -529,11 +532,12 @@ function item_post(&$a) {
$post_id = 0;
- $r = q("INSERT INTO `item` (`uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
+ $r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
`author-name`, `author-link`, `author-avatar`, `created`, `edited`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`,
`tag`, `inform`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach` )
- VALUES( %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s' )",
+ VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s' )",
intval($datarray['uid']),
+ dbesc($datarray['guid']),
dbesc($datarray['type']),
intval($datarray['wall']),
intval($datarray['gravity']),
diff --git a/update.php b/update.php
index 3c76a6bb4..256ab48e8 100644
--- a/update.php
+++ b/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1078 );
+define( 'UPDATE_VERSION' , 1079 );
/**
*
@@ -643,3 +643,6 @@ function update_1077() {
q("ALTER TABLE `guid` CHANGE `guid` `guid` CHAR( 64 ) NOT NULL");
}
+function update_1078() {
+ q("ALTER TABLE `item` ADD `guid` CHAR( 64 ) NOT NULL AFTER `id` , ADD INDEX ( `guid` ) ");
+}