Révision ecd39969
Ajouté par Assos Assos il y a environ 5 ans
drupal7/includes/registry.inc | ||
---|---|---|
19 | 19 |
* Does the work for registry_update(). |
20 | 20 |
*/ |
21 | 21 |
function _registry_update() { |
22 |
|
|
23 | 22 |
// The registry serves as a central autoloader for all classes, including |
24 | 23 |
// the database query builders. However, the registry rebuild process |
25 | 24 |
// requires write ability to the database, which means having access to the |
... | ... | |
33 | 32 |
require_once DRUPAL_ROOT . '/includes/database/select.inc'; |
34 | 33 |
require_once DRUPAL_ROOT . '/includes/database/' . $driver . '/query.inc'; |
35 | 34 |
|
35 |
// During the first registry rebuild in a request, we check all the files. |
|
36 |
// During subsequent rebuilds, we only add new files. It makes the rebuilding |
|
37 |
// process faster during installation of modules. |
|
38 |
static $check_existing_files = TRUE; |
|
39 |
|
|
36 | 40 |
// Get current list of modules and their files. |
37 | 41 |
$modules = db_query("SELECT * FROM {system} WHERE type = 'module'")->fetchAll(); |
38 | 42 |
// Get the list of files we are going to parse. |
... | ... | |
55 | 59 |
$files["$filename"] = array('module' => '', 'weight' => 0); |
56 | 60 |
} |
57 | 61 |
|
62 |
// Initialize an empty array for the unchanged files. |
|
63 |
$unchanged_files = array(); |
|
64 |
|
|
58 | 65 |
$transaction = db_transaction(); |
59 | 66 |
try { |
60 | 67 |
// Allow modules to manually modify the list of files before the registry |
... | ... | |
63 | 70 |
// list can then be added to the list of files that the registry will parse, |
64 | 71 |
// or modify attributes of a file. |
65 | 72 |
drupal_alter('registry_files', $files, $modules); |
73 |
|
|
66 | 74 |
foreach (registry_get_parsed_files() as $filename => $file) { |
67 | 75 |
// Add the hash for those files we have already parsed. |
68 | 76 |
if (isset($files[$filename])) { |
69 |
$files[$filename]['hash'] = $file['hash']; |
|
77 |
if ($check_existing_files === TRUE) { |
|
78 |
$files[$filename]['hash'] = $file['hash']; |
|
79 |
} |
|
80 |
else { |
|
81 |
// Ignore that file for this request, it has been parsed previously |
|
82 |
// and it is unlikely it has changed. |
|
83 |
unset($files[$filename]); |
|
84 |
$unchanged_files[$filename] = $file; |
|
85 |
} |
|
70 | 86 |
} |
71 | 87 |
else { |
72 | 88 |
// Flush the registry of resources in files that are no longer on disc |
... | ... | |
79 | 95 |
->execute(); |
80 | 96 |
} |
81 | 97 |
} |
98 |
|
|
82 | 99 |
$parsed_files = _registry_parse_files($files); |
83 | 100 |
|
101 |
// Add unchanged files to the files. |
|
102 |
$files += $unchanged_files; |
|
103 |
|
|
84 | 104 |
$unchanged_resources = array(); |
85 | 105 |
$lookup_cache = array(); |
86 | 106 |
if ($cache = cache_get('lookup_cache', 'cache_bootstrap')) { |
... | ... | |
89 | 109 |
foreach ($lookup_cache as $key => $file) { |
90 | 110 |
// If the file for this cached resource is carried over unchanged from |
91 | 111 |
// the last registry build, then we can safely re-cache it. |
92 |
if ($file && in_array($file, array_keys($files)) && !in_array($file, $parsed_files)) {
|
|
112 |
if ($file && isset($files[$file]) && !in_array($file, $parsed_files, TRUE)) {
|
|
93 | 113 |
$unchanged_resources[$key] = $file; |
94 | 114 |
} |
95 | 115 |
} |
96 |
module_implements('', FALSE, TRUE); |
|
97 |
_registry_check_code(REGISTRY_RESET_LOOKUP_CACHE); |
|
98 | 116 |
} |
99 | 117 |
catch (Exception $e) { |
100 | 118 |
$transaction->rollback(); |
... | ... | |
102 | 120 |
throw $e; |
103 | 121 |
} |
104 | 122 |
|
123 |
module_implements('', FALSE, TRUE); |
|
124 |
_registry_check_code(REGISTRY_RESET_LOOKUP_CACHE); |
|
125 |
|
|
126 |
// During the next run in this request, don't bother re-checking existing |
|
127 |
// files. |
|
128 |
$check_existing_files = FALSE; |
|
129 |
|
|
105 | 130 |
// We have some unchanged resources, warm up the cache - no need to pay |
106 | 131 |
// for looking them up again. |
107 | 132 |
if (count($unchanged_resources) > 0) { |
Formats disponibles : Unified diff
Udpate to 7.65