[rt-users] Fwd: How to list all enabled users in Perl script?

Ruslan Zakirov ruz at bestpractical.com
Tue Sep 3 07:05:15 EDT 2013


Find `sub Next` in lib/RT/Extension/MergeUsers.pm, put logging or printing
debug statements there to check what is going on.


On Tue, Sep 3, 2013 at 2:29 PM, Nathan Cutler <presnypreklad at gmail.com>wrote:

> > 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
>



-- 
Best regards, Ruslan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20130903/7624e04d/attachment.htm>


More information about the rt-users mailing list