[rt-users] Fwd: How to list all enabled users in Perl script?
Nathan Cutler
presnypreklad at gmail.com
Tue Sep 3 06:29:39 EDT 2013
> Call `print $RT_enabled_users->BuildSelectQuery, "\n";`, check SQL manually
> and it is correct then move to Next function.
Thanks, Ruslan. I tried your suggestion. It outputs the following
SELECT statement:
SELECT DISTINCT main.* FROM Users main JOIN Principals Principals_1
ON ( Principals_1.id = main.id ) WHERE (Principals_1.Disabled = '0')
AND (Principals_1.PrincipalType = 'User') ORDER BY main.Name ASC
which I cut-and-pasted into the mysql prompt. This gives me 167 rows
in alphabetical order. The Perl script's output, however, shows only
151 rows.
I changed the SELECT statement to output just main.Name (into a file).
Then, I modified my script to output just the Name of each enabled
user (also to a file). And then I diffed the two resulting files. The
SELECT statement yields 16 more users than the Perl script does.
Here's my guess at what's happening: I'm using the MergeUsers
extension. The SELECT statement ignores the fact that some of the
users have been merged, and simply grabs them all. The Perl script, by
contrast, attempts to get only those users that have not been merged
into other users. But for some reason it fails to do this correctly,
leaving out more users than it should. Significantly, it leaves out 8
users at the end of the list. This would indicate that it's getting a
wrong count of the number of non-merged users. Once it reaches the end
of the count, it simply ignores the remaining users, even though they
are non-merged.
It's quite possible that I have merged 8 users. These 8 are not in the
list generated by the Perl script. In addition to these 8, another 8
(at the end of the alphabet) are also missing. It's very weird and it
definitely smells like a bug.
Any ideas appreciated.
Nathan
More information about the rt-users
mailing list