Loading...
 
Skip to main content

Newsletter - problem in get_all_subscriber when login name contains uppercases

Status
Closed
Subject
Newsletter - problem in get_all_subscriber when login name contains uppercases
Version
8.x
Category
  • Usability
  • Patch
Feature
Newsletters
Resolution status
Fix on the Way
Submitted by
grundsch
Volunteered to solve
grundsch
Lastmod by
grundsch
Rating
(0)
Description

A user registered himself, and chooses as login a name with uppercases (Stephane).

Two newsletter are created, with different subscriptions:
1) group subscription, including the aforementioned user
2) user self subscribe

When sending newsletter 1, the email is sent to the user.
When sending newsletter 2, the email address of the user is not found in the database and cannot be sent (despite finding the correct number of subscribers)

I traced it to two libraries:
first in ./lib/newsletter/nllib.php, in the function get_all_subscriber, we can see in the first part of the function how the email adresses are collected based on the subscribed groups. The select is mostly direct, and gets the correct information.
Later in the function (line 215 and following), individual users are added to the list of emails. Line 218, the "email" from the table tiki_newsletter_subscriptions (which is the login for registered users) is brought to lower case. (Note: I'm not sure, but it could be that the subscription module also puts the login in lower case in that table...)
Finally, line 232, the function get_user_email uses as parameter this lowercase login name to find out the actual email address.

This function is defined in the library ./lib/userlibs.php on line 5581.
This function compares the login passed as parameter to the login in the users_users table, but with a "binary" comparison, i.e. case sensitive! Removing the binary keyword lets the newsletter module find the correct user, and then its email.

Solution

Update: actual fix is better done in /lib/newsletter/nllib.php
It has been done in trunk, commit 41587.
Login handling is still case sensitive, now the newsletter handle it correctly. Will be backported to 9.x when 9.0 is out.


--


I propose to change the login comparison to a normal (non-binary, case-insensitive) comparison. Only question remaining: there was surely a good reason to have a binary comparison, and what else would break if we remove the binary comparison?


userslib.php.8.4 2012-05-22 10:48:16.000000000 +0200 +++ userslib.php 2012-05-22 10:53:06.000000000 +0200

@@ -5580,7 +5580,7 @@

function get_user_email($user) {
global $prefs;
- return ( $prefs'login_is_email' == 'y' && $user != 'admin' ) ? $user : $this->getOne("select `email` from `users_users` where binary `login`=?", array($user));

+ return ( $prefs'login_is_email' == 'y' && $user != 'admin' ) ? $user : $this->getOne("select `email` from `users_users` where `login`=?", array($user));

}
function get_userId_what($userIds, $what='email') {
$query = "select `$what` from `users_users` where `userId` in (".implode(',',array_fill(0, count($userIds),'?')).')';

Importance
7
Easy to solve?
9
Priority
63
Demonstrate Bug on Tiki 19+
Demonstrate Bug (older Tiki versions)
Ticket ID
4230
Created
Tuesday 22 May, 2012 09:44:29 UTC
by grundsch
LastModif
Thursday 07 June, 2012 21:16:04 UTC


Show PHP error messages