Any Override Options?

TiG
TiG
@tig
4 years ago
184 posts
We have bots issuing expensive queries; I have been addressing them one at a time. However, one of these queries is not gracefully addressed. This query occurs when a bot issues a URL of the form: .../{profile}/comment/{cid}

This invokes:
function profile_view_jrComment_default($_profile, $_post, $_user, $_conf) 
which, among other things, checks for privacy with this code:

// We have private comments for this module - get comments attached to items
                        $_sp = array(
                            'search'              => array(
                                'comment_item_id in ' . implode(',', $_ids["{$_rt['comment_module']}"]),
                                "comment_module = {$_rt['comment_module']}"
                            ),
                            'return_item_id_only' => true,
                            'skip_triggers'       => true,
                            'privacy_check'       => false,
                            'ignore_pending'      => true,
                            'quota_check'         => false,
                            'order_by'            => false,
                            'limit'               => 1000000
                        );

                        $_sp = jrCore_db_search_items('jrComment', $_sp);

The above query turns out to be rather expensive on our system given the number of groups and group comments we have.

I would like to disallow access to URLs of this form by bots. Is there a recommended way to accomplish this? I suppose I can resort to a parse_url_listener but I figured I would check with you folks before doing that to ensure that is the right course of action.

Thanks ... TiG


--
TiG

updated by @tig: 03/15/21 02:24:14AM
michael
@michael
4 years ago
7,715 posts
You can over-ride a specific comment by use of a function, eg:
/somebody/comment/23
can be specifically addressed by creating a function:
profile_view_jrComment_23()
but I don't think that's what you're after here, you just want to run some type of catch to see if its a bot and throw it out if it is, so anywhere before the profile_view_jrComment_default() fires will work.

There's a listener that fires just before profile_view_jrComment_default() in the flow of things, its
'profile_data'

That looks to be the closest event.
TiG
TiG
@tig
4 years ago
184 posts
Thanks Michael, I will check into this.


--
TiG

Tags