More consistent use of cat_ID vs category_id

git-svn-id: http://svn.automattic.com/wordpress/trunk@2551 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2005-04-19 17:17:36 +00:00
parent 74b400f3d3
commit a2b53e2909
3 changed files with 14 additions and 16 deletions

View File

@ -106,8 +106,7 @@ function get_author_rss_link($echo = false, $author_id, $author_nicename) {
return $link; return $link;
} }
function get_category_rss_link($echo = false, $category_id, $category_nicename) { function get_category_rss_link($echo = false, $cat_ID, $category_nicename) {
$cat_ID = $category_id;
$permalink_structure = get_settings('permalink_structure'); $permalink_structure = get_settings('permalink_structure');
if ('' == $permalink_structure) { if ('' == $permalink_structure) {

View File

@ -591,7 +591,6 @@ function &get_category(&$category, $output = OBJECT) {
} else { } else {
if ( !isset($cache_categories[$category]) ) { if ( !isset($cache_categories[$category]) ) {
$category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = $category"); $category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = $category");
$category->category_id = $category->cat_ID; // Alias.
$cache_categories[$category->cat_ID] = & $category; $cache_categories[$category->cat_ID] = & $category;
} else { } else {
$category = & $cache_categories[$category]; $category = & $cache_categories[$category];
@ -1123,7 +1122,7 @@ function update_post_category_cache($post_ids) {
$post_ids = implode(',', $post_ids); $post_ids = implode(',', $post_ids);
$dogs = $wpdb->get_results("SELECT DISTINCT $dogs = $wpdb->get_results("SELECT DISTINCT
post_id, category_id FROM $wpdb->categories, $wpdb->post2cat post_id, cat_ID FROM $wpdb->categories, $wpdb->post2cat
WHERE category_id = cat_ID AND post_id IN ($post_ids)"); WHERE category_id = cat_ID AND post_id IN ($post_ids)");
if (! isset($cache_categories)) if (! isset($cache_categories))
@ -1131,7 +1130,7 @@ function update_post_category_cache($post_ids) {
if ( !empty($dogs) ) { if ( !empty($dogs) ) {
foreach ($dogs as $catt) { foreach ($dogs as $catt) {
$category_cache[$catt->post_id][$catt->category_id] = &$cache_categories[$catt->category_id]; $category_cache[$catt->post_id][$catt->cat_ID] = &$cache_categories[$catt->cat_ID];
} }
} }
} }
@ -1189,7 +1188,7 @@ function update_post_caches(&$posts) {
function update_category_cache() { function update_category_cache() {
global $cache_categories, $wpdb; global $cache_categories, $wpdb;
$dogs = $wpdb->get_results("SELECT *, cat_ID as category_id FROM $wpdb->categories"); $dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories");
foreach ($dogs as $catt) foreach ($dogs as $catt)
$cache_categories[$catt->cat_ID] = $catt; $cache_categories[$catt->cat_ID] = $catt;
} }

View File

@ -56,10 +56,10 @@ function get_the_category_list($separator = '', $parents='') {
if ($category->category_parent) { if ($category->category_parent) {
$thelist .= get_category_parents($category->category_parent, TRUE); $thelist .= get_category_parents($category->category_parent, TRUE);
} }
$thelist .= '<a href="' . get_category_link($category->category_id) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>'; $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>';
break; break;
case 'single': case 'single':
$thelist .= '<a href="' . get_category_link($category->category_id) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . ' rel="category tag">'; $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . ' rel="category tag">';
if ($category->category_parent) { if ($category->category_parent) {
$thelist .= get_category_parents($category->category_parent, FALSE); $thelist .= get_category_parents($category->category_parent, FALSE);
} }
@ -67,7 +67,7 @@ function get_the_category_list($separator = '', $parents='') {
break; break;
case '': case '':
default: default:
$thelist .= '<a href="' . get_category_link($category->category_id) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>'; $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>';
} }
} }
$thelist .= '</ul>'; $thelist .= '</ul>';
@ -79,16 +79,16 @@ function get_the_category_list($separator = '', $parents='') {
switch(strtolower($parents)) { switch(strtolower($parents)) {
case 'multiple': case 'multiple':
if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, TRUE); if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, TRUE);
$thelist .= '<a href="' . get_category_link($category->category_id) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>'; $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>';
break; break;
case 'single': case 'single':
$thelist .= '<a href="' . get_category_link($category->category_id) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'; $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">';
if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, FALSE); if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, FALSE);
$thelist .= "$category->cat_name</a>"; $thelist .= "$category->cat_name</a>";
break; break;
case '': case '':
default: default:
$thelist .= '<a href="' . get_category_link($category->category_id) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>'; $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>';
} }
++$i; ++$i;
} }
@ -139,7 +139,7 @@ function get_category_children($id, $before = '/', $after = '') {
function the_category_ID($echo = true) { function the_category_ID($echo = true) {
// Grab the first cat in the list. // Grab the first cat in the list.
$categories = get_the_category(); $categories = get_the_category();
$cat = $categories[0]->category_id; $cat = $categories[0]->cat_ID;
if ($echo) echo $cat; if ($echo) echo $cat;
@ -288,13 +288,13 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
} }
if ( $optiondates ) { if ( $optiondates ) {
$cat_dates = $wpdb->get_results(" SELECT category_id, $cat_dates = $wpdb->get_results(" SELECT cat_ID,
UNIX_TIMESTAMP( MAX(post_date) ) AS ts UNIX_TIMESTAMP( MAX(post_date) ) AS ts
FROM $wpdb->posts, $wpdb->post2cat FROM $wpdb->posts, $wpdb->post2cat
WHERE post_status = 'publish' AND post_id = ID $exclusions WHERE post_status = 'publish' AND post_id = ID $exclusions
GROUP BY category_id"); GROUP BY category_id");
foreach ($cat_dates as $cat_date) { foreach ($cat_dates as $cat_date) {
$category_timestamp["$cat_date->category_id"] = $cat_date->ts; $category_timestamp["$cat_date->cat_ID"] = $cat_date->ts;
} }
} }
@ -386,7 +386,7 @@ function in_category($category) { // Check if the current post is in the given c
global $post, $category_cache; global $post, $category_cache;
$cats = ''; $cats = '';
foreach ($category_cache[$post->ID] as $cat) : foreach ($category_cache[$post->ID] as $cat) :
$cats[] = $cat->category_id; $cats[] = $cat->cat_ID;
endforeach; endforeach;
if ( in_array($category, $cats) ) if ( in_array($category, $cats) )