How to override SearchForm2.php method in upgrade safe manner ?

I want to customize the query functionalities, when filter the Contacts.

I have done this by modifying the “public function generateSearchWhere($add_custom_fields = false, $module = ‘’)” method on SearchForm2.php. (Path: include\SearchForm\SearchForm2.php).

But this is not Upgrade safe.

I tried to follow the steps on the below link but not success:

https://stackoverflow.com/questions/22400098/how-do-i-extend-include-searchform-searchform2-php-in-upgrade-safe-manner?answertab=votes#tab-top

If any one can give me a solution to do this task, it would be grate…!!!

I found this link as a salesagility issue at GitHub.

https://github.com/salesagility/SuiteCRM/issues/5722

Still I am waiting for get a help on this task.