+ function upgradeImage() {
+ $fname = 'FiveUpgrade::upgradeImage';
+ $chunksize = 100;
+
+ extract( $this->dbw->tableNames( 'image', 'image_temp', 'image_old' ) );
+ $this->log( 'Creating temporary image_temp to merge into...' );
+ $this->dbw->query( <<<END
+CREATE TABLE $image_temp (
+ img_name varchar(255) binary NOT NULL default '',
+ img_size int(8) unsigned NOT NULL default '0',
+ img_width int(5) NOT NULL default '0',
+ img_height int(5) NOT NULL default '0',
+ img_metadata mediumblob NOT NULL,
+ img_bits int(3) NOT NULL default '0',
+ img_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL,
+ img_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart") NOT NULL default "unknown",
+ img_minor_mime varchar(32) NOT NULL default "unknown",
+ img_description tinyblob NOT NULL default '',
+ img_user int(5) unsigned NOT NULL default '0',
+ img_user_text varchar(255) binary NOT NULL default '',
+ img_timestamp char(14) binary NOT NULL default '',
+
+ PRIMARY KEY img_name (img_name),
+ INDEX img_size (img_size),
+ INDEX img_timestamp (img_timestamp)
+) TYPE=InnoDB
+END
+ , $fname);
+
+ $numimages = $this->dbw->selectField( 'image', 'count(*)', '', $fname );
+ $result = $this->dbr->select( 'image',
+ array(
+ 'img_name',
+ 'img_size',
+ 'img_description',
+ 'img_user',
+ 'img_user_text',
+ 'img_timestamp' ),
+ '',
+ $fname );
+ $add = array();
+ $this->setChunkScale( $chunksize, $numimages, 'image_temp', $fname );
+ while( $row = $this->dbr->fetchObject( $result ) ) {
+ // Fill in the new image info fields
+ $info = $this->imageInfo( $row->img_name );
+
+ // Update and convert encoding
+ $add[] = array(
+ 'img_name' => $this->conv( $row->img_name ),
+ 'img_size' => $row->img_size,
+ 'img_width' => $info['width'],
+ 'img_height' => $info['height'],
+ 'img_metadata' => "", // loaded on-demand
+ 'img_bits' => $info['bits'],
+ 'img_media_type' => $info['media'],
+ 'img_major_mime' => $info['major'],
+ 'img_minor_mime' => $info['minor'],
+ 'img_description' => $this->conv( $row->img_description ),
+ 'img_user' => $row->img_user,
+ 'img_user_text' => $this->conv( $row->img_user_text ),
+ 'img_timestamp' => $row->img_timestamp );
+
+ // If doing UTF8 conversion the file must be renamed
+ $this->renameFile( $row->img_name, 'wfImageDir' );
+ }
+ $this->lastChunk( $add );
+
+ $this->log( 'Renaming image to image_old and image_temp to image...' );
+ $this->dbw->query( "ALTER TABLE $image RENAME TO $image_old" );
+ $this->dbw->query( "ALTER TABLE $image_temp RENAME TO $image" );
+
+ $this->log( 'done with image table.' );