diff options
author | Brion Vibber <brion@pobox.com> | 2010-03-15 14:39:14 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-03-15 14:39:14 -0700 |
commit | 2b684f695447ce9839c04ca4ea6144bc87e63209 (patch) | |
tree | ce2e4cf5dd42fa39905b9c1c6e069faf9eb8d2b1 | |
parent | c89e1865f7250341c8b5e7878715d5a693a0e6aa (diff) | |
parent | cb471e0c96143c780c14e0864d70879a6308206e (diff) |
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x
-rw-r--r-- | classes/Notice.php | 16 | ||||
-rw-r--r-- | lib/activity.php | 2 | ||||
-rw-r--r-- | plugins/OStatus/lib/feeddiscovery.php | 4 | ||||
-rw-r--r-- | plugins/OStatus/scripts/testfeed.php | 89 |
4 files changed, 107 insertions, 4 deletions
diff --git a/classes/Notice.php b/classes/Notice.php index a704053a0..f7194e339 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -119,6 +119,9 @@ class Notice extends Memcached_DataObject // NOTE: we don't clear queue items $result = parent::delete(); + + $this->blowOnDelete(); + return $result; } /** @@ -421,6 +424,18 @@ class Notice extends Memcached_DataObject $profile->blowNoticeCount(); } + /** + * Clear cache entries related to this notice at delete time. + * Necessary to avoid breaking paging on public, profile timelines. + */ + function blowOnDelete() + { + $this->blowOnInsert(); + + self::blow('profile:notice_ids:%d;last', $this->profile_id); + self::blow('public;last'); + } + /** save all urls in the notice to the db * * follow redirects and save all available file information @@ -589,7 +604,6 @@ class Notice extends Memcached_DataObject array(), 'public', $offset, $limit, $since_id, $max_id); - return Notice::getStreamByIds($ids); } diff --git a/lib/activity.php b/lib/activity.php index 6acf37a8a..ae65fe36f 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -463,7 +463,7 @@ class ActivityUtils $text = $contentEl->textContent; return htmlspecialchars_decode($text, ENT_QUOTES); } else if ($type == 'xhtml') { - $divEl = ActivityUtils::child($contentEl, 'div'); + $divEl = ActivityUtils::child($contentEl, 'div', 'http://www.w3.org/1999/xhtml'); if (empty($divEl)) { return null; } diff --git a/plugins/OStatus/lib/feeddiscovery.php b/plugins/OStatus/lib/feeddiscovery.php index ff76b229e..7761ea583 100644 --- a/plugins/OStatus/lib/feeddiscovery.php +++ b/plugins/OStatus/lib/feeddiscovery.php @@ -211,11 +211,11 @@ class FeedDiscovery $type = $node->attributes->getNamedItem('type'); $href = $node->attributes->getNamedItem('href'); if ($rel && $type && $href) { - $rel = trim($rel->value); + $rel = array_filter(explode(" ", $rel->value)); $type = trim($type->value); $href = trim($href->value); - if (trim($rel) == 'alternate' && array_key_exists($type, $feeds) && empty($feeds[$type])) { + if (in_array('alternate', $rel) && array_key_exists($type, $feeds) && empty($feeds[$type])) { // Save the first feed found of each type... $feeds[$type] = $this->resolveURI($href, $base); } diff --git a/plugins/OStatus/scripts/testfeed.php b/plugins/OStatus/scripts/testfeed.php new file mode 100644 index 000000000..5e3ccd433 --- /dev/null +++ b/plugins/OStatus/scripts/testfeed.php @@ -0,0 +1,89 @@ +#!/usr/bin/env php +<?php +/* + * StatusNet - a distributed open-source microblogging tool + * Copyright (C) 2010, StatusNet, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); + +$longoptions = array('skip=', 'count='); + +$helptext = <<<END_OF_HELP +testfeed.php [options] http://example.com/atom-feed-url +Pull an Atom feed and run items in it as though they were live PuSH updates. +Mainly intended for testing funky feed formats. + + --skip=N Ignore the first N items in the feed. + --count=N Only process up to N items from the feed, after skipping. + + +END_OF_HELP; + +require_once INSTALLDIR.'/scripts/commandline.inc'; + +if (empty($args[0]) || !Validate::uri($args[0])) { + print "$helptext"; + exit(1); +} + +$feedurl = $args[0]; +$skip = have_option('skip') ? intval(get_option_value('skip')) : 0; +$count = have_option('count') ? intval(get_option_value('count')) : 0; + + +$sub = FeedSub::staticGet('topic', $feedurl); +if (!$sub) { + print "Feed $feedurl is not subscribed.\n"; + exit(1); +} + +$xml = file_get_contents($feedurl); +if ($xml === false) { + print "Bad fetch.\n"; + exit(1); +} + +$feed = new DOMDocument(); +if (!$feed->loadXML($xml)) { + print "Bad XML.\n"; + exit(1); +} + +if ($skip || $count) { + $entries = $feed->getElementsByTagNameNS(ActivityUtils::ATOM, 'entry'); + $remove = array(); + for ($i = 0; $i < $skip && $i < $entries->length; $i++) { + $item = $entries->item($i); + if ($item) { + $remove[] = $item; + } + } + if ($count) { + for ($i = $skip + $count; $i < $entries->length; $i++) { + $item = $entries->item($i); + if ($item) { + $remove[] = $item; + } + } + } + foreach ($remove as $item) { + $item->parentNode->removeChild($item); + } +} + +Event::handle('StartFeedSubReceive', array($sub, $feed)); + |