This repository was archived by the owner on Mar 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 20
20
21
21
namespace WildPHP \Modules \LinkSniffer ;
22
22
23
- use GuzzleHttp \Exception \ClientException ;
23
+ use GuzzleHttp \Exception \GuzzleException ;
24
24
use WildPHP \API \ShortenUri ;
25
25
use WildPHP \BaseModule ;
26
26
use WildPHP \CoreModules \Connection \IrcDataObject ;
@@ -64,10 +64,8 @@ public function sniffLinks(IrcDataObject $message)
64
64
{
65
65
try
66
66
{
67
- $ content_type = SnifferHelper::getContentTypeFromUri ($ uri );
68
-
69
67
$ shortUri = $ this ->createShortUri ($ uri );
70
-
68
+ $ content_type = SnifferHelper:: getContentTypeFromUri ( $ uri );
71
69
$ title = '(not a web page, content type: ' . $ content_type . ') ' ;
72
70
73
71
if ($ content_type == 'text/html ' )
@@ -84,10 +82,10 @@ public function sniffLinks(IrcDataObject $message)
84
82
return ;
85
83
}
86
84
87
- // ClientExceptions can be thrown by Guzzle. If one occurs, just give up .
88
- catch (ClientException $ e )
85
+ // Guzzle exceptions (such as connection timeouts) should be ignored .
86
+ catch (GuzzleException $ e )
89
87
{
90
- return ;
88
+ $ title = ' (link was unresponsive: ' . $ uri . ' ) ' ;
91
89
}
92
90
93
91
if (!empty ($ title ) && !empty ($ shortUri ))
Original file line number Diff line number Diff line change @@ -31,13 +31,13 @@ public function testAddEntry()
31
31
$ uriCache = new UriCache ();
32
32
33
33
$ uriCache ->addCacheItem ('googleUri ' , 'Google ' );
34
+
34
35
$ checkObject = new CacheItem ();
35
36
$ checkObject ->setTitle ('Google ' );
36
- $ checkObject ->setExpireTime (time () + 60 * 60 );
37
37
38
38
$ retrieved = $ uriCache ->getCacheItem ('googleUri ' );
39
39
40
- $ this ->assertEquals ($ checkObject , $ retrieved );
40
+ $ this ->assertSame ($ checkObject , $ retrieved );
41
41
}
42
42
43
43
public function testRemoveItem ()
You can’t perform that action at this time.
0 commit comments