Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443488
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3443488
Commits
d9ed1a9f
Commit
d9ed1a9f
authored
18 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#87185
by robert: added caching to taxonomy_get_term().
parent
bf3e2f3d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/taxonomy/taxonomy.module
+43
-4
43 additions, 4 deletions
modules/taxonomy/taxonomy.module
with
43 additions
and
4 deletions
modules/taxonomy/taxonomy.module
+
43
−
4
View file @
d9ed1a9f
...
...
@@ -899,6 +899,7 @@ function taxonomy_get_children($tid, $vid = 0, $key = 'tid') {
* @return
* An array of all term objects in the tree. Each term object is extended
* to have "depth" and "parents" attributes in addition to its normal ones.
* Results are statically cached.
*/
function
taxonomy_get_tree
(
$vid
,
$parent
=
0
,
$depth
=
-
1
,
$max_depth
=
NULL
)
{
static
$children
,
$parents
,
$terms
;
...
...
@@ -963,7 +964,18 @@ function taxonomy_get_synonym_root($synonym) {
}
/**
* Given a term id, count the number of published nodes in it.
* Count the number of published nodes classified by a term.
*
* @param $tid
* The term's ID
*
* @param $type
* The $node->type. If given, taxonomy_term_count_nodes only counts
* nodes of $type that are classified with the term $tid.
*
* @return int
* An integer representing a number of nodes.
* Results are statically cached.
*/
function
taxonomy_term_count_nodes
(
$tid
,
$type
=
0
)
{
static
$count
;
...
...
@@ -988,7 +1000,16 @@ function taxonomy_term_count_nodes($tid, $type = 0) {
}
/**
* Helper for taxonomy_term_count_nodes().
* Helper for taxonomy_term_count_nodes(). Used to find out
* which terms are children of a parent term.
*
* @param $tid
* The parent term's ID
*
* @return array
* An array of term IDs representing the children of $tid.
* Results are statically cached.
*
*/
function
_taxonomy_term_children
(
$tid
)
{
static
$children
;
...
...
@@ -1026,6 +1047,13 @@ function taxonomy_get_term_by_name($name) {
/**
* Return the vocabulary object matching a vocabulary ID.
*
* @param $vid
* The vocabulary's ID
*
* @return Object
* The vocabulary object with all of its metadata.
* Results are statically cached.
*/
function
taxonomy_get_vocabulary
(
$vid
)
{
static
$vocabularies
=
array
();
...
...
@@ -1046,10 +1074,21 @@ function taxonomy_get_vocabulary($vid) {
/**
* Return the term object matching a term ID.
*
* @param $tid
* A term's ID
*
* @return Object
* A term object. Results are statically cached.
*/
function
taxonomy_get_term
(
$tid
)
{
// simple cache using a static var?
return
db_fetch_object
(
db_query
(
'SELECT * FROM {term_data} WHERE tid = %d'
,
$tid
));
static
$terms
=
array
();
if
(
!
isset
(
$terms
[
$tid
]))
{
$terms
[
$tid
]
=
db_fetch_object
(
db_query
(
'SELECT * FROM {term_data} WHERE tid = %d'
,
$tid
));
}
return
$terms
[
$tid
];
}
function
_taxonomy_term_select
(
$title
,
$name
,
$value
,
$vocabulary_id
,
$description
,
$multiple
,
$blank
,
$exclude
=
array
())
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment