Revert "checks for files without extensions, from AtomicDryad"
This seems to break something, such that uploading a jpeg results
in image size 0x0 (other bits seem to work though o_O)
Will take a look at what's up and re-commit later...
This reverts commit ead87d3934
.
This commit is contained in:
parent
726dd80662
commit
7403fd7c87
2 changed files with 1 additions and 31 deletions
|
@ -132,25 +132,7 @@ abstract class DataHandlerExtension implements Extension {
|
|||
public function receive_event(Event $event) {
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if($event instanceof DataUploadEvent) {
|
||||
$valid=FALSE; // TRUE = skip check_contents()
|
||||
$USEHEADERSALWAYS=FALSE; //TRUE; // STUB - make option
|
||||
if ( is_null($event->type) || ($event->type == "") || ( $USEHEADERSALWAYS ) ) {
|
||||
if (is_callable(array($this,'find_ext'))) {
|
||||
// find_ext should always return false or a valid str, so:
|
||||
if(!$ext=$this->find_ext($event->tmpname)) return; // pass off to the next listener and avoid ext=NULL mysql insert
|
||||
$valid=TRUE; // or avoid calling check_contents() needlessly
|
||||
$event->type = $ext;
|
||||
$event->metadata['extension']=$ext;
|
||||
log_info("core-extension", get_class($this)." has renamed '".$event->metadata['filename']."' to '".$event->metadata['filename'].".$ext'");
|
||||
$event->metadata['filename']=$event->metadata['filename'].".$ext";
|
||||
} else { if(!$USEHEADERSALWAYS) return; } // no ext + valid check_contents = mysql error.
|
||||
}
|
||||
|
||||
|
||||
|
||||
if( ($valid) || ($this->check_contents($event->tmpname)) ) {
|
||||
|
||||
if(($event instanceof DataUploadEvent) && $this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
||||
if(!move_upload_to_archive($event)) return;
|
||||
send_event(new ThumbnailGenerationEvent($event->hash, $event->type));
|
||||
$image = $this->create_image_from_data(warehouse_path("images", $event->hash), $event->metadata);
|
||||
|
@ -161,7 +143,6 @@ abstract class DataHandlerExtension implements Extension {
|
|||
send_event($iae);
|
||||
$event->image_id = $iae->image->id;
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof ThumbnailGenerationEvent) && $this->supported_ext($event->type)) {
|
||||
$this->create_thumb($event->hash);
|
||||
|
|
|
@ -32,17 +32,6 @@ class PixelFileHandler extends DataHandlerExtension {
|
|||
return $image;
|
||||
}
|
||||
|
||||
protected function find_ext($file) {
|
||||
$phpimgexts = array ( 1=> 'gif', 'jpg', 'png', 'swf', 'psd', 'bmp', 'tiff', 'tiff',
|
||||
'jpc', 'jp2', 'jpf', 'jb2', 'swc', 'aiff', 'wbmp', 'xbm'); // const, do not change. Less overhead / PITA than image_type_to_extension($info[2])
|
||||
|
||||
if(!file_exists($file)) return false;
|
||||
$info = getimagesize($file);
|
||||
$exts = array("jpg", "jpeg", "gif", "png");
|
||||
$ret=$phpimgexts[$info[2]];
|
||||
return (in_array($ret,$exts)?$ret:false);
|
||||
}
|
||||
|
||||
protected function check_contents($file) {
|
||||
$valid = Array(IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_JPEG);
|
||||
if(!file_exists($file)) return false;
|
||||
|
|
Reference in a new issue