Index: trunk/phase3/includes/memcached-client.php |
— | — | @@ -245,11 +245,11 @@ |
246 | 246 | */ |
247 | 247 | public function __construct( $args ) { |
248 | 248 | global $wgMemCachedTimeout; |
249 | | - $this->set_servers( @$args['servers'] ); |
250 | | - $this->_debug = @$args['debug']; |
| 249 | + $this->set_servers( isset( $args['servers'] ) ? $args['servers'] : array() ); |
| 250 | + $this->_debug = isset( $args['debug'] ) ? $args['debug'] : false; |
251 | 251 | $this->stats = array(); |
252 | | - $this->_compress_threshold = @$args['compress_threshold']; |
253 | | - $this->_persistant = array_key_exists( 'persistant', $args ) ? ( @$args['persistant'] ) : false; |
| 252 | + $this->_compress_threshold = isset( $args['compress_threshold'] ) ? $args['compress_threshold'] : 0; |
| 253 | + $this->_persistant = isset( $args['persistant'] ) ? $args['persistant'] : false; |
254 | 254 | $this->_compress_enable = true; |
255 | 255 | $this->_have_zlib = function_exists( 'gzcompress' ); |
256 | 256 | |
— | — | @@ -318,7 +318,11 @@ |
319 | 319 | |
320 | 320 | $key = is_array( $key ) ? $key[1] : $key; |
321 | 321 | |
322 | | - @$this->stats['delete']++; |
| 322 | + if ( isset( $this->stats['delete'] ) ) { |
| 323 | + $this->stats['delete']++; |
| 324 | + } else { |
| 325 | + $this->stats['delete'] = 1; |
| 326 | + } |
323 | 327 | $cmd = "delete $key $time\r\n"; |
324 | 328 | if( !$this->_safe_fwrite( $sock, $cmd, strlen( $cmd ) ) ) { |
325 | 329 | $this->_dead_sock( $sock ); |
— | — | @@ -401,7 +405,11 @@ |
402 | 406 | return false; |
403 | 407 | } |
404 | 408 | |
405 | | - @$this->stats['get']++; |
| 409 | + if ( isset( $this->stats['get'] ) ) { |
| 410 | + $this->stats['get']++; |
| 411 | + } else { |
| 412 | + $this->stats['get'] = 1; |
| 413 | + } |
406 | 414 | |
407 | 415 | $cmd = "get $key\r\n"; |
408 | 416 | if ( !$this->_safe_fwrite( $sock, $cmd, strlen( $cmd ) ) ) { |
— | — | @@ -438,7 +446,11 @@ |
439 | 447 | return false; |
440 | 448 | } |
441 | 449 | |
442 | | - @$this->stats['get_multi']++; |
| 450 | + if ( isset( $this->stats['get_multi'] ) ) { |
| 451 | + $this->stats['get_multi']++; |
| 452 | + } else { |
| 453 | + $this->stats['get_multi'] = 1; |
| 454 | + } |
443 | 455 | $sock_keys = array(); |
444 | 456 | |
445 | 457 | foreach ( $keys as $key ) { |
— | — | @@ -667,11 +679,13 @@ |
668 | 680 | $timeout = $this->_connect_timeout; |
669 | 681 | $errno = $errstr = null; |
670 | 682 | for( $i = 0; !$sock && $i < $this->_connect_attempts; $i++ ) { |
| 683 | + wfSuppressWarnings(); |
671 | 684 | if ( $this->_persistant == 1 ) { |
672 | | - $sock = @pfsockopen( $ip, $port, $errno, $errstr, $timeout ); |
| 685 | + $sock = pfsockopen( $ip, $port, $errno, $errstr, $timeout ); |
673 | 686 | } else { |
674 | | - $sock = @fsockopen( $ip, $port, $errno, $errstr, $timeout ); |
| 687 | + $sock = fsockopen( $ip, $port, $errno, $errstr, $timeout ); |
675 | 688 | } |
| 689 | + wfRestoreWarnings(); |
676 | 690 | } |
677 | 691 | if ( !$sock ) { |
678 | 692 | if ( $this->_debug ) { |
— | — | @@ -702,7 +716,8 @@ |
703 | 717 | } |
704 | 718 | |
705 | 719 | function _dead_host( $host ) { |
706 | | - @list( $ip, /* $port */) = explode( ':', $host ); |
| 720 | + $parts = explode( ':', $host ); |
| 721 | + $ip = $parts[0]; |
707 | 722 | $this->_host_dead[$ip] = time() + 30 + intval( rand( 0, 10 ) ); |
708 | 723 | $this->_host_dead[$host] = $this->_host_dead[$ip]; |
709 | 724 | unset( $this->_cache_sock[$host] ); |
— | — | @@ -801,7 +816,11 @@ |
802 | 817 | } |
803 | 818 | |
804 | 819 | $key = is_array( $key ) ? $key[1] : $key; |
805 | | - @$this->stats[$cmd]++; |
| 820 | + if ( isset( $this->stats[$cmd] ) ) { |
| 821 | + $this->stats[$cmd]++; |
| 822 | + } else { |
| 823 | + $this->stats[$cmd] = 1; |
| 824 | + } |
806 | 825 | if ( !$this->_safe_fwrite( $sock, "$cmd $key $amt\r\n" ) ) { |
807 | 826 | return $this->_dead_sock( $sock ); |
808 | 827 | } |
— | — | @@ -843,7 +862,11 @@ |
844 | 863 | } |
845 | 864 | $offset += $n; |
846 | 865 | $bneed -= $n; |
847 | | - @$ret[$rkey] .= $data; |
| 866 | + if ( isset( $ret[$rkey] ) ) { |
| 867 | + $ret[$rkey] .= $data; |
| 868 | + } else { |
| 869 | + $ret[$rkey] = $data; |
| 870 | + } |
848 | 871 | } |
849 | 872 | |
850 | 873 | if ( $offset != $len + 2 ) { |
— | — | @@ -898,7 +921,11 @@ |
899 | 922 | return false; |
900 | 923 | } |
901 | 924 | |
902 | | - @$this->stats[$cmd]++; |
| 925 | + if ( isset( $this->stats[$cmd] ) ) { |
| 926 | + $this->stats[$cmd]++; |
| 927 | + } else { |
| 928 | + $this->stats[$cmd] = 1; |
| 929 | + } |
903 | 930 | |
904 | 931 | $flags = 0; |
905 | 932 | |