@@ -13,11 +13,11 @@ |
||
13 | 13 | |
14 | 14 | class ClearExpiredIdentificationData extends ConsoleTaskBase |
15 | 15 | { |
16 | - /** |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public function execute() |
|
20 | - { |
|
21 | - IdentificationVerifier::clearExpiredCacheEntries($this->getSiteConfiguration(), $this->getDatabase()); |
|
22 | - } |
|
16 | + /** |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public function execute() |
|
20 | + { |
|
21 | + IdentificationVerifier::clearExpiredCacheEntries($this->getSiteConfiguration(), $this->getDatabase()); |
|
22 | + } |
|
23 | 23 | } |
@@ -12,28 +12,28 @@ |
||
12 | 12 | |
13 | 13 | class OldRequestCleanupTask extends ConsoleTaskBase |
14 | 14 | { |
15 | - private $expiryTime; |
|
15 | + private $expiryTime; |
|
16 | 16 | |
17 | - /** |
|
18 | - * OldRequestCleanupTask constructor. |
|
19 | - */ |
|
20 | - public function __construct() |
|
21 | - { |
|
22 | - $this->expiryTime = $this->getSiteConfiguration()->getEmailConfirmationExpiryDays(); |
|
23 | - } |
|
17 | + /** |
|
18 | + * OldRequestCleanupTask constructor. |
|
19 | + */ |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + $this->expiryTime = $this->getSiteConfiguration()->getEmailConfirmationExpiryDays(); |
|
23 | + } |
|
24 | 24 | |
25 | - public function execute() |
|
26 | - { |
|
27 | - $statement = $this->getDatabase()->prepare(<<<SQL |
|
25 | + public function execute() |
|
26 | + { |
|
27 | + $statement = $this->getDatabase()->prepare(<<<SQL |
|
28 | 28 | DELETE FROM request |
29 | 29 | WHERE |
30 | 30 | date < DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL :expiry DAY) |
31 | 31 | AND emailconfirm != 'Confirmed' |
32 | 32 | AND emailconfirm != ''; |
33 | 33 | SQL |
34 | - ); |
|
34 | + ); |
|
35 | 35 | |
36 | - $statement->bindValue(':expiry', $this->expiryTime); |
|
37 | - $statement->execute(); |
|
38 | - } |
|
36 | + $statement->bindValue(':expiry', $this->expiryTime); |
|
37 | + $statement->execute(); |
|
38 | + } |
|
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -10,8 +10,8 @@ |
||
10 | 10 | |
11 | 11 | class RegexConstants |
12 | 12 | { |
13 | - const IPV6_CIDR = '(?:/(?:12[0-8]|1[01][0-9]|[0-9]{1,2}))?'; |
|
14 | - const IPV4_CIDR = '(?:/(?:32|3[01]|[0-2]?[0-9]))?'; |
|
15 | - const IPV4 = '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'; |
|
16 | - const IPV6 = '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))'; |
|
13 | + const IPV6_CIDR = '(?:/(?:12[0-8]|1[01][0-9]|[0-9]{1,2}))?'; |
|
14 | + const IPV4_CIDR = '(?:/(?:32|3[01]|[0-2]?[0-9]))?'; |
|
15 | + const IPV4 = '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'; |
|
16 | + const IPV6 = '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))'; |
|
17 | 17 | } |
18 | 18 | \ No newline at end of file |
@@ -12,52 +12,52 @@ |
||
12 | 12 | |
13 | 13 | class WikiTextHelper |
14 | 14 | { |
15 | - /** |
|
16 | - * @var SiteConfiguration |
|
17 | - */ |
|
18 | - private $configuration; |
|
19 | - /** |
|
20 | - * @var HttpHelper |
|
21 | - */ |
|
22 | - private $http; |
|
23 | - |
|
24 | - /** |
|
25 | - * WikiTextHelper constructor. |
|
26 | - * |
|
27 | - * @param SiteConfiguration $configuration |
|
28 | - * @param HttpHelper $http |
|
29 | - */ |
|
30 | - public function __construct(SiteConfiguration $configuration, HttpHelper $http) |
|
31 | - { |
|
32 | - $this->configuration = $configuration; |
|
33 | - $this->http = $http; |
|
34 | - } |
|
35 | - |
|
36 | - /** |
|
37 | - * Gets the HTML for the provided wiki-markup from the MediaWiki service endpoint |
|
38 | - * |
|
39 | - * @param string $wikiText |
|
40 | - * |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function getHtmlForWikiText($wikiText) |
|
44 | - { |
|
45 | - $endpoint = $this->configuration->getMediawikiWebServiceEndpoint(); |
|
46 | - |
|
47 | - $parameters = array( |
|
48 | - 'action' => 'parse', |
|
49 | - 'pst' => true, |
|
50 | - 'contentmodel' => 'wikitext', |
|
51 | - 'disablelimitreport' => true, |
|
52 | - 'disabletoc' => true, |
|
53 | - 'disableeditsection' => true, |
|
54 | - 'format' => 'php', |
|
55 | - 'text' => $wikiText, |
|
56 | - ); |
|
57 | - |
|
58 | - $apiResult = $this->http->get($endpoint, $parameters); |
|
59 | - $parseResult = unserialize($apiResult); |
|
60 | - |
|
61 | - return $parseResult['parse']['text']['*']; |
|
62 | - } |
|
15 | + /** |
|
16 | + * @var SiteConfiguration |
|
17 | + */ |
|
18 | + private $configuration; |
|
19 | + /** |
|
20 | + * @var HttpHelper |
|
21 | + */ |
|
22 | + private $http; |
|
23 | + |
|
24 | + /** |
|
25 | + * WikiTextHelper constructor. |
|
26 | + * |
|
27 | + * @param SiteConfiguration $configuration |
|
28 | + * @param HttpHelper $http |
|
29 | + */ |
|
30 | + public function __construct(SiteConfiguration $configuration, HttpHelper $http) |
|
31 | + { |
|
32 | + $this->configuration = $configuration; |
|
33 | + $this->http = $http; |
|
34 | + } |
|
35 | + |
|
36 | + /** |
|
37 | + * Gets the HTML for the provided wiki-markup from the MediaWiki service endpoint |
|
38 | + * |
|
39 | + * @param string $wikiText |
|
40 | + * |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function getHtmlForWikiText($wikiText) |
|
44 | + { |
|
45 | + $endpoint = $this->configuration->getMediawikiWebServiceEndpoint(); |
|
46 | + |
|
47 | + $parameters = array( |
|
48 | + 'action' => 'parse', |
|
49 | + 'pst' => true, |
|
50 | + 'contentmodel' => 'wikitext', |
|
51 | + 'disablelimitreport' => true, |
|
52 | + 'disabletoc' => true, |
|
53 | + 'disableeditsection' => true, |
|
54 | + 'format' => 'php', |
|
55 | + 'text' => $wikiText, |
|
56 | + ); |
|
57 | + |
|
58 | + $apiResult = $this->http->get($endpoint, $parameters); |
|
59 | + $parseResult = unserialize($apiResult); |
|
60 | + |
|
61 | + return $parseResult['parse']['text']['*']; |
|
62 | + } |
|
63 | 63 | } |
64 | 64 | \ No newline at end of file |
@@ -14,49 +14,49 @@ |
||
14 | 14 | |
15 | 15 | class BanHelper implements IBanHelper |
16 | 16 | { |
17 | - /** |
|
18 | - * @var PdoDatabase |
|
19 | - */ |
|
20 | - private $database; |
|
17 | + /** |
|
18 | + * @var PdoDatabase |
|
19 | + */ |
|
20 | + private $database; |
|
21 | 21 | |
22 | - public function __construct(PdoDatabase $database) |
|
23 | - { |
|
24 | - $this->database = $database; |
|
25 | - } |
|
22 | + public function __construct(PdoDatabase $database) |
|
23 | + { |
|
24 | + $this->database = $database; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Summary of nameIsBanned |
|
29 | - * |
|
30 | - * @param string $name The name to test if is banned. |
|
31 | - * |
|
32 | - * @return Ban |
|
33 | - */ |
|
34 | - public function nameIsBanned($name) |
|
35 | - { |
|
36 | - return Ban::getBanByTarget($name, "Name", $this->database); |
|
37 | - } |
|
27 | + /** |
|
28 | + * Summary of nameIsBanned |
|
29 | + * |
|
30 | + * @param string $name The name to test if is banned. |
|
31 | + * |
|
32 | + * @return Ban |
|
33 | + */ |
|
34 | + public function nameIsBanned($name) |
|
35 | + { |
|
36 | + return Ban::getBanByTarget($name, "Name", $this->database); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Summary of emailIsBanned |
|
41 | - * |
|
42 | - * @param string $email |
|
43 | - * |
|
44 | - * @return Ban |
|
45 | - */ |
|
46 | - public function emailIsBanned($email) |
|
47 | - { |
|
48 | - return Ban::getBanByTarget($email, "EMail", $this->database); |
|
49 | - } |
|
39 | + /** |
|
40 | + * Summary of emailIsBanned |
|
41 | + * |
|
42 | + * @param string $email |
|
43 | + * |
|
44 | + * @return Ban |
|
45 | + */ |
|
46 | + public function emailIsBanned($email) |
|
47 | + { |
|
48 | + return Ban::getBanByTarget($email, "EMail", $this->database); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Summary of ipIsBanned |
|
53 | - * |
|
54 | - * @param string $ip |
|
55 | - * |
|
56 | - * @return Ban |
|
57 | - */ |
|
58 | - public function ipIsBanned($ip) |
|
59 | - { |
|
60 | - return Ban::getBanByTarget($ip, "IP", $this->database); |
|
61 | - } |
|
51 | + /** |
|
52 | + * Summary of ipIsBanned |
|
53 | + * |
|
54 | + * @param string $ip |
|
55 | + * |
|
56 | + * @return Ban |
|
57 | + */ |
|
58 | + public function ipIsBanned($ip) |
|
59 | + { |
|
60 | + return Ban::getBanByTarget($ip, "IP", $this->database); |
|
61 | + } |
|
62 | 62 | } |
@@ -12,51 +12,51 @@ |
||
12 | 12 | |
13 | 13 | class TypeAheadHelper implements ITypeAheadHelper |
14 | 14 | { |
15 | - private $definedClasses = array(); |
|
16 | - |
|
17 | - /** |
|
18 | - * @param string $class CSS class to apply this typeahead to. |
|
19 | - * @param callable $generator Generator function taking no arguments to return an array of strings. |
|
20 | - */ |
|
21 | - public function defineTypeAheadSource($class, callable $generator) |
|
22 | - { |
|
23 | - $dataList = ''; |
|
24 | - foreach ($generator() as $dataItem) { |
|
25 | - $dataList .= '"' . htmlentities($dataItem) . '", '; |
|
26 | - } |
|
27 | - $dataList = "[" . rtrim($dataList, ", ") . "]"; |
|
28 | - |
|
29 | - $script = <<<JS |
|
15 | + private $definedClasses = array(); |
|
16 | + |
|
17 | + /** |
|
18 | + * @param string $class CSS class to apply this typeahead to. |
|
19 | + * @param callable $generator Generator function taking no arguments to return an array of strings. |
|
20 | + */ |
|
21 | + public function defineTypeAheadSource($class, callable $generator) |
|
22 | + { |
|
23 | + $dataList = ''; |
|
24 | + foreach ($generator() as $dataItem) { |
|
25 | + $dataList .= '"' . htmlentities($dataItem) . '", '; |
|
26 | + } |
|
27 | + $dataList = "[" . rtrim($dataList, ", ") . "]"; |
|
28 | + |
|
29 | + $script = <<<JS |
|
30 | 30 | $('.{$class}').typeahead({ |
31 | 31 | source: {$dataList} |
32 | 32 | }); |
33 | 33 | JS; |
34 | - $this->definedClasses[$class] = $script; |
|
35 | - } |
|
34 | + $this->definedClasses[$class] = $script; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @return string HTML fragment containing a JS block for typeaheads. |
|
39 | - */ |
|
40 | - public function getTypeAheadScriptBlock() |
|
41 | - { |
|
42 | - $jsBlocks = ''; |
|
37 | + /** |
|
38 | + * @return string HTML fragment containing a JS block for typeaheads. |
|
39 | + */ |
|
40 | + public function getTypeAheadScriptBlock() |
|
41 | + { |
|
42 | + $jsBlocks = ''; |
|
43 | 43 | |
44 | - if (count($this->definedClasses) === 0) { |
|
45 | - return ''; |
|
46 | - } |
|
44 | + if (count($this->definedClasses) === 0) { |
|
45 | + return ''; |
|
46 | + } |
|
47 | 47 | |
48 | - foreach ($this->definedClasses as $class => $js) { |
|
49 | - $jsBlocks = $js . "\r\n\r\n"; |
|
50 | - } |
|
48 | + foreach ($this->definedClasses as $class => $js) { |
|
49 | + $jsBlocks = $js . "\r\n\r\n"; |
|
50 | + } |
|
51 | 51 | |
52 | - $data = <<<HTML |
|
52 | + $data = <<<HTML |
|
53 | 53 | <script type="text/javascript"> |
54 | 54 | {$jsBlocks} |
55 | 55 | </script> |
56 | 56 | HTML; |
57 | 57 | |
58 | - $this->definedClasses = array(); |
|
58 | + $this->definedClasses = array(); |
|
59 | 59 | |
60 | - return $data; |
|
61 | - } |
|
60 | + return $data; |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | \ No newline at end of file |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | { |
23 | 23 | $dataList = ''; |
24 | 24 | foreach ($generator() as $dataItem) { |
25 | - $dataList .= '"' . htmlentities($dataItem) . '", '; |
|
25 | + $dataList .= '"'.htmlentities($dataItem).'", '; |
|
26 | 26 | } |
27 | - $dataList = "[" . rtrim($dataList, ", ") . "]"; |
|
27 | + $dataList = "[".rtrim($dataList, ", ")."]"; |
|
28 | 28 | |
29 | 29 | $script = <<<JS |
30 | 30 | $('.{$class}').typeahead({ |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | foreach ($this->definedClasses as $class => $js) { |
49 | - $jsBlocks = $js . "\r\n\r\n"; |
|
49 | + $jsBlocks = $js."\r\n\r\n"; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $data = <<<HTML |
@@ -13,53 +13,53 @@ |
||
13 | 13 | */ |
14 | 14 | class DebugHelper |
15 | 15 | { |
16 | - /** |
|
17 | - * Internal mockable method wrapper for debug_backtrace. |
|
18 | - * |
|
19 | - * As mocking out debug_backtrace uses debug_backtrace internally, we need this in order to not cause a recursive |
|
20 | - * cascade until the runtime explodes. |
|
21 | - * |
|
22 | - * Instead, we mock this method, which allows debug_backtrace to still be called correctly. |
|
23 | - * |
|
24 | - * @return array |
|
25 | - */ |
|
26 | - public function get_debug_backtrace() |
|
27 | - { |
|
28 | - return debug_backtrace(); |
|
29 | - } |
|
16 | + /** |
|
17 | + * Internal mockable method wrapper for debug_backtrace. |
|
18 | + * |
|
19 | + * As mocking out debug_backtrace uses debug_backtrace internally, we need this in order to not cause a recursive |
|
20 | + * cascade until the runtime explodes. |
|
21 | + * |
|
22 | + * Instead, we mock this method, which allows debug_backtrace to still be called correctly. |
|
23 | + * |
|
24 | + * @return array |
|
25 | + */ |
|
26 | + public function get_debug_backtrace() |
|
27 | + { |
|
28 | + return debug_backtrace(); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Returns a string representation of the current backtrace for display. |
|
33 | - * |
|
34 | - * Note that this explicitly excludes the top two frames, which will be methods from this class. |
|
35 | - * |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function getBacktrace() |
|
39 | - { |
|
40 | - $backtrace = $this->get_debug_backtrace(); |
|
31 | + /** |
|
32 | + * Returns a string representation of the current backtrace for display. |
|
33 | + * |
|
34 | + * Note that this explicitly excludes the top two frames, which will be methods from this class. |
|
35 | + * |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function getBacktrace() |
|
39 | + { |
|
40 | + $backtrace = $this->get_debug_backtrace(); |
|
41 | 41 | |
42 | - $output = ""; |
|
42 | + $output = ""; |
|
43 | 43 | |
44 | - $count = 0; |
|
45 | - foreach ($backtrace as $line) { |
|
46 | - if ($count <= 1) { |
|
47 | - $count++; |
|
48 | - continue; |
|
49 | - } |
|
44 | + $count = 0; |
|
45 | + foreach ($backtrace as $line) { |
|
46 | + if ($count <= 1) { |
|
47 | + $count++; |
|
48 | + continue; |
|
49 | + } |
|
50 | 50 | |
51 | - $output .= "#{$count}: "; |
|
51 | + $output .= "#{$count}: "; |
|
52 | 52 | |
53 | - if (isset($line['type']) && $line['type'] != "") { |
|
54 | - $output .= $line['class'] . $line['type']; |
|
55 | - } |
|
53 | + if (isset($line['type']) && $line['type'] != "") { |
|
54 | + $output .= $line['class'] . $line['type']; |
|
55 | + } |
|
56 | 56 | |
57 | - $output .= $line['function'] . "(...)"; |
|
58 | - $output .= " [{$line['file']}#{$line['line']}\r\n"; |
|
57 | + $output .= $line['function'] . "(...)"; |
|
58 | + $output .= " [{$line['file']}#{$line['line']}\r\n"; |
|
59 | 59 | |
60 | - $count++; |
|
61 | - } |
|
60 | + $count++; |
|
61 | + } |
|
62 | 62 | |
63 | - return $output; |
|
64 | - } |
|
63 | + return $output; |
|
64 | + } |
|
65 | 65 | } |
@@ -51,10 +51,10 @@ |
||
51 | 51 | $output .= "#{$count}: "; |
52 | 52 | |
53 | 53 | if (isset($line['type']) && $line['type'] != "") { |
54 | - $output .= $line['class'] . $line['type']; |
|
54 | + $output .= $line['class'].$line['type']; |
|
55 | 55 | } |
56 | 56 | |
57 | - $output .= $line['function'] . "(...)"; |
|
57 | + $output .= $line['function']."(...)"; |
|
58 | 58 | $output .= " [{$line['file']}#{$line['line']}\r\n"; |
59 | 59 | |
60 | 60 | $count++; |
@@ -13,91 +13,91 @@ |
||
13 | 13 | |
14 | 14 | class BlacklistHelper implements IBlacklistHelper |
15 | 15 | { |
16 | - /** @var HttpHelper */ |
|
17 | - private $httpHelper; |
|
18 | - /** |
|
19 | - * Cache of previously requested usernames |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - private $cache = array(); |
|
23 | - /** @var string */ |
|
24 | - private $mediawikiWebServiceEndpoint; |
|
16 | + /** @var HttpHelper */ |
|
17 | + private $httpHelper; |
|
18 | + /** |
|
19 | + * Cache of previously requested usernames |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + private $cache = array(); |
|
23 | + /** @var string */ |
|
24 | + private $mediawikiWebServiceEndpoint; |
|
25 | 25 | |
26 | - /** |
|
27 | - * BlacklistHelper constructor. |
|
28 | - * |
|
29 | - * @param HttpHelper $httpHelper |
|
30 | - * @param string $mediawikiWebServiceEndpoint |
|
31 | - */ |
|
32 | - public function __construct(HttpHelper $httpHelper, $mediawikiWebServiceEndpoint) |
|
33 | - { |
|
34 | - $this->httpHelper = $httpHelper; |
|
35 | - $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint; |
|
36 | - } |
|
26 | + /** |
|
27 | + * BlacklistHelper constructor. |
|
28 | + * |
|
29 | + * @param HttpHelper $httpHelper |
|
30 | + * @param string $mediawikiWebServiceEndpoint |
|
31 | + */ |
|
32 | + public function __construct(HttpHelper $httpHelper, $mediawikiWebServiceEndpoint) |
|
33 | + { |
|
34 | + $this->httpHelper = $httpHelper; |
|
35 | + $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
40 | - * |
|
41 | - * @param string $username |
|
42 | - * |
|
43 | - * @return false|string False if the username is not blacklisted, else the blacklist entry. |
|
44 | - */ |
|
45 | - public function isBlacklisted($username) |
|
46 | - { |
|
47 | - if (isset($this->cache[$username])) { |
|
48 | - $result = $this->cache[$username]; |
|
49 | - if ($result === false) { |
|
50 | - return false; |
|
51 | - } |
|
38 | + /** |
|
39 | + * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
40 | + * |
|
41 | + * @param string $username |
|
42 | + * |
|
43 | + * @return false|string False if the username is not blacklisted, else the blacklist entry. |
|
44 | + */ |
|
45 | + public function isBlacklisted($username) |
|
46 | + { |
|
47 | + if (isset($this->cache[$username])) { |
|
48 | + $result = $this->cache[$username]; |
|
49 | + if ($result === false) { |
|
50 | + return false; |
|
51 | + } |
|
52 | 52 | |
53 | - return $result['line']; |
|
54 | - } |
|
53 | + return $result['line']; |
|
54 | + } |
|
55 | 55 | |
56 | - try { |
|
57 | - $result = $this->performWikiLookup($username); |
|
58 | - } |
|
59 | - catch (CurlException $ex) { |
|
60 | - // LOGME log this, but fail gracefully. |
|
61 | - return false; |
|
62 | - } |
|
56 | + try { |
|
57 | + $result = $this->performWikiLookup($username); |
|
58 | + } |
|
59 | + catch (CurlException $ex) { |
|
60 | + // LOGME log this, but fail gracefully. |
|
61 | + return false; |
|
62 | + } |
|
63 | 63 | |
64 | - if ($result['result'] === 'ok') { |
|
65 | - // not blacklisted |
|
66 | - $this->cache[$username] = false; |
|
64 | + if ($result['result'] === 'ok') { |
|
65 | + // not blacklisted |
|
66 | + $this->cache[$username] = false; |
|
67 | 67 | |
68 | - return false; |
|
69 | - } |
|
70 | - else { |
|
71 | - $this->cache[$username] = $result; |
|
68 | + return false; |
|
69 | + } |
|
70 | + else { |
|
71 | + $this->cache[$username] = $result; |
|
72 | 72 | |
73 | - return $result['line']; |
|
74 | - } |
|
75 | - } |
|
73 | + return $result['line']; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Performs a fetch to MediaWiki for the relevant title blacklist entry |
|
79 | - * |
|
80 | - * @param string $username The username to look up |
|
81 | - * |
|
82 | - * @return array |
|
83 | - * @throws CurlException |
|
84 | - */ |
|
85 | - private function performWikiLookup($username) |
|
86 | - { |
|
87 | - $endpoint = $this->mediawikiWebServiceEndpoint; |
|
77 | + /** |
|
78 | + * Performs a fetch to MediaWiki for the relevant title blacklist entry |
|
79 | + * |
|
80 | + * @param string $username The username to look up |
|
81 | + * |
|
82 | + * @return array |
|
83 | + * @throws CurlException |
|
84 | + */ |
|
85 | + private function performWikiLookup($username) |
|
86 | + { |
|
87 | + $endpoint = $this->mediawikiWebServiceEndpoint; |
|
88 | 88 | |
89 | - $parameters = array( |
|
90 | - 'action' => 'titleblacklist', |
|
91 | - 'format' => 'php', |
|
92 | - 'tbtitle' => $username, |
|
93 | - 'tbaction' => 'new-account', |
|
94 | - 'tbnooverride' => true, |
|
95 | - ); |
|
89 | + $parameters = array( |
|
90 | + 'action' => 'titleblacklist', |
|
91 | + 'format' => 'php', |
|
92 | + 'tbtitle' => $username, |
|
93 | + 'tbaction' => 'new-account', |
|
94 | + 'tbnooverride' => true, |
|
95 | + ); |
|
96 | 96 | |
97 | - $apiResult = $this->httpHelper->get($endpoint, $parameters); |
|
97 | + $apiResult = $this->httpHelper->get($endpoint, $parameters); |
|
98 | 98 | |
99 | - $data = unserialize($apiResult); |
|
99 | + $data = unserialize($apiResult); |
|
100 | 100 | |
101 | - return $data['titleblacklist']; |
|
102 | - } |
|
101 | + return $data['titleblacklist']; |
|
102 | + } |
|
103 | 103 | } |
104 | 104 | \ No newline at end of file |
@@ -12,16 +12,16 @@ |
||
12 | 12 | |
13 | 13 | class FakeBlacklistHelper implements IBlacklistHelper |
14 | 14 | { |
15 | - /** |
|
16 | - * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
17 | - * |
|
18 | - * @param string $username |
|
19 | - * |
|
20 | - * @return bool |
|
21 | - */ |
|
22 | - public function isBlacklisted($username) |
|
23 | - { |
|
24 | - // Short-circuit |
|
25 | - return false; |
|
26 | - } |
|
15 | + /** |
|
16 | + * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
17 | + * |
|
18 | + * @param string $username |
|
19 | + * |
|
20 | + * @return bool |
|
21 | + */ |
|
22 | + public function isBlacklisted($username) |
|
23 | + { |
|
24 | + // Short-circuit |
|
25 | + return false; |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | \ No newline at end of file |