Are Drupal reversal hooks used that are not in use?

Does Drupal use parsing (and / or triggering) hooks that are not related to content loaded by the current user?

For example, let's say I had a module installed and active foowith the following hooks:

<?php 
// .. stuff ...    
function foo_menu() {
      $items = array();
      $items['foo/show'] = array(
        'title' => t('Foo!'),
        'page callback' => 'foo_display_all',
        'description' => 'All our foo are belong to you',
        'type' => MENU_NORMAL_ITEM,
      );
      return $items;
    }

    function foo_display_all() {
    // About 100 lines of code
    }
// ... stuff ...

Will Drupal analyze (and thus affect load time) for pages that are not listed in foo_menu? In other words, will length and complexity foo_display_allaffect the loading of www.example.com/bar?

If two different questions arise, I will say that I will be grateful for an explanation (or a link to an explanation) about how and why Drupal performs or does not analyze, and not the yes / no answer.

+3
5

hook_menu drupal , URL-, .

Drupal , , . , , foo_menu(). API- hooks

: , PHP , , . , Drupal , PHP . , PHP , Drupal.

, inc, , .

+6

. , , , . Drupal 6, theme_whatever(), hook_menu() include. Drupal , , - require_once().

hook_menu() hook_theme() .

, - , APC, - APC PHP . " " , .

Drupal 7

+4

Drupal MODULE.module( , ) .

Drupal , - , , - . .

+3

, Drupal, -, , -, ,

function foo_display_all() {
    include("foo_display_all_body.php");
}

, , + php .

Fourth, this is micro-optimization. It might be better to avoid this if it’s not absolutely necessary, since the additional complexity (and reading the +1 file) may cost you more in the long run than it saves on parsing.

If you want to speed up parsing php code, you should use the operation cache code

+3
source

Now APC now caches .inc files as well as php, which greatly improves performance.

0
source

Source: https://habr.com/ru/post/1712554/


All Articles