@@ -166,7 +166,8 @@ |
||
| 166 | 166 | $success = send_template_email($d, $m, true); |
| 167 | 167 | mlog("sent ... "); |
| 168 | 168 | # sleep if time between sending mails is less than a certain number of seconds on average |
| 169 | - if (((time() - $start_time) / $sentemails) < 0.5) { # number of seconds per mail not to be quicker than |
|
| 169 | + if (((time() - $start_time) / $sentemails) < 0.5) { |
|
| 170 | +# number of seconds per mail not to be quicker than |
|
| 170 | 171 | mlog("pausing ... "); |
| 171 | 172 | sleep(1); |
| 172 | 173 | } |
@@ -154,7 +154,7 @@ |
||
| 154 | 154 | global $globalsuccess, $sentemails, $nomail, $start_time; |
| 155 | 155 | |
| 156 | 156 | $sentemails++; |
| 157 | - mlog("SEND $sentemails : Sending email to $current[email] ... "); |
|
| 157 | + mlog("send $sentemails : Sending email to $current[email] ... "); |
|
| 158 | 158 | $d = ['to' => $current['email'], 'template' => $template]; |
| 159 | 159 | $m = [ |
| 160 | 160 | 'DATA' => join("\n", $data), |
@@ -106,7 +106,8 @@ |
||
| 106 | 106 | // Write the text to the file... |
| 107 | 107 | $filename = $rsspath . $person_id . '.rdf'; |
| 108 | 108 | $fh = @fopen($filename, "w"); |
| 109 | - if (!$fh) { # Problem writing, just carry on |
|
| 109 | + if (!$fh) { |
|
| 110 | +# Problem writing, just carry on |
|
| 110 | 111 | echo "Could not write to file ($filename)\n"; |
| 111 | 112 | continue; |
| 112 | 113 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | foreach ($q as $person) { |
| 25 | 25 | $person_id = $person['person_id']; |
| 26 | 26 | |
| 27 | - $args = [ 'person_id' => $person_id ]; |
|
| 27 | + $args = ['person_id' => $person_id]; |
|
| 28 | 28 | $speeches = $HANSARDLIST->display('person', $args, 'none'); |
| 29 | 29 | |
| 30 | 30 | // Some data about this person that we'll need for the feed. |
@@ -16,20 +16,20 @@ discard block |
||
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public function testQueenie() { |
| 19 | - $page = $this->fetch_page([ 'representative_type' => 'royal', 'n' => 'elizabeth_the_second' ]); |
|
| 19 | + $page = $this->fetch_page(['representative_type' => 'royal', 'n' => 'elizabeth_the_second']); |
|
| 20 | 20 | $this->assertStringContainsString('Elizabeth the Second', $page); |
| 21 | 21 | $this->assertStringContainsString('Coronated on 2 June 1953', $page); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function testSittingMP() { |
| 25 | - $page = $this->fetch_page([ 'pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency' ]); |
|
| 25 | + $page = $this->fetch_page(['pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency']); |
|
| 26 | 26 | $this->assertStringContainsString('Test Current-MP', $page); |
| 27 | 27 | $this->assertMatchesRegularExpression('#<span class="person-header__about__position__constituency">\s*Test Westminster Constituency\s*</span>#', $page); |
| 28 | 28 | $this->assertMatchesRegularExpression('#<span class="person-header__about__position__role">\s*Labour\s*MP\s*</span>#', $page); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public function testSittingMLA() { |
| 32 | - $page = $this->fetch_page([ 'pid' => 4, 'representative_type' => 'mla', 'url' => '/mp/4/test_current-mla' ]); |
|
| 32 | + $page = $this->fetch_page(['pid' => 4, 'representative_type' => 'mla', 'url' => '/mp/4/test_current-mla']); |
|
| 33 | 33 | $this->assertStringContainsString('Test Current-MLA', $page); |
| 34 | 34 | $this->assertMatchesRegularExpression('#<span class="person-header__about__position__constituency">\s*Test Northern Ireland Constituency\s*</span>#', $page); |
| 35 | 35 | $this->assertMatchesRegularExpression('#<span class="person-header__about__position__role">\s*Sinn Féin\s*MLA\s*</span>#', $page); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * Ensure that the Sinn Fein message is displayed for SF MPs. |
| 40 | 40 | */ |
| 41 | 41 | public function testSittingSinnFeinMP() { |
| 42 | - $page = $this->fetch_page([ 'pid' => 15, 'url' => '/mp/15/test_current-sf-mp/test_westminster_constituency' ]); |
|
| 42 | + $page = $this->fetch_page(['pid' => 15, 'url' => '/mp/15/test_current-sf-mp/test_westminster_constituency']); |
|
| 43 | 43 | $this->assertStringContainsString('Sinn Féin MPs do not take their seats in Parliament.', $page); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * Ensure that the Sinn Fein message is not displayed for non-SF MPs. |
| 48 | 48 | */ |
| 49 | 49 | public function testSittingNonSinnFeinMP() { |
| 50 | - $page = $this->fetch_page([ 'pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency' ]); |
|
| 50 | + $page = $this->fetch_page(['pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency']); |
|
| 51 | 51 | $this->assertStringNotContainsString('Sinn Féin MPs do not take their seats in Parliament.', $page); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * Ensure that the Speaker is given the correct constituency. |
| 56 | 56 | */ |
| 57 | 57 | public function testSpeaker() { |
| 58 | - $page = $this->fetch_page([ 'pid' => 13, 'url' => '/mp/13/test_speaker/buckingham' ]); |
|
| 58 | + $page = $this->fetch_page(['pid' => 13, 'url' => '/mp/13/test_speaker/buckingham']); |
|
| 59 | 59 | $this->assertMatchesRegularExpression('#<span class="person-header__about__position__role">\s*Speaker\s*MP\s*</span>#', $page); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | # makes sure it is empty in case there's something hanging |
| 66 | 66 | # about in memcached |
| 67 | 67 | $banner->set_text('', "banner"); |
| 68 | - $page = $this->fetch_page([ 'url' => '/' ]); |
|
| 68 | + $page = $this->fetch_page(['url' => '/']); |
|
| 69 | 69 | $this->assertStringNotContainsString('<div class="banner">', $page); |
| 70 | 70 | $this->assertStringNotContainsString('This is a banner', $page); |
| 71 | 71 | |
@@ -85,20 +85,20 @@ discard block |
||
| 85 | 85 | '; |
| 86 | 86 | |
| 87 | 87 | $banner->set_text($banner_config, "banner"); |
| 88 | - $page = $this->fetch_page([ 'url' => '/' ]); |
|
| 88 | + $page = $this->fetch_page(['url' => '/']); |
|
| 89 | 89 | $this->assertStringContainsString('This is a banner', $page); |
| 90 | 90 | |
| 91 | 91 | $banner->set_text('', "banner"); |
| 92 | - $page = $this->fetch_page([ 'url' => '/' ]); |
|
| 92 | + $page = $this->fetch_page(['url' => '/']); |
|
| 93 | 93 | $this->assertStringNotContainsString('<div class="banner">', $page); |
| 94 | 94 | $this->assertStringNotContainsString('This is a banner', $page); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function testNewMPMessage() { |
| 98 | - $page = $this->fetch_page([ 'pid' => 17, 'url' => '/mp/17/recent_mp/test_westminster_constituency' ]); |
|
| 98 | + $page = $this->fetch_page(['pid' => 17, 'url' => '/mp/17/recent_mp/test_westminster_constituency']); |
|
| 99 | 99 | $this->assertStringNotContainsString('is a recently elected MP', $page); |
| 100 | 100 | self::$db->query('UPDATE member SET entered_house = NOW() WHERE person_id = 17'); |
| 101 | - $page = $this->fetch_page([ 'pid' => 17, 'url' => '/mp/17/recent_mp/test_westminster_constituency' ]); |
|
| 101 | + $page = $this->fetch_page(['pid' => 17, 'url' => '/mp/17/recent_mp/test_westminster_constituency']); |
|
| 102 | 102 | $this->assertStringContainsString('is a recently elected MP', $page); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public function testConstituencySearch() { |
| 23 | 23 | $this->assertEquals( |
| 24 | - [ [ 'Alyn and Deeside' ], false ], |
|
| 24 | + [['Alyn and Deeside'], false], |
|
| 25 | 25 | \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery('Alyn') |
| 26 | 26 | ); |
| 27 | 27 | $this->assertEquals( |
| 28 | - [ [ 'Alyn and Deeside' ], false ], |
|
| 28 | + [['Alyn and Deeside'], false], |
|
| 29 | 29 | \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery('Alyn and Deeside') |
| 30 | 30 | ); |
| 31 | 31 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @group xapian |
| 110 | 110 | */ |
| 111 | 111 | public function testSearchPage() { |
| 112 | - $page = $this->fetch_page([ ]); |
|
| 112 | + $page = $this->fetch_page([]); |
|
| 113 | 113 | $this->assertStringContainsString('Search', $page); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @group xapian |
| 120 | 120 | */ |
| 121 | 121 | public function testSearchPageMP() { |
| 122 | - $page = $this->fetch_page([ 'q' => 'Mary Smith' ]); |
|
| 122 | + $page = $this->fetch_page(['q' => 'Mary Smith']); |
|
| 123 | 123 | $this->assertStringContainsString('Mary Smith', $page); |
| 124 | 124 | $this->assertStringContainsString('MP, Amber Valley', $page); |
| 125 | 125 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @group xapian |
| 131 | 131 | */ |
| 132 | 132 | public function testSearchPageMultipleMP() { |
| 133 | - $page = $this->fetch_page([ 'q' => 'Jones' ]); |
|
| 133 | + $page = $this->fetch_page(['q' => 'Jones']); |
|
| 134 | 134 | $this->assertStringContainsString('People matching <em class="current-search-term">Jones</em>', $page); |
| 135 | 135 | $this->assertStringContainsString('Andrew Jones', $page); |
| 136 | 136 | $this->assertStringContainsString('Simon Jones', $page); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @group xapian |
| 143 | 143 | */ |
| 144 | 144 | public function testSearchPageCons() { |
| 145 | - $page = $this->fetch_page([ 'q' => 'Amber' ]); |
|
| 145 | + $page = $this->fetch_page(['q' => 'Amber']); |
|
| 146 | 146 | $this->assertStringContainsString('MP for <em class="current-search-term">Amber</em>', $page); |
| 147 | 147 | $this->assertStringContainsString('Mary Smith', $page); |
| 148 | 148 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @group xapian |
| 155 | 155 | */ |
| 156 | 156 | public function testSearchPageConsWithNoMp() { |
| 157 | - $page = $this->fetch_page([ 'q' => 'Alyn' ]); |
|
| 157 | + $page = $this->fetch_page(['q' => 'Alyn']); |
|
| 158 | 158 | $this->assertStringNotContainsString('MP for <em class="current-search-term">Alyn</em>', $page); |
| 159 | 159 | $this->assertStringNotContainsString('MPs in constituencies matching', $page); |
| 160 | 160 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @group xapian |
| 167 | 167 | */ |
| 168 | 168 | public function testSearchPageMultipleCons() { |
| 169 | - $page = $this->fetch_page([ 'q' => 'Liverpool' ]); |
|
| 169 | + $page = $this->fetch_page(['q' => 'Liverpool']); |
|
| 170 | 170 | $this->assertStringContainsString('MPs in constituencies matching <em class="current-search-term">Liverpool</em>', $page); |
| 171 | 171 | $this->assertStringContainsString('Susan Brown', $page); |
| 172 | 172 | $this->assertStringContainsString('MP, Liverpool, Riverside', $page); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @group xapian |
| 181 | 181 | */ |
| 182 | 182 | public function testSearchPageGlossary() { |
| 183 | - $page = $this->fetch_page([ 'q' => 'other place' ]); |
|
| 183 | + $page = $this->fetch_page(['q' => 'other place']); |
|
| 184 | 184 | $this->assertStringContainsString('Glossary items matching', $page); |
| 185 | 185 | $this->assertStringContainsString('<a href="/glossary/?gl=1">“other place', $page); |
| 186 | 186 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * @group xapian |
| 192 | 192 | */ |
| 193 | 193 | public function testSearchPageSpellCorrect() { |
| 194 | - $page = $this->fetch_page([ 'q' => 'plice' ]); |
|
| 194 | + $page = $this->fetch_page(['q' => 'plice']); |
|
| 195 | 195 | $this->assertStringContainsString('Did you mean <a href="/search/?q=place">place', $page); |
| 196 | 196 | } |
| 197 | 197 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @group xapian |
| 202 | 202 | */ |
| 203 | 203 | public function testSearchBySpeakerNoResults() { |
| 204 | - $page = $this->fetch_page([ 'q' => 'splice', 'o' => 'p' ]); |
|
| 204 | + $page = $this->fetch_page(['q' => 'splice', 'o' => 'p']); |
|
| 205 | 205 | $this->assertStringContainsString('Who says splice the most', $page); |
| 206 | 206 | $this->assertStringContainsString('No results', $page); |
| 207 | 207 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * @group xapian |
| 229 | 229 | */ |
| 230 | 230 | public function testSearchPageRSS() { |
| 231 | - $page = $this->fetch_page([ 'q' => 'test' ]); |
|
| 231 | + $page = $this->fetch_page(['q' => 'test']); |
|
| 232 | 232 | $this->assertStringContainsString('<a href="/search/rss/?s=test">get an RSS feed', $page); |
| 233 | 233 | } |
| 234 | 234 | |
@@ -21,31 +21,31 @@ |
||
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function testKeywordOnly() { |
| 24 | - $page = $this->fetch_page([ 'alertsearch' => 'elephant']); |
|
| 24 | + $page = $this->fetch_page(['alertsearch' => 'elephant']); |
|
| 25 | 25 | $this->assertStringContainsString('Receive alerts when [elephant] is mentioned', $page); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public function testPostCodeOnly() { |
| 29 | - $page = $this->fetch_page([ 'alertsearch' => 'SE17 3HE']); |
|
| 29 | + $page = $this->fetch_page(['alertsearch' => 'SE17 3HE']); |
|
| 30 | 30 | $this->assertStringContainsString('when Mrs Test Current-MP', $page); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function testPostCodeWithKeyWord() { |
| 34 | - $page = $this->fetch_page([ 'alertsearch' => 'SE17 3HE elephant']); |
|
| 34 | + $page = $this->fetch_page(['alertsearch' => 'SE17 3HE elephant']); |
|
| 35 | 35 | $this->assertStringContainsString('You have used a postcode and something else', $page); |
| 36 | 36 | $this->assertStringContainsString('Mentions of [elephant] by your MP, Mrs Test Current-MP', $page); |
| 37 | 37 | $this->assertStringNotContainsString('by your MSP', $page); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function testScottishPostcodeWithKeyword() { |
| 41 | - $page = $this->fetch_page([ 'alertsearch' => 'PH6 2DB elephant']); |
|
| 41 | + $page = $this->fetch_page(['alertsearch' => 'PH6 2DB elephant']); |
|
| 42 | 42 | $this->assertStringContainsString('You have used a postcode and something else', $page); |
| 43 | 43 | $this->assertStringContainsString('Mentions of [elephant] by your MP, Mr Test2 Current-MP', $page); |
| 44 | 44 | $this->assertStringContainsString('Mentions of [elephant] by your MSP, Mrs Test Current-MSP', $page); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public function testPostcodeAndKeywordWithNoSittingMP() { |
| 48 | - $page = $this->fetch_page([ 'alertsearch' => 'OX1 4LF elephant']); |
|
| 48 | + $page = $this->fetch_page(['alertsearch' => 'OX1 4LF elephant']); |
|
| 49 | 49 | $this->assertStringContainsString('You have used a postcode and something else', $page); |
| 50 | 50 | $this->assertStringNotContainsString('Did you mean to get alerts for when your MP', $page); |
| 51 | 51 | } |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function testEditUserInfo() { |
| 43 | - $page = $this->fetch_user_page(['pg' => 'edit' ]); |
|
| 43 | + $page = $this->fetch_user_page(['pg' => 'edit']); |
|
| 44 | 44 | $this->assertStringContainsString('Edit your details', $page); |
| 45 | 45 | $this->assertStringContainsString('name="pg" value="edit"', $page); |
| 46 | 46 | $this->assertStringContainsString('value="Test"', $page); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | private function fetch_votes_page() { |
| 16 | - return $this->fetch_page([ 'pagetype' => 'votes', 'pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency/votes' ]); |
|
| 16 | + return $this->fetch_page(['pagetype' => 'votes', 'pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency/votes']); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | public function testVoteSummary() { |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | public function escape_comments($data) { |
| 155 | 155 | |
| 156 | - $data = preg_replace_callback("/<!--(.*?)-->/s", function ($matches) { |
|
| 156 | + $data = preg_replace_callback("/<!--(.*?)-->/s", function($matches) { |
|
| 157 | 157 | return '<!--' . HtmlSpecialChars($this->StripSingle($matches[1])) . '-->'; |
| 158 | 158 | }, $data); |
| 159 | 159 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | public function check_tags($data) { |
| 205 | 205 | |
| 206 | - $data = preg_replace_callback("/<(.*?)>/s", function ($matches) { |
|
| 206 | + $data = preg_replace_callback("/<(.*?)>/s", function($matches) { |
|
| 207 | 207 | return $this->process_tag($this->StripSingle($matches[1])); |
| 208 | 208 | }, $data); |
| 209 | 209 | |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | $data = preg_replace_callback( |
| 393 | 393 | '/(^|[^\w\s\';,\\-])(\s*)([a-z])/', |
| 394 | - function ($m) { |
|
| 394 | + function($m) { |
|
| 395 | 395 | return $m[1] . $m[2] . strtoupper($m[3]); |
| 396 | 396 | }, |
| 397 | 397 | $data |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | |
| 433 | 433 | $data = preg_replace_callback( |
| 434 | 434 | '!&([^&;]*)(?=(;|&|$))!', |
| 435 | - function ($matches) { |
|
| 435 | + function($matches) { |
|
| 436 | 436 | return $this->check_entity($this->StripSingle($matches[1]), $this->StripSingle($matches[2])); |
| 437 | 437 | }, |
| 438 | 438 | $data |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | # Sort into order, largest first |
| 109 | - usort($phrases, function ($a, $b) { |
|
| 109 | + usort($phrases, function($a, $b) { |
|
| 110 | 110 | return strlen($a) < strlen($b); |
| 111 | 111 | }); |
| 112 | 112 | |
@@ -156,31 +156,31 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | public static function antiTagInTag($content = '', $format = 'htmlhead') { |
| 158 | 158 | $tagend = -1; |
| 159 | - for($tagstart = strpos($content, '<', $tagend + 1) ; $tagstart !== false && $tagstart < strlen($content); $tagstart = strpos($content, '<', $tagend)) { |
|
| 159 | + for ($tagstart = strpos($content, '<', $tagend + 1); $tagstart !== false && $tagstart < strlen($content); $tagstart = strpos($content, '<', $tagend)) { |
|
| 160 | 160 | // got the start of a tag. Now find the proper end! |
| 161 | 161 | $walker = $tagstart + 1; |
| 162 | 162 | $open = 1; |
| 163 | - while($open != 0 && $walker < strlen($content)) { |
|
| 163 | + while ($open != 0 && $walker < strlen($content)) { |
|
| 164 | 164 | $nextopen = strpos($content, '<', $walker); |
| 165 | 165 | $nextclose = strpos($content, '>', $walker); |
| 166 | - if($nextclose === false) { |
|
| 166 | + if ($nextclose === false) { |
|
| 167 | 167 | // ERROR! Open waka without close waka! |
| 168 | 168 | // echo '<code>Error in antiTagInTag - malformed tag!</code> '; |
| 169 | 169 | return $content; |
| 170 | 170 | } |
| 171 | - if($nextopen === false || $nextopen > $nextclose) { |
|
| 171 | + if ($nextopen === false || $nextopen > $nextclose) { |
|
| 172 | 172 | // No more opens, but there was a close; or, a close happens before the next open. |
| 173 | 173 | // walker goes to the close+1, and open decrements |
| 174 | 174 | $open--; |
| 175 | 175 | $walker = $nextclose + 1; |
| 176 | - } elseif($nextopen < $nextclose) { |
|
| 176 | + } elseif ($nextopen < $nextclose) { |
|
| 177 | 177 | // an open before the next close |
| 178 | 178 | $open++; |
| 179 | 179 | $walker = $nextopen + 1; |
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | $tagend = $walker; |
| 183 | - if($tagend > strlen($content)) { |
|
| 183 | + if ($tagend > strlen($content)) { |
|
| 184 | 184 | $tagend = strlen($content); |
| 185 | 185 | } else { |
| 186 | 186 | $tagend--; |