How to replace a preprocess function entirely? I need to replace template_preprocess_links with my own preprocess function and I can't find in the documentation how to replace a preprocess function entirely. Here is my current HOOK_theme implementation:

/**
 * Implements hook_theme().
 */
function my_module_theme($existing, $type, $theme, $path)
{    
  return [
    'links' =&gt; [
      'variables' =&gt; [
        'links' =&gt; NULL,
        'raw_links' =&gt; NULL,
        'attributes' =&gt; NULL,
        'heading' =&gt; NULL
      ],
      'override preprocess functions' =&gt; TRUE
    ]
  ];
}


But even with override preprocess functions set to TRUE, the core template_preprocess_links is still called and pollute the output with rendered links.

How can I replace this preprocess function entirely?
hook_theme() is for new theme implementations, not altering the existing ones, and 'override preprocess functions' can be used just from themes.

The hook you need to implement is hook_theme_registry_alter(). The example code shows how to remove a preprocess function for a theme implementation.

function mymodule_theme_registry_alter(&amp;$theme_registry) {
  // Kill the next/previous forum topic navigation links.
  foreach ($theme_registry['forum_topic_navigation']['preprocess functions'] as $key =&gt; $value) {
    if ($value == 'template_preprocess_forum_topic_navigation') {
      unset($theme_registry['forum_topic_navigation']['preprocess functions'][$key]);
    }
  }
}


Removing all the preprocess functions would just require a line like unset($theme_registry['forum_topic_navigation']['preprocess functions'].

The same is true for Drupal 7. (See the example code given in hook_theme_registry_alter() - Drupal 7).