Index: trunk/extensions/CentralNotice/SpecialBannerListLoader.php |
— | — | @@ -15,7 +15,6 @@ |
16 | 16 | function __construct() { |
17 | 17 | // Register special page |
18 | 18 | parent::__construct( "BannerListLoader" ); |
19 | | - $this->centralNoticeDB = new CentralNoticeDB(); |
20 | 19 | } |
21 | 20 | |
22 | 21 | function execute( $par ) { |
— | — | @@ -64,21 +63,21 @@ |
65 | 64 | |
66 | 65 | if ( $this->language == 'en' && $this->project != null ) { |
67 | 66 | // See if we have any preferred notices for all of en |
68 | | - $notices = $this->centralNoticeDB->getNotices( null, 'en', null, 1, 1, $this->location ); |
| 67 | + $notices = CentralNoticeDB::getNotices( null, 'en', null, 1, 1, $this->location ); |
69 | 68 | |
70 | 69 | if ( $notices ) { |
71 | 70 | // Pull banners |
72 | | - $templates = $this->centralNoticeDB->selectTemplatesAssigned( $notices ); |
| 71 | + $templates = CentralNoticeDB::selectTemplatesAssigned( $notices ); |
73 | 72 | } |
74 | 73 | } |
75 | 74 | |
76 | 75 | if ( !$templates && $this->project == 'wikipedia' ) { |
77 | 76 | // See if we have any preferred notices for this language wikipedia |
78 | | - $notices = $this->centralNoticeDB->getNotices( 'wikipedia', $this->language, null, 1, 1, $this->location ); |
| 77 | + $notices = CentralNoticeDB::getNotices( 'wikipedia', $this->language, null, 1, 1, $this->location ); |
79 | 78 | |
80 | 79 | if ( $notices ) { |
81 | 80 | // Pull banners |
82 | | - $templates = $this->centralNoticeDB->selectTemplatesAssigned( $notices ); |
| 81 | + $templates = CentralNoticeDB::selectTemplatesAssigned( $notices ); |
83 | 82 | } |
84 | 83 | } |
85 | 84 | |
Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php |
— | — | @@ -14,8 +14,6 @@ |
15 | 15 | |
16 | 16 | // Internationalization |
17 | 17 | wfLoadExtensionMessages( 'CentralNotice' ); |
18 | | - |
19 | | - $this->centralNoticeDB = new CentralNoticeDB(); |
20 | 18 | } |
21 | 19 | |
22 | 20 | /** |
— | — | @@ -1069,7 +1067,7 @@ |
1070 | 1068 | |
1071 | 1069 | $templates = array(); |
1072 | 1070 | // Pull all banners assigned to the campaigns |
1073 | | - $templates = $this->centralNoticeDB->selectTemplatesAssigned( $campaigns ); |
| 1071 | + $templates = CentralNoticeDB::selectTemplatesAssigned( $campaigns ); |
1074 | 1072 | return $templates; |
1075 | 1073 | } |
1076 | 1074 | |
Index: trunk/extensions/CentralNotice/CentralNotice.db.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | * Return campaigns in the system within given constraints |
20 | 20 | * By default returns enabled campaigns, if $enabled set to false, returns both enabled and disabled campaigns |
21 | 21 | */ |
22 | | - public function getNotices( $project = false, $language = false, $date = false, $enabled = true, $preferred = false, $location = false ) { |
| 22 | + static function getNotices( $project = false, $language = false, $date = false, $enabled = true, $preferred = false, $location = false ) { |
23 | 23 | |
24 | 24 | $notices = array(); |
25 | 25 | |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | if ( $preferred ) { |
49 | 49 | $conds[] = "not_preferred = 1"; |
50 | 50 | } |
51 | | - $conds[] = 'not_project' => array( '', $project ); |
| 51 | + $conds[] = "not_project IN ( '', " . $dbr->addQuotes($project ) . " )"; |
52 | 52 | $conds[] = "not_geo = 0"; |
53 | 53 | $conds[] = "not_start <= " . $encTimestamp; |
54 | 54 | $conds[] = "not_end >= " . $encTimestamp; |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | if ( $preferred ) { |
94 | 94 | $conds[] = "not_preferred = 1"; |
95 | 95 | } |
96 | | - $conds[] = 'not_project' => array( '', $project ); |
| 96 | + $conds[] = "not_project IN ( '', " . $dbr->addQuotes($project ) . " )"; |
97 | 97 | $conds[] = "not_geo = 1"; |
98 | 98 | $conds[] = "nc_notice_id = cn_notices.not_id"; |
99 | 99 | $conds[] = "nc_country =" . $dbr->addQuotes( $location ); |
— | — | @@ -121,7 +121,7 @@ |
122 | 122 | /* |
123 | 123 | * Given one or more campaign ids, return all banners bound to them |
124 | 124 | */ |
125 | | - public function selectTemplatesAssigned( $campaigns ) { |
| 125 | + static function selectTemplatesAssigned( $campaigns ) { |
126 | 126 | $dbr = wfGetDB( DB_SLAVE ); |
127 | 127 | |
128 | 128 | // Pull templates based on join with assignments |