diff --git a/classes/Divisions.php b/classes/Divisions.php index 5fd7550db0..d2a1d9f0d2 100644 --- a/classes/Divisions.php +++ b/classes/Divisions.php @@ -142,8 +142,8 @@ public function getRecentDebatesWithDivisions($number = 20, $majors = null) { # Fetch any division speech, its subsection gid for the link, and # section/subsection bodies to construct a debate title $q = $this->db->query( - "SELECT eps.body as section_body, epss.body as subsection_body, - ss.gid as debate_gid, h.gid, h.hdate, h.major, count(h.gid) AS c + "SELECT min(eps.body) as section_body, min(epss.body) as subsection_body, + min(ss.gid) as debate_gid, min(h.gid), min(h.hdate), min(h.major), count(h.gid) AS c FROM hansard h, hansard ss, epobject eps, epobject epss WHERE h.section_id = eps.epobject_id AND h.subsection_id = epss.epobject_id diff --git a/classes/PartyCohort.php b/classes/PartyCohort.php index 5ecabeecc0..1d23ced091 100644 --- a/classes/PartyCohort.php +++ b/classes/PartyCohort.php @@ -395,14 +395,25 @@ public static function getCohortQuery(){ from (select person_id, - REPLACE(COALESCE(party), "/Co-operative", "") as "start_party", - GROUP_CONCAT(concat(entered_house,":", left_house)) as "membership_key" + REPLACE(COALESCE(m2party), "/Co-operative", "") as "start_party", + GROUP_CONCAT(concat(entered_house,":", left_house) ORDER BY entered_house) as "membership_key" from member + +inner join +( +select party m2party, person_id m2pid +from member +where + house = :house and entered_house > :cut_off +and entered_house = (select min(entered_house) from member m3 where house=:house and entered_house > :cut_off and member.person_id=m3.person_id) +) m2 +ON member.person_id = m2.m2pid + where house = :house and entered_house > :cut_off group by person_id - order by person_id, entered_house + order by person_id )as member_periods left join (select diff --git a/classes/Utility/Wikipedia.php b/classes/Utility/Wikipedia.php index 764bdd2aa2..3cef6ba8d8 100644 --- a/classes/Utility/Wikipedia.php +++ b/classes/Utility/Wikipedia.php @@ -83,6 +83,13 @@ public static function wikipedize($source) { $params[':phrase' . $i] = $phrase; } + if (!$params) { + if ($was_array) { + $source = explode('|||', $source); + } + return $source; + } + # Open up a db connection, and whittle our list down even further, against # the real titles. $matched = array(); diff --git a/tests/UserTest.php b/tests/UserTest.php index 2751470de8..a3862f1fa7 100644 --- a/tests/UserTest.php +++ b/tests/UserTest.php @@ -60,7 +60,7 @@ public function testEditUser() { 'postcode' => 'EH1 99SP', 'password' => '', 'url' => '', - 'optin' => '', + 'optin' => 0, 'user_id' => 1 ) ); @@ -81,7 +81,7 @@ public function testEditUserEmail() { 'postcode' => 'EH1 99SP', 'password' => '', 'url' => '', - 'optin' => '', + 'optin' => 0, 'user_id' => 1 ), false );