summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Auth/OpenID/Discover.php24
-rw-r--r--Services/Yadis/Yadis.php25
-rw-r--r--Tests/Auth/OpenID/Discover_OpenID.php5
3 files changed, 32 insertions, 22 deletions
diff --git a/Auth/OpenID/Discover.php b/Auth/OpenID/Discover.php
index 1668a10..c19cf09 100644
--- a/Auth/OpenID/Discover.php
+++ b/Auth/OpenID/Discover.php
@@ -97,8 +97,9 @@ class Auth_OpenID_ServiceEndpoint {
if (!$this->isOPIdentifier()) {
$this->claimed_id = $yadis_url;
- $this->local_id = Auth_OpenID_findOPLocalIdentifier($service_element,
- $this->type_uris);
+ $this->local_id = Auth_OpenID_findOPLocalIdentifier(
+ $service_element,
+ $this->type_uris);
if ($this->local_id === false) {
return false;
}
@@ -329,18 +330,25 @@ function Auth_OpenID_discoverWithYadis($uri, &$fetcher)
$fetcher);
$yadis_services = array();
- $identity_url = null;
+ $identity_url = $uri;
if ($response) {
$identity_url = $response->uri;
- $yadis_services =
- $response->xrds->services(array('filter_MatchesAnyOpenIDType'));
+
+ if ($response->xrds) {
+ $yadis_services =
+ $response->xrds->services(
+ array('filter_MatchesAnyOpenIDType'));
+ }
}
if (!$yadis_services) {
- if (Services_Yadis_XRDS::parseXRDS($response->body) !== null) {
+ if ($response &&
+ Services_Yadis_XRDS::parseXRDS($response->body) !== null) {
return @Auth_OpenID_discoverWithoutYadis($uri,
$fetcher);
+ } else if (!$response) {
+ return array($uri, array(), null);
}
// Try to parse the response as HTML to get OpenID 1.0/1.1
@@ -354,7 +362,7 @@ function Auth_OpenID_discoverWithYadis($uri, &$fetcher)
}
$openid_services = Auth_OpenID_getOPOrUserServices($openid_services);
- return array($identity_url, $openid_services, $http_response);
+ return array($identity_url, $openid_services, $response);
}
function _Auth_OpenID_discoverServiceList($uri, &$fetcher)
@@ -415,7 +423,7 @@ function _Auth_OpenID_discoverXRI($iname, &$fetcher)
function Auth_OpenID_discover($uri, &$fetcher)
{
- return @Auth_OpenID_discoverWithYadis($uri, $fetcher);
+ return Auth_OpenID_discoverWithYadis($uri, $fetcher);
}
?> \ No newline at end of file
diff --git a/Services/Yadis/Yadis.php b/Services/Yadis/Yadis.php
index 338bb3a..d565889 100644
--- a/Services/Yadis/Yadis.php
+++ b/Services/Yadis/Yadis.php
@@ -207,7 +207,7 @@ class Services_Yadis_Yadis {
}
if ($response->status != 200) {
- return null;
+ return null;
}
$xrds_uri = $response->final_url;
@@ -245,7 +245,7 @@ class Services_Yadis_Yadis {
if ($new_uri) {
$response = $fetcher->get($new_uri);
if ($response->status != 200) {
- return null;
+ return null;
}
$http_response = $response;
$body = $response->body;
@@ -258,20 +258,21 @@ class Services_Yadis_Yadis {
$xrds = Services_Yadis_XRDS::parseXRDS($body, $extra_ns_map);
- if ($xrds !== null) {
- $y = new Services_Yadis_Yadis();
+ $y = new Services_Yadis_Yadis();
- $y->request_uri = $request_uri;
+ $y->request_uri = $request_uri;
+ $y->xrds = null;
+ $y->xrds_uri = null;
+ $y->uri = $uri;
+ $y->body = $body;
+ $y->content_type = $content_type;
+
+ if ($xrds !== null) {
$y->xrds = $xrds;
- $y->uri = $uri;
$y->xrds_uri = $xrds_uri;
- $y->body = $body;
- $y->content_type = $content_type;
-
- return $y;
- } else {
- return null;
}
+
+ return $y;
}
/**
diff --git a/Tests/Auth/OpenID/Discover_OpenID.php b/Tests/Auth/OpenID/Discover_OpenID.php
index 40bc04d..c9857cf 100644
--- a/Tests/Auth/OpenID/Discover_OpenID.php
+++ b/Tests/Auth/OpenID/Discover_OpenID.php
@@ -392,8 +392,9 @@ class Tests_Auth_OpenID_Discover_OpenID extends _DiscoveryBase {
list($id_url, $svclist, $http_response) = $result;
- $this->assertTrue($http_response->status == 404,
- "Expected 404 status from /404 discovery");
+ $this->assertTrue($http_response === null);
+ $this->assertTrue($svclist == array());
+ $this->assertTrue($id_url == $this->id_url . '/404');
}
function test_noYadis()