diff options
Diffstat (limited to 'includes/Cdb_PHP.php')
-rw-r--r-- | includes/Cdb_PHP.php | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/includes/Cdb_PHP.php b/includes/Cdb_PHP.php index 02be65f3..71b55f87 100644 --- a/includes/Cdb_PHP.php +++ b/includes/Cdb_PHP.php @@ -126,6 +126,7 @@ class CdbReader_PHP extends CdbReader { /** * @param $fileName string + * @throws MWException */ function __construct( $fileName ) { $this->fileName = $fileName; @@ -179,7 +180,7 @@ class CdbReader_PHP extends CdbReader { protected function read( $length, $pos ) { if ( fseek( $this->handle, $pos ) == -1 ) { // This can easily happen if the internal pointers are incorrect - throw new MWException( + throw new MWException( 'Seek failed, file "' . $this->fileName . '" may be corrupted.' ); } @@ -198,12 +199,13 @@ class CdbReader_PHP extends CdbReader { /** * Unpack an unsigned integer and throw an exception if it needs more than 31 bits * @param $s - * @return + * @throws MWException + * @return mixed */ protected function unpack31( $s ) { $data = unpack( 'V', $s ); if ( $data[1] > 0x7fffffff ) { - throw new MWException( + throw new MWException( 'Error in CDB file "' . $this->fileName . '", integer too big.' ); } return $data[1]; @@ -330,10 +332,10 @@ class CdbWriter_PHP extends CdbWriter { */ public function close() { $this->finish(); - if( isset($this->handle) ) { + if( isset( $this->handle ) ) { fclose( $this->handle ); } - if ( wfIsWindows() && file_exists($this->realFileName) ) { + if ( wfIsWindows() && file_exists( $this->realFileName ) ) { unlink( $this->realFileName ); } if ( !rename( $this->tmpFileName, $this->realFileName ) ) { @@ -349,7 +351,7 @@ class CdbWriter_PHP extends CdbWriter { protected function write( $buf ) { $len = fwrite( $this->handle, $buf ); if ( $len !== strlen( $buf ) ) { - $this->throwException( 'Error writing to CDB file "'.$this->tmpFileName.'".' ); + $this->throwException( 'Error writing to CDB file "' . $this->tmpFileName . '".' ); } } @@ -361,7 +363,7 @@ class CdbWriter_PHP extends CdbWriter { $newpos = $this->pos + $len; if ( $newpos > 0x7fffffff ) { $this->throwException( - 'A value in the CDB file "'.$this->tmpFileName.'" is too large.' ); + 'A value in the CDB file "' . $this->tmpFileName . '" is too large.' ); } $this->pos = $newpos; } @@ -390,10 +392,10 @@ class CdbWriter_PHP extends CdbWriter { */ protected function addbegin( $keylen, $datalen ) { if ( $keylen > 0x7fffffff ) { - $this->throwException( 'Key length too long in file "'.$this->tmpFileName.'".' ); + $this->throwException( 'Key length too long in file "' . $this->tmpFileName . '".' ); } if ( $datalen > 0x7fffffff ) { - $this->throwException( 'Data length too long in file "'.$this->tmpFileName.'".' ); + $this->throwException( 'Data length too long in file "' . $this->tmpFileName . '".' ); } $buf = pack( 'VV', $keylen, $datalen ); $this->write( $buf ); @@ -468,14 +470,14 @@ class CdbWriter_PHP extends CdbWriter { // Write the pointer array at the start of the file rewind( $this->handle ); if ( ftell( $this->handle ) != 0 ) { - $this->throwException( 'Error rewinding to start of file "'.$this->tmpFileName.'".' ); + $this->throwException( 'Error rewinding to start of file "' . $this->tmpFileName . '".' ); } $this->write( $final ); } /** * Clean up the temp file and throw an exception - * + * * @param $msg string * @throws MWException */ |