Changeset 11023 for trunk/src/bp-blogs/classes/class-bp-blogs-blog.php
- Timestamp:
- 08/22/2016 09:34:15 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/classes/class-bp-blogs-blog.php
r10426 r11023 49 49 public function __construct( $id = null ) { 50 50 if ( !empty( $id ) ) { 51 $this->id = $id;51 $this->id = (int) $id; 52 52 $this->populate(); 53 53 } … … 64 64 $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name} WHERE id = %d", $this->id ) ); 65 65 66 $this->user_id = $blog->user_id;67 $this->blog_id = $blog->blog_id;66 $this->user_id = (int) $blog->user_id; 67 $this->blog_id = (int) $blog->blog_id; 68 68 } 69 69 … … 244 244 $paged_blogs = BP_Blogs_Blog::get_blog_extras( $paged_blogs, $blog_ids, $type ); 245 245 246 // Integer casting. 247 foreach ( (array) $paged_blogs as $key => $data ) { 248 $paged_blogs[ $key ]->blog_id = (int) $paged_blogs[ $key ]->blog_id; 249 $paged_blogs[ $key ]->admin_user_id = (int) $paged_blogs[ $key ]->admin_user_id; 250 } 251 246 252 if ( $update_meta_cache ) { 247 253 bp_blogs_update_meta_cache( $blog_ids ); … … 339 345 foreach ( (array) $blogs as $blog ) { 340 346 $user_blogs[$blog->blog_id] = new stdClass; 341 $user_blogs[$blog->blog_id]->id = $blog->id;342 $user_blogs[$blog->blog_id]->blog_id = $blog->blog_id;347 $user_blogs[$blog->blog_id]->id = (int) $blog->id; 348 $user_blogs[$blog->blog_id]->blog_id = (int) $blog->blog_id; 343 349 $user_blogs[$blog->blog_id]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path; 344 350 $user_blogs[$blog->blog_id]->name = $blog->name; … … 365 371 $user_id = bp_displayed_user_id(); 366 372 367 return $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id) );373 return array_map( 'intval', $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) ) ); 368 374 } 369 375 … … 380 386 $bp = buddypress(); 381 387 382 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) ); 388 $query = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE blog_id = %d", $blog_id ) ); 389 390 return is_numeric( $query ) ? (int) $query : $query; 383 391 } 384 392 … … 445 453 $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND {$search_terms_sql} ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC" ); 446 454 447 return array( 'blogs' => $paged_blogs, 'total' => $total_blogs ); 455 // Integer casting. 456 foreach ( (array) $paged_blogs as $key => $data ) { 457 $paged_blogs[ $key ]->blog_id = (int) $paged_blogs[ $key ]->blog_id; 458 } 459 460 return array( 'blogs' => $paged_blogs, 'total' => (int) $total_blogs ); 448 461 } 449 462 … … 473 486 $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql}" ); 474 487 475 return array( 'blogs' => $paged_blogs, 'total' => $total_blogs ); 488 // Integer casting. 489 foreach ( (array) $paged_blogs as $key => $data ) { 490 $paged_blogs[ $key ]->blog_id = (int) $paged_blogs[ $key ]->blog_id; 491 } 492 493 return array( 'blogs' => $paged_blogs, 'total' => (int) $total_blogs ); 476 494 } 477 495 … … 510 528 $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND {$letter_sql} {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC" ); 511 529 512 return array( 'blogs' => $paged_blogs, 'total' => $total_blogs ); 530 // Integer casting. 531 foreach ( (array) $paged_blogs as $key => $data ) { 532 $paged_blogs[ $key ]->blog_id = (int) $paged_blogs[ $key ]->blog_id; 533 } 534 535 return array( 'blogs' => $paged_blogs, 'total' => (int) $total_blogs ); 513 536 } 514 537
Note: See TracChangeset
for help on using the changeset viewer.