Ticket #34536: add_braces_to_ifstatement.diff
| File add_braces_to_ifstatement.diff, 5.9 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/cache.php
412 412 * @return bool False if cache key and group already exist, true on success 413 413 */ 414 414 public function add( $key, $data, $group = 'default', $expire = 0 ) { 415 if ( wp_suspend_cache_addition() ) 415 if ( wp_suspend_cache_addition() ) { 416 416 return false; 417 } 417 418 418 if ( empty( $group ) ) 419 if ( empty( $group ) ) { 419 420 $group = 'default'; 421 } 420 422 421 423 $id = $key; 422 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) 424 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { 423 425 $id = $this->blog_prefix . $key; 426 } 424 427 425 if ( $this->_exists( $id, $group ) ) 428 if ( $this->_exists( $id, $group ) ) { 426 429 return false; 430 } 427 431 428 432 return $this->set( $key, $data, $group, (int) $expire ); 429 433 } … … 455 459 * @return false|int False on failure, the item's new value on success. 456 460 */ 457 461 public function decr( $key, $offset = 1, $group = 'default' ) { 458 if ( empty( $group ) ) 462 if ( empty( $group ) ) { 459 463 $group = 'default'; 464 } 460 465 461 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) 466 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { 462 467 $key = $this->blog_prefix . $key; 468 } 463 469 464 if ( ! $this->_exists( $key, $group ) ) 470 if ( ! $this->_exists( $key, $group ) ) { 465 471 return false; 472 } 466 473 467 if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) 474 if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) { 468 475 $this->cache[ $group ][ $key ] = 0; 476 } 469 477 470 478 $offset = (int) $offset; 471 479 472 480 $this->cache[ $group ][ $key ] -= $offset; 473 481 474 if ( $this->cache[ $group ][ $key ] < 0 ) 482 if ( $this->cache[ $group ][ $key ] < 0 ) { 475 483 $this->cache[ $group ][ $key ] = 0; 484 } 476 485 477 486 return $this->cache[ $group ][ $key ]; 478 487 } … … 491 500 * @return bool False if the contents weren't deleted and true on success. 492 501 */ 493 502 public function delete( $key, $group = 'default', $deprecated = false ) { 494 if ( empty( $group ) ) 503 if ( empty( $group ) ) { 495 504 $group = 'default'; 505 } 496 506 497 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) 507 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { 498 508 $key = $this->blog_prefix . $key; 509 } 499 510 500 if ( ! $this->_exists( $key, $group ) ) 511 if ( ! $this->_exists( $key, $group ) ) { 501 512 return false; 513 } 502 514 503 515 unset( $this->cache[$group][$key] ); 504 516 return true; … … 539 551 * @return false|mixed False on failure to retrieve contents or the cache contents on success. 540 552 */ 541 553 public function get( $key, $group = 'default', $force = false, &$found = null ) { 542 if ( empty( $group ) ) 554 if ( empty( $group ) ) { 543 555 $group = 'default'; 556 } 544 557 545 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) 558 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { 546 559 $key = $this->blog_prefix . $key; 560 } 547 561 548 562 if ( $this->_exists( $key, $group ) ) { 549 563 $found = true; 550 564 $this->cache_hits += 1; 551 if ( is_object($this->cache[$group][$key]) ) 565 if ( is_object($this->cache[$group][$key]) ) { 552 566 return clone $this->cache[$group][$key]; 553 else567 } else { 554 568 return $this->cache[$group][$key]; 569 } 555 570 } 556 571 557 572 $found = false; … … 571 586 * @return false|int False on failure, the item's new value on success. 572 587 */ 573 588 public function incr( $key, $offset = 1, $group = 'default' ) { 574 if ( empty( $group ) ) 589 if ( empty( $group ) ) { 575 590 $group = 'default'; 591 } 576 592 577 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) 593 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { 578 594 $key = $this->blog_prefix . $key; 595 } 579 596 580 if ( ! $this->_exists( $key, $group ) ) 597 if ( ! $this->_exists( $key, $group ) ) { 581 598 return false; 599 } 582 600 583 if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) 601 if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) { 584 602 $this->cache[ $group ][ $key ] = 0; 603 } 585 604 586 605 $offset = (int) $offset; 587 606 588 607 $this->cache[ $group ][ $key ] += $offset; 589 608 590 if ( $this->cache[ $group ][ $key ] < 0 ) 609 if ( $this->cache[ $group ][ $key ] < 0 ) { 591 610 $this->cache[ $group ][ $key ] = 0; 611 } 592 612 593 613 return $this->cache[ $group ][ $key ]; 594 614 } … … 608 628 * @return bool False if not exists, true if contents were replaced. 609 629 */ 610 630 public function replace( $key, $data, $group = 'default', $expire = 0 ) { 611 if ( empty( $group ) ) 631 if ( empty( $group ) ) { 612 632 $group = 'default'; 633 } 613 634 614 635 $id = $key; 615 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) 636 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { 616 637 $id = $this->blog_prefix . $key; 638 } 617 639 618 if ( ! $this->_exists( $id, $group ) ) 640 if ( ! $this->_exists( $id, $group ) ) { 619 641 return false; 642 } 620 643 621 644 return $this->set( $key, $data, $group, (int) $expire ); 622 645 } … … 635 658 636 659 // Clear out non-global caches since the blog ID has changed. 637 660 foreach ( array_keys( $this->cache ) as $group ) { 638 if ( ! isset( $this->global_groups[ $group ] ) ) 661 if ( ! isset( $this->global_groups[ $group ] ) ) { 639 662 unset( $this->cache[ $group ] ); 663 } 640 664 } 641 665 } 642 666 … … 662 686 * @return true Always returns true. 663 687 */ 664 688 public function set( $key, $data, $group = 'default', $expire = 0 ) { 665 if ( empty( $group ) ) 689 if ( empty( $group ) ) { 666 690 $group = 'default'; 691 } 667 692 668 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) 693 if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) { 669 694 $key = $this->blog_prefix . $key; 695 } 670 696 671 if ( is_object( $data ) ) 697 if ( is_object( $data ) ) { 672 698 $data = clone $data; 699 } 673 700 674 701 $this->cache[$group][$key] = $data; 675 702 return true; … … 730 757 * 731 758 * @since 2.0.8 732 759 * 733 * @global int $blog_id Global blog ID.760 * @global int $blog_id Global blog ID. 734 761 */ 735 762 public function __construct() { 736 763 global $blog_id;
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)