r69016 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69015‎ | r69016 | r69017 >
Date:20:43, 4 July 2010
Author:ialex
Status:ok
Tags:
Comment:
Removed error suppression opertators (per bug 24159)
Modified paths:
  • /trunk/phase3/includes/memcached-client.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/memcached-client.php
@@ -245,11 +245,11 @@
246246 */
247247 public function __construct( $args ) {
248248 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;
251251 $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;
254254 $this->_compress_enable = true;
255255 $this->_have_zlib = function_exists( 'gzcompress' );
256256
@@ -318,7 +318,11 @@
319319
320320 $key = is_array( $key ) ? $key[1] : $key;
321321
322 - @$this->stats['delete']++;
 322+ if ( isset( $this->stats['delete'] ) ) {
 323+ $this->stats['delete']++;
 324+ } else {
 325+ $this->stats['delete'] = 1;
 326+ }
323327 $cmd = "delete $key $time\r\n";
324328 if( !$this->_safe_fwrite( $sock, $cmd, strlen( $cmd ) ) ) {
325329 $this->_dead_sock( $sock );
@@ -401,7 +405,11 @@
402406 return false;
403407 }
404408
405 - @$this->stats['get']++;
 409+ if ( isset( $this->stats['get'] ) ) {
 410+ $this->stats['get']++;
 411+ } else {
 412+ $this->stats['get'] = 1;
 413+ }
406414
407415 $cmd = "get $key\r\n";
408416 if ( !$this->_safe_fwrite( $sock, $cmd, strlen( $cmd ) ) ) {
@@ -438,7 +446,11 @@
439447 return false;
440448 }
441449
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+ }
443455 $sock_keys = array();
444456
445457 foreach ( $keys as $key ) {
@@ -667,11 +679,13 @@
668680 $timeout = $this->_connect_timeout;
669681 $errno = $errstr = null;
670682 for( $i = 0; !$sock && $i < $this->_connect_attempts; $i++ ) {
 683+ wfSuppressWarnings();
671684 if ( $this->_persistant == 1 ) {
672 - $sock = @pfsockopen( $ip, $port, $errno, $errstr, $timeout );
 685+ $sock = pfsockopen( $ip, $port, $errno, $errstr, $timeout );
673686 } else {
674 - $sock = @fsockopen( $ip, $port, $errno, $errstr, $timeout );
 687+ $sock = fsockopen( $ip, $port, $errno, $errstr, $timeout );
675688 }
 689+ wfRestoreWarnings();
676690 }
677691 if ( !$sock ) {
678692 if ( $this->_debug ) {
@@ -702,7 +716,8 @@
703717 }
704718
705719 function _dead_host( $host ) {
706 - @list( $ip, /* $port */) = explode( ':', $host );
 720+ $parts = explode( ':', $host );
 721+ $ip = $parts[0];
707722 $this->_host_dead[$ip] = time() + 30 + intval( rand( 0, 10 ) );
708723 $this->_host_dead[$host] = $this->_host_dead[$ip];
709724 unset( $this->_cache_sock[$host] );
@@ -801,7 +816,11 @@
802817 }
803818
804819 $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+ }
806825 if ( !$this->_safe_fwrite( $sock, "$cmd $key $amt\r\n" ) ) {
807826 return $this->_dead_sock( $sock );
808827 }
@@ -843,7 +862,11 @@
844863 }
845864 $offset += $n;
846865 $bneed -= $n;
847 - @$ret[$rkey] .= $data;
 866+ if ( isset( $ret[$rkey] ) ) {
 867+ $ret[$rkey] .= $data;
 868+ } else {
 869+ $ret[$rkey] = $data;
 870+ }
848871 }
849872
850873 if ( $offset != $len + 2 ) {
@@ -898,7 +921,11 @@
899922 return false;
900923 }
901924
902 - @$this->stats[$cmd]++;
 925+ if ( isset( $this->stats[$cmd] ) ) {
 926+ $this->stats[$cmd]++;
 927+ } else {
 928+ $this->stats[$cmd] = 1;
 929+ }
903930
904931 $flags = 0;
905932

Follow-up revisions

RevisionCommit summaryAuthorDate
r69505Removed error suppression operators (per bug 24159)ialex13:16, 18 July 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r68900And one error suppression opertator less (per bug 24159)ialex19:10, 2 July 2010
r68971Two error suppression opertators less (per bug 24159)ialex20:35, 3 July 2010

Status & tagging log