/// Forces a regeneration of region overview pages ('Tirol', 'Vorarlberg', ...)
function wrRecacheRegions() {
- $dbr = wfGetDB(DB_SLAVE);
+ $dbr = wfGetDB(DB_REPLICA);
// SELECT cl_from FROM categorylinks where cl_to = 'Region'
$res = $dbr->select('categorylinks', 'cl_from', array('cl_to' => 'Region'));
$page_ids = array();
/// Returns the tuple ($report_id, $sledrun_condition, $date_report)
/// $date_report is NULL or a time as returned by strtotime
-/// Expects a database connection ($dbr = wfGetDB(DB_SLAVE);)
+/// Expects a database connection ($dbr = wfGetDB(DB_REPLICA);)
/// and a page_id describung the page where the condition should be returned.
/// If no condition is found, (NULL, NULL, NULL) is returned.
function wrGetSledrunCondition($dbr, $page_id) {
/// Updates the line of the wrreportcache table that corresponds to the $page_id parameter
function wrUpdateWrReportCacheTable($page_id) {
// Determine the new content for the row that should be updated
- $dbr = wfGetDB(DB_SLAVE);
+ $dbr = wfGetDB(DB_REPLICA);
list($report_id, $condition, $date_report) = wrGetSledrunCondition($dbr, $page_id);
$rows = wrReportGetReports(array('id' => $report_id), 1);
/// $conditions = array('page_title' => 'Birgitzer Alm', 'date_invalid > now()');
/// $limit = 1; // or NULL for no limit
function wrReportGetReports($conditions, $limit=NULL) {
- $dbr = wfGetDB(DB_SLAVE);
+ $dbr = wfGetDB(DB_REPLICA);
$columns = wrReportGetColumnNames();
global $wgDBtype;
if ($wgDBtype == "mysql") // "condition" is a reserved word in mysql
///
/// If no condition is present, array(NULL, NULL) is returned
function wrReportConditionRender($page_title) {
- $dbr = wfGetDB(DB_SLAVE);
+ $dbr = wfGetDB(DB_REPLICA);
$cond = 'condition';
global $wgDBtype;
// select wrreport.id as report_id, `condition`, date_report from wrreport where page_title='Axamer Lizum' and `condition` is not null and date_invalid > now() and delete_date is null order by date_report desc, date_entry desc limit 1;
/// Returns the number of sledrun reports issued by a user with the given id.
public static function getUserSeldrunReportCount($user_id) {
- $dbr = wfGetDB(DB_SLAVE);
+ $dbr = wfGetDB(DB_REPLICA);
// select count(*) from wrreport where author_userid = 1 and delete_date is null and `condition` is not null;
$res = $dbr->select('wrreport', 'count(*)', array('author_userid' => $user_id, 'delete_date' => null, '`condition` is not null'));
$row = $res->fetchRow();
/// conditions is an array that's given to the where clause
private static function getRegionDetails($conditions) {
// Example: SELECT name FROM wrregion WHERE page_id = 882;
- $dbr = wfGetDB(DB_SLAVE);
+ $dbr = wfGetDB(DB_REPLICA);
$res = $dbr->select('wrregion', array('id', 'name', 'aswkb(border)'), $conditions);
if ($dbr->numRows($res) == 1) {
$row = $dbr->fetchRow($res);
/// Creates the HTML of the <bahnentabelle>, <bahnenregiontabelle> and <rodelbahntabelle> tags.
private static function createBahnentabelle($page_titles) {
- $dbr = wfGetDB(DB_SLAVE);
+ $dbr = wfGetDB(DB_REPLICA);
// SELECT p.page_id,p.page_title, c.length, c.walkup_time, c.top_elevation, c.bottom_elevation, c.walkup_separate, c.lift, c.night_light, c.public_transport, c.sled_rental, c.information_phone FROM `page` p, wrsledruncache c WHERE (p.page_title in ('Birgitzer_Alm_(vom_Adelshof)', 'Kemater_Alm', 'Axamer_Lizum') and p.page_id=c.page_id) ORDER BY page_title
$where_array = array('page.page_id = wrsledruncache.page_id');
// get titles that are in the region
$page_titles = array();
- $dbr = wfGetDB(DB_SLAVE);
+ $dbr = wfGetDB(DB_REPLICA);
// the following line would work if MySQL 5.5 would implement a real geospatial version of CONTAINS.
// $res = $dbr->select('wrsledruncache', 'page_id', array('CONTAINS(GEOMFROMWKB(' . $dbr->addQuotes($region_border_wkb) . '), POINT(position_longitude, position_latitude))', 'NOT under_construction'), __METHOD__, 'page_title');
$res = $dbr->select(array('wrsledruncache', 'wrregioncache'), array('page_id' => 'wrregioncache.page_id'), array('wrregioncache.region_id' => $region_id, 'wrregioncache.page_id=wrsledruncache.page_id', 'NOT under_construction'), __METHOD__, 'page_title');
// Note: As (of MediaWiki 1.19), only one feed can be added and each feed added replaces the previous one, the following is possible without risk of having duplicated feed entries.
WrReport::addRegionFeedLink($parser->getTitle());
- $dbr = wfGetDB(DB_SLAVE);
+ $dbr = wfGetDB(DB_REPLICA);
try {
libxml_use_internal_errors(true); // without that, we get PHP Warnings if the $input is not well-formed
try {
// Chech whether identical reports are present
if (!$errorMsg) {
- $dbr = wfGetDB(DB_SLAVE);
+ $dbr = wfGetDB(DB_REPLICA);
$cond = 'condition';
global $wgDBtype;
if ($wgDBtype == "mysql") $cond = "`$cond`"; // "condition" is a reserved word in mysql