I've created some patches to the node, og, and taxonomy_access modules which allow them to work together: http://groups.drupal.org/node/3700

What I want to do now is start removing some of these patches by putting the functionality I need into one separate module.

First up: taxonomy_access_db_rewrite_sql(). Curently, I patch this function in order to get the taxonomy_access module to display terms and nodes while respecting OG access control. What I would like to do is take this patched code, put it into another module, and have that module override the default taxonomy_access_db_rewrite_sql() function (therefore removing my need to patch it).

Put another way, I would like to have the db_rewrite_sql() function of Module B override (not add to or augment, but replace) the db_rewrite_sql() function of Module A.

Is this even possible? And if so, how would I go about doing it?

Thanks!

Comments

coreyp_1’s picture

If your version of php has the apd pecl extension enabled, you can use rename_function() to rename the original function to something else, then declare your own version.

- Corey

Thomas Sewell’s picture

Just add a module-name_db_rewrite_sql function to your new module that makes the alterations you need under the correct set of conditions.

You'll also need to ensure that your custom module's weight in the system table makes it so that your module's function runs after the taxonomy module's does, Setting the weight of your module in the DB is generally done at .install time.

somebodysysop’s picture

You probably already answered this, but just so I'm sure: If the new custom module function executes under the same conditions as the one in taxonomy_access (TAC), but executes after the one in TAC because it is weighted higher, won't the db_rewrite sql still contain the elements of the TAC function in addition to the new function (which is what I'm trying to avoid)? Or, since it is under the same conditions, will the new module function override the existing taxonomy_access function (provided the new function is executed afterwards)?

FYI, I found a way to modify module weight here: http://drupal.org/project/moduleweight

Thanks!

somebodysysop’s picture

The answer to my question is: "Placing the custom hook_db_rewrite_sql() in module weighted higher will override that in TAC, so long as conditions are the same". Thanks.