Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
In #228594: UMN Usability: split access rules into an optional module a small performance improvement was introduced. Instead of having to look up the user's IP address in the database for every request, the site owner can specify the list of IP addresses in settings.php - possibly just an empty array.
This is a simple change that seems like a reasonable candidate for inclusion into D6.
Comment | File | Size | Author |
---|---|---|---|
#6 | blocked_ips-3.patch | 1.1 KB | c960657 |
#4 | blocked_ips-2.patch | 1.74 KB | c960657 |
blocked_ips-1-D6.patch | 2.27 KB | c960657 | |
Comments
Comment #1
catchSubscribe. It'd be worth adding this as a merge request to Pressflow as well.
Comment #2
c960657 CreditAttribution: c960657 commentedNote that the query does not make good use of MySQL's query cache, because the client's IP address is different for each client. So even though this is just one query per request, it is a query that is often not cached in the database.
Comment #3
c960657 CreditAttribution: c960657 commentedTagging.
Comment #4
c960657 CreditAttribution: c960657 commentedRerolled with Git.
Comment #5
rjbrown99 CreditAttribution: rjbrown99 commentedQuestion about #4. It seems to check for a variable blocked_ips, and then does the access check against that array. The variables are all called blocked_ips, but the original function checks for three different $type possibilities: host, mail, or user.
It would seem that you could still potentially accomplish that with an array, but the variable names are a bit misleading. Perhaps renaming to blocked_access or something similar, with examples for each different $type.
Comment #6
c960657 CreditAttribution: c960657 commentedYou are right. The intention was only to support the "host" option with the blocked_ips array (like in D7), because _drupal_bootstrap() calls
drupal_is_denied('host', ip_address())
every request.Here is an updated patch that checks that $type == "host".
Comment #7
rjbrown99 CreditAttribution: rjbrown99 commentedThanks, question though: you COULD pop host, mail, or user into that same array couldn't you? For example, in my case I'm not using this at all so I'd rather just pass in an empty array for all of it, or manually maintain my array in the conf file if needed.
Comment #8
c960657 CreditAttribution: c960657 commentedYes, that would be possible, though the performance improvement for the other two would be smaller, because the function is not invoked with those $type in every request. I think adding support for those two also would be a bit more than just a backport of the D7 feature.
Comment #9
rjbrown99 CreditAttribution: rjbrown99 commentedAaah, I now understand why you are only doing 'host' and not the others. RTFC - bootstrap.inc (from Pressflow below, probably the same or similar):
The drupal_is_denied call is only made with 'host', so the enclosed patch only really needs to account for that to obtain the speed improvement.
Just posting back in case someone else finds this thread.