Skip to content

Commit

Permalink
MDL-48595 logstore: Replacing references to deprecated interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Mar 9, 2015
1 parent 1cfce08 commit 59aebbe
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 44 deletions.
10 changes: 5 additions & 5 deletions admin/tool/log/tests/manager_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@ public function test_get_log_manager() {
$this->assertCount(2, $stores);
foreach ($stores as $key => $store) {
$this->assertInternalType('string', $key);
$this->assertInstanceOf('core\log\sql_select_reader', $store);
$this->assertInstanceOf('core\log\sql_reader', $store);
}

$stores = $manager->get_readers('core\log\sql_internal_reader');
$stores = $manager->get_readers('core\log\sql_internal_table_reader');
$this->assertInternalType('array', $stores);
$this->assertCount(1, $stores);
foreach ($stores as $key => $store) {
$this->assertInternalType('string', $key);
$this->assertSame('logstore_standard', $key);
$this->assertInstanceOf('core\log\sql_internal_reader', $store);
$this->assertInstanceOf('core\log\sql_internal_table_reader', $store);
}

$stores = $manager->get_readers('core\log\sql_select_reader');
$stores = $manager->get_readers('core\log\sql_reader');
$this->assertInternalType('array', $stores);
$this->assertCount(2, $stores);
foreach ($stores as $key => $store) {
$this->assertInternalType('string', $key);
$this->assertInstanceOf('core\log\sql_select_reader', $store);
$this->assertInstanceOf('core\log\sql_reader', $store);
}
}
}
2 changes: 1 addition & 1 deletion backup/util/helper/backup_cron_helper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ public static function remove_excess_backups($course) {
*/
protected static function is_course_modified($courseid, $since) {
$logmang = get_log_manager();
$readers = $logmang->get_readers('core\log\sql_select_reader');
$readers = $logmang->get_readers('core\log\sql_reader');
$where = "courseid = :courseid and timecreated > :since and crud <> 'r'";
$params = array('courseid' => $courseid, 'since' => $since);
foreach ($readers as $reader) {
Expand Down
2 changes: 1 addition & 1 deletion course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2437,7 +2437,7 @@ function can_delete_course($courseid) {
}

$logmanger = get_log_manager();
$readers = $logmanger->get_readers('\core\log\sql_select_reader');
$readers = $logmanger->get_readers('\core\log\sql_reader');
$reader = reset($readers);

if (empty($reader)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/task/send_failed_login_notifications_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function execute() {
// Get all the IPs with more than notifyloginthreshold failures since lastnotifyfailure
// and insert them into the cache_flags temp table.
$logmang = get_log_manager();
$readers = $logmang->get_readers('\core\log\sql_internal_reader');
$readers = $logmang->get_readers('\core\log\sql_internal_table_reader');
$reader = reset($readers);
$readername = key($readers);
if (empty($reader) || empty($readername)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/statslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ function stats_get_start_from($str) {
$stores = $manager->get_readers();
$firstlog = false;
foreach ($stores as $store) {
if ($store instanceof \core\log\sql_internal_reader) {
if ($store instanceof \core\log\sql_internal_table_reader) {
$logtable = $store->get_internal_log_table_name();
if (!$logtable) {
continue;
Expand Down Expand Up @@ -1767,7 +1767,7 @@ function stats_temp_table_fill($timestart, $timeend) {
$manager = get_log_manager();
$stores = $manager->get_readers();
foreach ($stores as $store) {
if ($store instanceof \core\log\sql_internal_reader) {
if ($store instanceof \core\log\sql_internal_table_reader) {
$logtable = $store->get_internal_log_table_name();
if (!$logtable) {
continue;
Expand Down
6 changes: 3 additions & 3 deletions report/log/classes/renderable.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,17 @@ public function __construct($logreader = "", $course = 0, $userid = 0, $modid =
}

/**
* Get a list of enabled sql_select_reader objects/name
* Get a list of enabled sql_reader objects/name
*
* @param bool $nameonly if true only reader names will be returned.
* @return array core\log\sql_select_reader object or name.
* @return array core\log\sql_reader object or name.
*/
public function get_readers($nameonly = false) {
if (!isset($this->logmanager)) {
$this->logmanager = get_log_manager();
}

$readers = $this->logmanager->get_readers('core\log\sql_select_reader');
$readers = $this->logmanager->get_readers('core\log\sql_reader');
if ($nameonly) {
foreach ($readers as $pluginname => $reader) {
$readers[$pluginname] = $reader->get_name();
Expand Down
2 changes: 1 addition & 1 deletion report/log/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function report_log_extend_navigation_course($navigation, $course, $context) {
* @return bool returns true if the store is supported by the report, false otherwise.
*/
function report_log_supports_logstore($instance) {
if ($instance instanceof \core\log\sql_select_reader) {
if ($instance instanceof \core\log\sql_reader) {
return true;
}
return false;
Expand Down
12 changes: 6 additions & 6 deletions report/log/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ function report_log_print_graph($course, $userid, $type, $date=0, $logreader='')
} else {
$reader = $readers[$logreader];
}
// If reader is not a sql_internal_reader and not legacy store then don't show graph.
if (!($reader instanceof \core\log\sql_internal_reader) && !($reader instanceof logstore_legacy\log\store)) {
// If reader is not a sql_internal_table_reader and not legacy store then don't show graph.
if (!($reader instanceof \core\log\sql_internal_table_reader) && !($reader instanceof logstore_legacy\log\store)) {
return array();
}

Expand Down Expand Up @@ -82,8 +82,8 @@ function report_log_usercourse($userid, $courseid, $coursestart, $logreader = ''
$reader = $readers[$logreader];
}

// If reader is not a sql_internal_reader and not legacy store then return.
if (!($reader instanceof \core\log\sql_internal_reader) && !($reader instanceof logstore_legacy\log\store)) {
// If reader is not a sql_internal_table_reader and not legacy store then return.
if (!($reader instanceof \core\log\sql_internal_table_reader) && !($reader instanceof logstore_legacy\log\store)) {
return array();
}

Expand Down Expand Up @@ -134,8 +134,8 @@ function report_log_userday($userid, $courseid, $daystart, $logreader = '') {
$reader = $readers[$logreader];
}

// If reader is not a sql_internal_reader and not legacy store then return.
if (!($reader instanceof \core\log\sql_internal_reader) && !($reader instanceof logstore_legacy\log\store)) {
// If reader is not a sql_internal_table_reader and not legacy store then return.
if (!($reader instanceof \core\log\sql_internal_table_reader) && !($reader instanceof logstore_legacy\log\store)) {
return array();
}

Expand Down
8 changes: 4 additions & 4 deletions report/loglive/classes/renderable.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,18 @@ public function __construct($logreader = "", $course = 0, $url = "", $date = 0,
}

/**
* Get a list of enabled sql_select_reader objects/name
* Get a list of enabled sql_reader objects/name
*
* @param bool $nameonly if true only reader names will be returned.
*
* @return array core\log\sql_select_reader object or name.
* @return array core\log\sql_reader object or name.
*/
public function get_readers($nameonly = false) {
if (!isset($this->logmanager)) {
$this->logmanager = get_log_manager();
}

$readers = $this->logmanager->get_readers('core\log\sql_select_reader');
$readers = $this->logmanager->get_readers('core\log\sql_reader');
if ($nameonly) {
foreach ($readers as $pluginname => $reader) {
$readers[$pluginname] = $reader->get_name();
Expand Down Expand Up @@ -227,4 +227,4 @@ public function get_table($ajax = false) {
}
return $this->tablelog;
}
}
}
2 changes: 1 addition & 1 deletion report/loglive/classes/table_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class report_loglive_table_log extends table_sql {
* - int userid: user id
* - int|string modid: Module id or "site_errors" to view site errors
* - int groupid: Group id
* - \core\log\sql_select_reader logreader: reader from which data will be fetched.
* - \core\log\sql_reader logreader: reader from which data will be fetched.
* - int edulevel: educational level.
* - string action: view action
* - int date: Date from which logs to be viewed.
Expand Down
2 changes: 1 addition & 1 deletion report/loglive/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function report_loglive_extend_navigation_course($navigation, $course, $context)
* @return bool returns true if the store is supported by the report, false otherwise.
*/
function report_loglive_supports_logstore($instance) {
if ($instance instanceof \core\log\sql_select_reader) {
if ($instance instanceof \core\log\sql_reader) {
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion report/outline/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
$views = $DB->get_records_sql($sql, $params);
}

// Get record from sql_internal_reader and merge with records obtained from legacy log (if needed).
// Get record from sql_internal_table_reader and merge with records obtained from legacy log (if needed).
if ($useinternalreader) {
// Check if we need to show the last access.
$sqllasttime = '';
Expand Down
2 changes: 1 addition & 1 deletion report/outline/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function report_outline_page_type_list($pagetype, $parentcontext, $currentcontex
* @return bool returns true if the store is supported by the report, false otherwise.
*/
function report_outline_supports_logstore($instance) {
if ($instance instanceof \core\log\sql_internal_reader || $instance instanceof \logstore_legacy\log\store) {
if ($instance instanceof \core\log\sql_internal_table_reader || $instance instanceof \logstore_legacy\log\store) {
return true;
}
return false;
Expand Down
8 changes: 4 additions & 4 deletions report/outline/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ function report_outline_get_common_log_variables() {
$uselegacyreader = true;
}

// If sql_internal_reader is preferred reader.
if ($reader instanceof \core\log\sql_internal_reader) {
// If sql_internal_table_reader is preferred reader.
if ($reader instanceof \core\log\sql_internal_table_reader) {
$useinternalreader = true;
$logtable = $reader->get_internal_log_table_name();
$minloginternalreader = $DB->get_field_sql('SELECT min(timecreated) FROM {' . $logtable . '}');
Expand Down Expand Up @@ -144,7 +144,7 @@ function report_outline_user_outline($userid, $cmid, $module, $instanceid) {
}
}

// Get record from sql_internal_reader and combine with the number of views from the legacy log table (if needed).
// Get record from sql_internal_table_reader and combine with the number of views from the legacy log table (if needed).
if ($useinternalreader) {
$params = array('userid' => $userid, 'contextlevel' => CONTEXT_MODULE, 'contextinstanceid' => $cmid, 'crud' => 'r',
'edulevel1' => core\event\base::LEVEL_PARTICIPATING, 'edulevel2' => core\event\base::LEVEL_TEACHING,
Expand Down Expand Up @@ -223,7 +223,7 @@ function report_outline_user_complete($userid, $cmid, $module, $instanceid) {
}
}

// Get record from sql_internal_reader and combine with the number of views from the legacy log table (if needed).
// Get record from sql_internal_table_reader and combine with the number of views from the legacy log table (if needed).
if ($useinternalreader) {
$params = array('userid' => $userid, 'contextlevel' => CONTEXT_MODULE, 'contextinstanceid' => $cmid, 'crud' => 'r',
'edulevel1' => core\event\base::LEVEL_PARTICIPATING, 'edulevel2' => core\event\base::LEVEL_TEACHING,
Expand Down
8 changes: 4 additions & 4 deletions report/participation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();

$uselegacyreader = false; // Use legacy reader with sql_internal_reader to aggregate records.
$uselegacyreader = false; // Use legacy reader with sql_internal_table_reader to aggregate records.
$onlyuselegacyreader = false; // Use only legacy log table to aggregate records.

$logtable = report_participation_get_log_table_name(); // Log table to use for fetaching records.
Expand All @@ -100,7 +100,7 @@

$modinfo = get_fast_modinfo($course);

$minloginternalreader = 0; // Time of first record in sql_internal_reader.
$minloginternalreader = 0; // Time of first record in sql_internal_table_reader.

if ($onlyuselegacyreader) {
// If no sql_inrenal_reader enabled then get min. time from log table.
Expand All @@ -119,7 +119,7 @@
$minlog = $minloginternalreader;
}

// If timefrom is greater then first record in sql_internal_reader then get record from sql_internal_reader only.
// If timefrom is greater then first record in sql_internal_table_reader then get record from sql_internal_table_reader only.
if (!empty($timefrom) && ($minloginternalreader < $timefrom)) {
$uselegacyreader = false;
}
Expand Down Expand Up @@ -270,7 +270,7 @@
}
}

// Get record from sql_internal_reader and merge with records got from legacy log (if needed).
// Get record from sql_internal_table_reader and merge with records got from legacy log (if needed).
if (!$onlyuselegacyreader) {
$sql = "SELECT ra.userid, $usernamefields, u.idnumber, COUNT(l.actioncount) AS count
FROM (SELECT DISTINCT userid FROM {role_assignments} WHERE contextid $relatedctxsql AND roleid = :roleid ) ra
Expand Down
4 changes: 2 additions & 2 deletions report/participation/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ function report_participation_page_type_list($pagetype, $parentcontext, $current
* @return bool returns true if the store is supported by the report, false otherwise.
*/
function report_participation_supports_logstore($instance) {
if ($instance instanceof \core\log\sql_internal_reader || $instance instanceof \logstore_legacy\log\store) {
if ($instance instanceof \core\log\sql_internal_table_reader || $instance instanceof \logstore_legacy\log\store) {
return true;
}
return false;
}
}
6 changes: 3 additions & 3 deletions report/participation/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @return string table name
*/
function report_participation_get_log_table_name() {
// Get prefered sql_internal_reader reader (if enabled).
// Get prefered sql_internal_table_reader reader (if enabled).
$logmanager = get_log_manager();
$readers = $logmanager->get_readers();
$logtable = '';
Expand All @@ -43,8 +43,8 @@ function report_participation_get_log_table_name() {
break;
}

// If sql_internal_reader is preferred reader.
if ($reader instanceof \core\log\sql_internal_reader) {
// If sql_internal_table_reader is preferred reader.
if ($reader instanceof \core\log\sql_internal_table_reader) {
$logtable = $reader->get_internal_log_table_name();
break;
}
Expand Down
4 changes: 2 additions & 2 deletions report/stats/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ function report_stats_page_type_list($pagetype, $parentcontext, $currentcontext)
* @return bool returns true if the store is supported by the report, false otherwise.
*/
function report_stats_supports_logstore($instance) {
if ($instance instanceof \core\log\sql_internal_reader || $instance instanceof \logstore_legacy\log\store) {
if ($instance instanceof \core\log\sql_internal_table_reader || $instance instanceof \logstore_legacy\log\store) {
return true;
}
return false;
}
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2015030500.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2015030500.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.

Expand Down

0 comments on commit 59aebbe

Please sign in to comment.