]> git.mxchange.org Git - friendica.git/commitdiff
item guids
authorFriendika <info@friendika.com>
Mon, 8 Aug 2011 00:29:26 +0000 (17:29 -0700)
committerFriendika <info@friendika.com>
Mon, 8 Aug 2011 00:29:26 +0000 (17:29 -0700)
boot.php
database.sql
include/items.php
include/text.php
mod/item.php
update.php

index 3bdbe2db2a72b51663e6dd0b639ca171bdac2106..27adea086666f683585bbb88c4b09905f279f264 100644 (file)
--- 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' );
index 1521293378f14491e1a823f1ac1d3db11e849f98..89c4b4267c4de032fae42a874950ad4c7f10bdf3 100644 (file)
@@ -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`),
index 4c0e8312cc3c2b863057d3f2ba750ab7050493dc..50d7bd68c7439485af54b3b5dfe628441a5a2268 100644 (file)
@@ -747,6 +747,8 @@ function item_store($arr,$force_parent = false) {
                }
        }
 
+       $arr['guid'] = get_guid();
+
        call_hooks('post_remote',$arr);
 
        dbesc_array($arr);
index 2973836023825c14d4907c025bfc163122b9f2df..adc94b4589800a1f65fba696c2438d83590e6bdb 100644 (file)
@@ -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)
                );
index fd5d405ff6cac3a071a431f95220c4eaf37dd147..884e730e6b3e96eef9d9fb7d3988715f06a2f74f 100644 (file)
@@ -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']),
index 3c76a6bb4c318ee484c7a420d034a62cbf18d137..256ab48e813e5eb15f4a94259f309154aefca40d 100644 (file)
@@ -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` ) ");
+}