Merge pull request #4351 from annando/item-move

Most functions now moved from include/items.php
This commit is contained in:
Hypolite Petovan 2018-01-28 12:54:41 -05:00 committed by GitHub
commit 174ae78ec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 1502 additions and 1528 deletions

View File

@ -4731,7 +4731,7 @@ function post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $f
. '[/url]';
// do the magic for storing the item in the database and trigger the federation to other contacts
item_store($arr);
Item::insert($arr);
}
/**

View File

@ -11,6 +11,7 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Util\Map;
@ -399,7 +400,7 @@ function event_store($arr) {
$item_arr['object'] .= '<content>' . xmlify(format_event_bbcode($event)) . '</content>';
$item_arr['object'] .= '</object>' . "\n";
$item_id = item_store($item_arr);
$item_id = Item::insert($item_arr);
if ($item_id) {
q("UPDATE `item` SET `event-id` = %d WHERE `uid` = %d AND `id` = %d",
intval($event['id']),

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@ use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Protocol\Diaspora;
/**
@ -244,7 +245,7 @@ EOT;
'unseen' => 1,
];
$new_item_id = item_store($new_item);
$new_item_id = Item::insert($new_item);
// @todo: Explain this block
if (! $item['visible']) {

View File

@ -26,6 +26,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Network\Probe;
use Friendica\Protocol\Diaspora;
@ -439,7 +440,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
$arr['deny_cid'] = $user['deny_cid'];
$arr['deny_gid'] = $user['deny_gid'];
$i = item_store($arr);
$i = Item::insert($arr);
if ($i) {
Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
}
@ -701,7 +702,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
$arr['deny_cid'] = $user['deny_cid'];
$arr['deny_gid'] = $user['deny_gid'];
$i = item_store($arr);
$i = Item::insert($arr);
if ($i) {
Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
}

View File

@ -729,7 +729,7 @@ function item_post(App $a) {
unset($datarray['self']);
unset($datarray['api_source']);
$post_id = item_store($datarray);
$post_id = Item::insert($datarray);
if (!$post_id) {
logger("Item wasn't stored.");

View File

@ -8,6 +8,7 @@ use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Module\Login;
use Friendica\Model\Item;
function notify_init(App $a)
{
@ -27,7 +28,7 @@ function notify_init(App $a)
require_once("include/items.php");
$urldata = parse_url($note['link']);
$guid = basename($urldata["path"]);
$itemdata = get_item_id($guid, local_user());
$itemdata = Item::getIdAndNickByGuid($guid, local_user());
if ($itemdata["id"] != 0) {
$note['link'] = System::baseUrl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
}

View File

@ -13,6 +13,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Photo;
use Friendica\Model\Profile;
use Friendica\Network\Probe;
@ -519,7 +520,7 @@ function photos_post(App $a)
. '[img]' . System::baseUrl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]'
. '[/url]';
$item_id = item_store($arr);
$item_id = Item::insert($arr);
}
if ($item_id) {
@ -709,7 +710,7 @@ function photos_post(App $a)
. System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '</id>';
$arr['target'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '" />' . "\n" . '<link rel="preview" type="'.$p[0]['type'].'" href="' . System::baseUrl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
$item_id = item_store($arr);
$item_id = Item::insert($arr);
if ($item_id) {
Worker::add(PRIORITY_HIGH, "Notifier", "tag", $item_id);
}
@ -931,7 +932,7 @@ function photos_post(App $a)
. '[img]' . System::baseUrl() . "/photo/{$photo_hash}-{$smallest}.".$Image->getExt() . '[/img]'
. '[/url]';
$item_id = item_store($arr);
$item_id = Item::insert($arr);
// Update the photo albums cache
Photo::clearAlbumCache($page_owner_uid);

View File

@ -19,6 +19,7 @@ use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Item;
require_once 'include/security.php';
require_once 'include/bbcode.php';
@ -132,7 +133,7 @@ function poke_init(App $a) {
$arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $target['photo'] . '" />' . "\n");
$arr['object'] .= '</link></object>' . "\n";
$item_id = item_store($arr);
$item_id = Item::insert($arr);
if($item_id) {
//q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
// dbesc(System::baseUrl() . '/display/' . $poster['nickname'] . '/' . $item_id),

View File

@ -15,6 +15,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\GContact;
use Friendica\Model\Profile;
use Friendica\Model\Item;
use Friendica\Network\Probe;
function profiles_init(App $a) {
@ -601,7 +602,7 @@ function profile_activity($changed, $value) {
$arr['deny_cid'] = $a->user['deny_cid'];
$arr['deny_gid'] = $a->user['deny_gid'];
$i = item_store($arr);
$i = Item::insert($arr);
if ($i) {
Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
}

View File

@ -7,6 +7,7 @@ use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Item;
require_once 'include/security.php';
require_once 'include/bbcode.php';
@ -149,7 +150,7 @@ EOT;
$arr['visible'] = 1;
$arr['unseen'] = 1;
$post_id = item_store($arr);
$post_id = Item::insert($arr);
if (! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",

View File

@ -8,6 +8,7 @@ use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Item;
require_once 'include/security.php';
require_once 'include/bbcode.php';
@ -145,13 +146,7 @@ EOT;
$arr['unseen'] = 1;
$arr['origin'] = 1;
$post_id = item_store($arr);
// q("UPDATE `item` set plink = '%s' where id = %d",
// dbesc(System::baseUrl() . '/display/' . $owner_nick . '/' . $post_id),
// intval($post_id)
// );
$post_id = Item::insert($arr);
if(! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",

View File

@ -549,4 +549,91 @@ class BBCode
$s = htmlspecialchars($s, ENT_NOQUOTES, 'UTF-8');
return $s;
}
/**
* The purpose of this function is to apply system message length limits to
* imported messages without including any embedded photos in the length
*
* @brief Truncates imported message body string length to max_import_size
* @param string $body
* @return string
*/
public static function limitBodySize($body)
{
$maxlen = get_max_import_size();
// If the length of the body, including the embedded images, is smaller
// than the maximum, then don't waste time looking for the images
if ($maxlen && (strlen($body) > $maxlen)) {
logger('the total body length exceeds the limit', LOGGER_DEBUG);
$orig_body = $body;
$new_body = '';
$textlen = 0;
$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
while (($img_st_close !== false) && ($img_end !== false)) {
$img_st_close++; // make it point to AFTER the closing bracket
$img_end += $img_start;
$img_end += strlen('[/img]');
if (!strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
// This is an embedded image
if (($textlen + $img_start) > $maxlen) {
if ($textlen < $maxlen) {
logger('the limit happens before an embedded image', LOGGER_DEBUG);
$new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen);
$textlen = $maxlen;
}
} else {
$new_body = $new_body . substr($orig_body, 0, $img_start);
$textlen += $img_start;
}
$new_body = $new_body . substr($orig_body, $img_start, $img_end - $img_start);
} else {
if (($textlen + $img_end) > $maxlen) {
if ($textlen < $maxlen) {
logger('the limit happens before the end of a non-embedded image', LOGGER_DEBUG);
$new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen);
$textlen = $maxlen;
}
} else {
$new_body = $new_body . substr($orig_body, 0, $img_end);
$textlen += $img_end;
}
}
$orig_body = substr($orig_body, $img_end);
if ($orig_body === false) {
// in case the body ends on a closing image tag
$orig_body = '';
}
$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
}
if (($textlen + strlen($orig_body)) > $maxlen) {
if ($textlen < $maxlen) {
logger('the limit happens after the end of the last image', LOGGER_DEBUG);
$new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen);
}
} else {
logger('the text size with embedded images extracted did not violate the limit', LOGGER_DEBUG);
$new_body = $new_body . $orig_body;
}
return $new_body;
} else {
return $body;
}
}
}

