summaryrefslogtreecommitdiff
path: root/plugins/OStatus/lib/linkheader.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-03-18 17:08:19 -0700
committerBrion Vibber <brion@pobox.com>2010-03-18 17:08:19 -0700
commit1301877dfe89c57c182246c0d7ba0ff6335fd17b (patch)
treef2945952dbecefae0dc486a25f2529f589cf38df /plugins/OStatus/lib/linkheader.php
parent26ba430ae8163089c4a1d0aee5d5f21bb0dbf96f (diff)
OStatus discover fixes:
* Subscription::start was sometimes passing users instead of profiles to hooks, which broke OStatus subscription notifications; now normalizing to profiles for processing. * H-card parsing would trigger a lot of PHP warnings and notices in hKit. Now suppressing warnings and notices for the duration of the call to keep them out of output when display_errors is on. * H-card parsing would trigger a PHP fatal error if the source page was not well-formed XML and Tidy was not present on the system. Switched normalization to use the PHP DOM module which is always present, as we have no need for Tidy's extra features here. * Trying to fetch avatars from Google profiles failed and triggered a PHP warning due to the relative URL not being resolved during h-card parsing. Now passing profile page URL into hKit by sneaking a <base> tag in while we normalize the HTML source. * Profile pages without a "Link" header could trigger PHP notices due to a bad NULL -> array(NULL) conversion in LinkHeader::getLink(). Now checking that there was a return value before converting single return value into array.
Diffstat (limited to 'plugins/OStatus/lib/linkheader.php')
-rw-r--r--plugins/OStatus/lib/linkheader.php24
1 files changed, 12 insertions, 12 deletions
diff --git a/plugins/OStatus/lib/linkheader.php b/plugins/OStatus/lib/linkheader.php
index 2f6c66dc9..afcd66d26 100644
--- a/plugins/OStatus/lib/linkheader.php
+++ b/plugins/OStatus/lib/linkheader.php
@@ -43,21 +43,21 @@ class LinkHeader
static function getLink($response, $rel=null, $type=null)
{
$headers = $response->getHeader('Link');
+ if ($headers) {
+ // Can get an array or string, so try to simplify the path
+ if (!is_array($headers)) {
+ $headers = array($headers);
+ }
- // Can get an array or string, so try to simplify the path
- if (!is_array($headers)) {
- $headers = array($headers);
- }
-
- foreach ($headers as $header) {
- $lh = new LinkHeader($header);
+ foreach ($headers as $header) {
+ $lh = new LinkHeader($header);
- if ((is_null($rel) || $lh->rel == $rel) &&
- (is_null($type) || $lh->type == $type)) {
- return $lh->href;
+ if ((is_null($rel) || $lh->rel == $rel) &&
+ (is_null($type) || $lh->type == $type)) {
+ return $lh->href;
+ }
}
}
-
return null;
}
-} \ No newline at end of file
+}