Skip to content
Permalink
Browse files

Improvements to cns_birthdays RSS hook - perf, and de-duplicating in …

…an edge case
  • Loading branch information...
chrisgraham committed May 15, 2019
1 parent 9008858 commit bf8f15fdb6cfa32603ddefac270120f217cfb328
Showing with 13 additions and 5 deletions.
  1. +5 −2 sources/forum/cns.php
  2. +3 −2 sources/forum_stub.php
  3. +5 −1 sources/hooks/systems/rss/cns_birthdays.php
@@ -569,12 +569,15 @@ public function member_home_url($id, $tempcode_okay = false)
*
* @param MEMBER $id The member ID
* @param boolean $tempcode_okay Whether it is okay to return the result using Tempcode (more efficient, and allows keep_* parameters to propagate which you almost certainly want!)
* @param ?string $username Username, passed for performance reasons (null: look it up)
* @return mixed The URL to the member profile
*/
protected function _member_profile_url($id, $tempcode_okay = false)
protected function _member_profile_url($id, $tempcode_okay = false, $username = null)
{
if (get_option('username_profile_links') == '1') {
$username = $GLOBALS['FORUM_DRIVER']->get_username($id);
if ($username === null) {
$username = $GLOBALS['FORUM_DRIVER']->get_username($id);
}
$map = array('page' => 'members', 'type' => 'view', 'id' => is_null($username) ? strval($id) : $username);
if (get_page_name() == 'members') {
$map += propagate_filtercode();
@@ -77,9 +77,10 @@ public function get_guest_group()
* @param MEMBER $id The forum member
* @param boolean $definitely_profile Whether to be insistent that we go to the profile, rather than possibly starting an IM which can link to the profile
* @param boolean $tempcode_okay Whether it is okay to return the result using Tempcode (more efficient, and allows keep_* parameters to propagate which you almost certainly want!)
* @param ?string $username Username, passed for performance reasons (null: look it up)
* @return mixed The URL
*/
public function member_profile_url($id, $definitely_profile = false, $tempcode_okay = false)
public function member_profile_url($id, $definitely_profile = false, $tempcode_okay = false, $username = null)
{
$url = mixed();
@@ -91,7 +92,7 @@ public function member_profile_url($id, $definitely_profile = false, $tempcode_o
return $url;
}
$url = $this->_member_profile_url($id, $tempcode_okay);
$url = $this->_member_profile_url($id, $tempcode_okay, $username);
if (($tempcode_okay) && (!is_object($url))) {
$url = make_string_tempcode($url);
}
@@ -70,6 +70,8 @@ public function run($_filters, $cutoff, $prefix, $date_string, $max)
}
$rows = $GLOBALS['FORUM_DB']->query('SELECT id,m_dob_day,m_dob_month,m_dob_year,m_username,m_reveal_age,m_join_time FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members p' . $join . ' WHERE m_validated=1 AND ' . $filters . ' AND m_dob_day IS NOT NULL ORDER BY ' . $order, $max);
$rows = remove_duplicate_rows($rows);
$done = 0;
$year = intval(date('Y', time()));
@@ -110,6 +112,8 @@ public function run($_filters, $cutoff, $prefix, $date_string, $max)
sort_maps_by($rows, 'birthday_time');
}
$GLOBALS['NO_QUERY_LIMIT'] = true;
foreach ($rows as $row) {
$id = strval($row['id']);
$author = $row['m_username'];
@@ -128,7 +132,7 @@ public function run($_filters, $cutoff, $prefix, $date_string, $max)
$category = do_lang('BIRTHDAY');
$category_raw = do_lang('BIRTHDAY');
$view_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($row['id'], true, false);
$view_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($row['id'], true, false, $row['m_username']);
$if_comments = new Tempcode();

0 comments on commit bf8f15f

Please sign in to comment.
You can’t perform that action at this time.