View File

@ -60,7 +60,7 @@ class System extends BaseObject
$previous = ['class' => '', 'function' => ''];
// The ignore list contains all functions that are only wrapper functions
$ignore = ['get_config', 'get_pconfig', 'set_config', 'set_pconfig', 'fetch_url', 'probe_url'];
$ignore = ['fetchUrl'];
while ($func = array_pop($trace)) {
if (!empty($func['class'])) {

View File

@ -1354,4 +1354,113 @@ class Contact extends BaseObject
return $contact;
}
public static function addRelationship($importer, $contact, $datarray, $item, $sharing = false) {
$url = notags(trim($datarray['author-link']));
$name = notags(trim($datarray['author-name']));
$photo = notags(trim($datarray['author-avatar']));
if (is_object($item)) {
$rawtag = $item->get_item_tags(NAMESPACE_ACTIVITY,'actor');
if ($rawtag && $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data']) {
$nick = $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data'];
}
} else {
$nick = $item;
}
if (is_array($contact)) {
if (($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING)
|| ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) {
dba::update('contact', ['rel' => CONTACT_IS_FRIEND, 'writable' => true],
['id' => $contact['id'], 'uid' => $importer['uid']]);
}
// send email notification to owner?
} else {
// create contact record
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `name`, `nick`, `photo`, `network`, `rel`,
`blocked`, `readonly`, `pending`, `writable`)
VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, 1)",
intval($importer['uid']),
dbesc(datetime_convert()),
dbesc($url),
dbesc(normalise_link($url)),
dbesc($name),
dbesc($nick),
dbesc($photo),
dbesc(NETWORK_OSTATUS),
intval(CONTACT_IS_FOLLOWER)
);
$r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 LIMIT 1",
intval($importer['uid']),
dbesc($url)
);
if (DBM::is_result($r)) {
$contact_record = $r[0];
Contact::updateAvatar($photo, $importer["uid"], $contact_record["id"], true);
}
/// @TODO Encapsulate this into a function/method
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($importer['uid'])
);
if (DBM::is_result($r) && !in_array($r[0]['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
// create notification
$hash = random_string();
if (is_array($contact_record)) {
dba::insert('intro', ['uid' => $importer['uid'], 'contact-id' => $contact_record['id'],
'blocked' => false, 'knowyou' => false,
'hash' => $hash, 'datetime' => datetime_convert()]);
}
Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']);
if (($r[0]['notify-flags'] & NOTIFY_INTRO) &&
in_array($r[0]['page-flags'], [PAGE_NORMAL])) {
notification([
'type' => NOTIFY_INTRO,
'notify_flags' => $r[0]['notify-flags'],
'language' => $r[0]['language'],
'to_name' => $r[0]['username'],
'to_email' => $r[0]['email'],
'uid' => $r[0]['uid'],
'link' => System::baseUrl() . '/notifications/intro',
'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : L10n::t('[Name Withheld]')),
'source_link' => $contact_record['url'],
'source_photo' => $contact_record['photo'],
'verb' => ($sharing ? ACTIVITY_FRIEND : ACTIVITY_FOLLOW),
'otype' => 'intro'
]);
}
} elseif (DBM::is_result($r) && in_array($r[0]['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1",
intval($importer['uid']),
dbesc($url)
);
}
}
}
public static function removeFollower($importer, $contact, array $datarray = [], $item = "") {
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
dba::update('contact', ['rel' => CONTACT_IS_SHARING], ['id' => $contact['id']]);
} else {
Contact::remove($contact['id']);
}
}
public static function removeSharer($importer, $contact, array $datarray = [], $item = "") {
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
dba::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]);
} else {
Contact::remove($contact['id']);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Model\Term;
use Friendica\Model\User;
@ -27,6 +28,7 @@ use Friendica\Protocol\OStatus;
use Friendica\Util\Crypto;
use Friendica\Util\Network;
use Friendica\Util\XML;
use Friendica\Content\Text\BBCode;
use dba;
use DOMDocument;
@ -922,7 +924,7 @@ class DFRN
}
if ($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) {
$body = fix_private_photos($item['body'], $owner['uid'], $item, $cid);
$body = Item::fixPrivatePhotos($item['body'], $owner['uid'], $item, $cid);
} else {
$body = $item['body'];
}
@ -1059,7 +1061,7 @@ class DFRN
$entry->appendChild($actarg);
}
$tags = item_getfeedtags($item);
$tags = Item::getFeedTags($item);
if (count($tags)) {
foreach ($tags as $t) {
@ -2214,7 +2216,7 @@ class DFRN
"to_email" => $importer["email"],
"uid" => $importer["importer_uid"],
"item" => $item,
"link" => System::baseUrl()."/display/".urlencode(get_item_guid($posted_id)),
"link" => System::baseUrl()."/display/".urlencode(Item::getGuidById($posted_id)),
"source_name" => stripslashes($item["author-name"]),
"source_link" => $item["author-link"],
"source_photo" => ((link_compare($item["author-link"], $importer["url"]))
@ -2254,22 +2256,22 @@ class DFRN
// This function once was responsible for DFRN and OStatus.
if (activity_match($item["verb"], ACTIVITY_FOLLOW)) {
logger("New follower");
new_follower($importer, $contact, $item, $nickname);
Contact::addRelationship($importer, $contact, $item, $nickname);
return false;
}
if (activity_match($item["verb"], ACTIVITY_UNFOLLOW)) {
logger("Lost follower");
lose_follower($importer, $contact, $item);
Contact::removeFollower($importer, $contact, $item);
return false;
}
if (activity_match($item["verb"], ACTIVITY_REQ_FRIEND)) {
logger("New friend request");
new_follower($importer, $contact, $item, $nickname, true);
Contact::addRelationship($importer, $contact, $item, $nickname, true);
return false;
}
if (activity_match($item["verb"], ACTIVITY_UNFRIEND)) {
logger("Lost sharer");
lose_sharer($importer, $contact, $item);
Contact::removeSharer($importer, $contact, $item);
return false;
}
} else {
@ -2448,7 +2450,7 @@ class DFRN
// make sure nobody is trying to sneak some html tags by us
$item["body"] = notags(base64url_decode($item["body"]));
$item["body"] = limit_body_size($item["body"]);
$item["body"] = BBCode::limitBodySize($item["body"]);
/// @todo Do we really need this check for HTML elements? (It was copied from the old function)
if ((strpos($item['body'], '<') !== false) && (strpos($item['body'], '>') !== false)) {
@ -2502,7 +2504,7 @@ class DFRN
$item["guid"] = $xpath->query("dfrn:diaspora_guid/text()", $entry)->item(0)->nodeValue;
// We store the data from "dfrn:diaspora_signature" in a different table, this is done in "item_store"
// We store the data from "dfrn:diaspora_signature" in a different table, this is done in "Item::insert"
$dsprsig = unxmlify($xpath->query("dfrn:diaspora_signature/text()", $entry)->item(0)->nodeValue);
if ($dsprsig != "") {
$item["dsprsig"] = $dsprsig;
@ -2670,7 +2672,7 @@ class DFRN
}
if (in_array($entrytype, [DFRN_REPLY, DFRN_REPLY_RC])) {
$posted_id = item_store($item);
$posted_id = Item::insert($item);
$parent = 0;
if ($posted_id) {
@ -2700,7 +2702,7 @@ class DFRN
/*
* The item owner info is not our contact. It's OK and is to be expected if this is a tgroup delivery,
* but otherwise there's a possible data mixup on the sender's system.
* the tgroup delivery code called from item_store will correct it if it's a forum,
* the tgroup delivery code called from Item::insert will correct it if it's a forum,
* but we're going to unconditionally correct it here so that the post will always be owned by our contact.
*/
logger('Correcting item owner.', LOGGER_DEBUG);
@ -2716,9 +2718,9 @@ class DFRN
// This is my contact on another system, but it's really me.
// Turn this into a wall post.
$notify = item_is_remote_self($importer, $item);
$notify = Item::isRemoteSelf($importer, $item);
$posted_id = item_store($item, false, $notify);
$posted_id = Item::insert($item, false, $notify);
logger("Item was stored with id ".$posted_id, LOGGER_DEBUG);

View File

@ -20,6 +20,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Model\Queue;
use Friendica\Model\User;
@ -1730,7 +1731,7 @@ class Diaspora
self::fetchGuid($datarray);
$message_id = item_store($datarray);
$message_id = Item::insert($datarray);
if ($message_id <= 0) {
return false;
@ -2051,7 +2052,7 @@ class Diaspora
$datarray["body"] = self::constructLikeBody($contact, $parent_item, $guid);
$message_id = item_store($datarray);
$message_id = Item::insert($datarray);
if ($message_id <= 0) {
return false;
@ -2417,7 +2418,7 @@ class Diaspora
$arr["deny_cid"] = $user["deny_cid"];
$arr["deny_gid"] = $user["deny_gid"];
$i = item_store($arr);
$i = Item::insert($arr);
if ($i) {
Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
}
@ -2501,7 +2502,7 @@ class Diaspora
return true;
} else {
logger("Author ".$author." doesn't want to follow us anymore.", LOGGER_DEBUG);
lose_follower($importer, $contact);
Contact::removeFollower($importer, $contact);
return true;
}
}
@ -2780,7 +2781,7 @@ class Diaspora
$datarray["object-type"] = $original_item["object-type"];
self::fetchGuid($datarray);
$message_id = item_store($datarray);
$message_id = Item::insert($datarray);
self::sendParticipation($contact, $datarray);
@ -3020,7 +3021,7 @@ class Diaspora
}
self::fetchGuid($datarray);
$message_id = item_store($datarray);
$message_id = Item::insert($datarray);
self::sendParticipation($contact, $datarray);

View File

@ -423,7 +423,7 @@ class Feed {
if (!$simulate) {
logger("Stored feed: ".print_r($item, true), LOGGER_DEBUG);
$notify = item_is_remote_self($contact, $item);
$notify = Item::isRemoteSelf($contact, $item);
// Distributed items should have a well formatted URI.
// Additionally we have to avoid conflicts with identical URI between imported feeds and these items.
@ -433,7 +433,7 @@ class Feed {
unset($item['parent-uri']);
}
$id = item_store($item, false, $notify);
$id = Item::insert($item, false, $notify);
logger("Feed for contact ".$contact["url"]." stored under id ".$id);
} else {

View File

@ -14,6 +14,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Model\Conversation;
use Friendica\Model\Item;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Util\Lock;
@ -455,12 +456,12 @@ class OStatus
}
if ($item["verb"] == ACTIVITY_FOLLOW) {
new_follower($importer, $contact, $item, $nickname);
Contact::addRelationship($importer, $contact, $item, $nickname);
continue;
}
if ($item["verb"] == NAMESPACE_OSTATUS."/unfollow") {
lose_follower($importer, $contact, $item, $dummy);
Contact::removeFollower($importer, $contact, $item, $dummy);
continue;
}
@ -521,12 +522,12 @@ class OStatus
logger("Item with uri ".$item["uri"]." is from a blocked contact.", LOGGER_DEBUG);
} else {
// We are having duplicated entries. Hopefully this solves it.
if (Lock::set('ostatus_process_item_store')) {
$ret = item_store($item);
Lock::remove('ostatus_process_item_store');
if (Lock::set('ostatus_process_item_insert')) {
$ret = Item::insert($item);
Lock::remove('ostatus_process_item_insert');
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"].' stored. Return value: '.$ret);
} else {
$ret = item_store($item);
$ret = Item::insert($item);
logger("We couldn't lock - but tried to store the item anyway. Return value is ".$ret);
}
}
@ -1996,7 +1997,7 @@ class OStatus
XML::addElement($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);
}
$tags = item_getfeedtags($item);
$tags = item::getFeedTags($item);
if (count($tags)) {
foreach ($tags as $t) {

View File

@ -82,7 +82,7 @@ class Network
$a = get_app();
if (self::isUrlBlocked($url)) {
logger('z_fetch_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
logger('domain of ' . $url . ' is blocked', LOGGER_DATA);
return $ret;
}
@ -187,7 +187,7 @@ class Network
}
if (curl_errno($ch) !== CURLE_OK) {
logger('fetch_url error fetching ' . $url . ': ' . curl_error($ch), LOGGER_NORMAL);
logger('error fetching ' . $url . ': ' . curl_error($ch), LOGGER_NORMAL);
}
$ret['errno'] = curl_errno($ch);
@ -197,7 +197,7 @@ class Network
$http_code = $curl_info['http_code'];
logger('fetch_url ' . $url . ': ' . $http_code . " " . $s, LOGGER_DATA);
logger($url . ': ' . $http_code . " " . $s, LOGGER_DATA);
$header = '';
// Pull out multiple headers, e.g. proxy and continuation headers
@ -250,8 +250,8 @@ class Network
if (!$ret['success']) {
$ret['error'] = curl_error($ch);
$ret['debug'] = $curl_info;
logger('z_fetch_url: error: '.$url.': '.$ret['return_code'].' - '.$ret['error'], LOGGER_DEBUG);
logger('z_fetch_url: debug: '.print_r($curl_info, true), LOGGER_DATA);
logger('error: '.$url.': '.$ret['return_code'].' - '.$ret['error'], LOGGER_DEBUG);
logger('debug: '.print_r($curl_info, true), LOGGER_DATA);
}
$ret['body'] = substr($s, strlen($header));

View File

@ -207,7 +207,7 @@ class Delivery {
logger('notifier: '.$target_item["guid"].' dfrndelivery: '.$contact['name']);
if ($mail) {
$item['body'] = fix_private_photos($item['body'],$owner['uid'],null,$message[0]['contact-id']);
$item['body'] = Item::fixPrivatePhotos($item['body'],$owner['uid'],null,$message[0]['contact-id']);
$atom = DFRN::mail($item, $owner);
} elseif ($fsuggest) {
$atom = DFRN::fsuggest($item, $owner);

View File

@ -9,6 +9,7 @@ namespace Friendica\Worker;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Model\Item;
use Friendica\Database\DBM;
use dba;
@ -43,7 +44,7 @@ class Expire {
$user = dba::selectFirst('user', ['uid', 'username', 'expire'], ['uid' => $param]);
if (DBM::is_result($user)) {
logger('Expire items for user '.$user['uid'].' ('.$user['username'].') - interval: '.$user['expire'], LOGGER_DEBUG);
item_expire($user['uid'], $user['expire']);
Item::expire($user['uid'], $user['expire']);
logger('Expire items for user '.$user['uid'].' ('.$user['username'].') - done ', LOGGER_DEBUG);
}
return;

View File

@ -8,6 +8,8 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Content\Text\BBCode;
use Friendica\Protocol\Email;
use Friendica\Protocol\PortableContact;
use Friendica\Util\Network;
@ -487,7 +489,7 @@ class OnePoll
continue;
}
$datarray['body'] = escape_tags($r['body']);
$datarray['body'] = limit_body_size($datarray['body']);
$datarray['body'] = BBCode::limitBodySize($datarray['body']);
logger("Mail: Importing ".$msg_uid." for ".$mailconf['user']);
@ -531,7 +533,7 @@ class OnePoll
$datarray['allow_cid'] = '<' . $contact['id'] . '>';
}
$stored_item = item_store($datarray);
$stored_item = Item::insert($datarray);
switch ($mailconf['action']) {
case 0:

View File

@ -5,6 +5,7 @@
*/
namespace Friendica\Worker;
use Friendica\Model\Item;
use Friendica\Core\Config;
require_once("include/items.php");
@ -46,7 +47,7 @@ class SpoolPost {
continue;
}
$result = item_store($arr);
$result = Item::insert($arr);
logger("Spool file ".$file." stored: ".$result, LOGGER_DEBUG);
unlink($fullfile);