Merge branch 'master' into next
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 6 May 2016 13:07:21 +0000 (15:07 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 6 May 2016 13:07:21 +0000 (15:07 +0200)
1  2 
wcfsetup/install/files/lib/data/style/StyleAction.class.php
wcfsetup/install/files/lib/data/style/StyleEditor.class.php
wcfsetup/install/files/lib/util/FileUtil.class.php

index 9d81404fff0345eb1a8ddc9d3756df9f8c0ce94e,7c6ba1a6a07cbbdd2ca559c22e32a5a9538a7aa2..6c0a623745036f129428c926d808d2810124ae50
@@@ -471,21 -451,37 +471,34 @@@ class StyleEditor extends DatabaseObjec
                }
                
                // save style
 -              if ($style !== null) {
 -                      $style->update($styleData);
 -              }
 -              else {
 +              if ($style === null) {
                        $styleData['packageID'] = $packageID;
                        $style = new StyleEditor(self::create($styleData));
 -              }
 -              
 -              // import preview image
 -              if (!empty($data['image'])) {
 -                      $fileExtension = mb_substr($data['image'], mb_strrpos($data['image'], '.'));
 -                      $index = $tar->getIndexByFilename($data['image']);
 -                      if ($index !== false) {
 -                              $filename = WCF_DIR.'images/stylePreview-'.$style->styleID.$fileExtension;
 -                              $tar->extract($index, $filename);
 -                              FileUtil::makeWritable($filename);
 -                              
 -                              if (file_exists($filename)) {
 -                                      try {
 -                                              if (($imageData = getimagesize($filename)) !== false) {
 -                                                      switch ($imageData[2]) {
 -                                                              case IMG_PNG:
 -                                                              case IMG_JPEG:
 -                                                              case IMG_JPG:
 -                                                              case IMG_GIF:
 -                                                                      $style->update(array('image' => 'stylePreview-'.$style->styleID.$fileExtension));
 +                      
 +                      // import preview image
 +                      if (!empty($data['image'])) {
 +                              $fileExtension = mb_substr($data['image'], mb_strrpos($data['image'], '.'));
 +                              $index = $tar->getIndexByFilename($data['image']);
 +                              if ($index !== false) {
 +                                      $filename = WCF_DIR.'images/stylePreview-'.$style->styleID.$fileExtension;
 +                                      $tar->extract($index, $filename);
 +                                      FileUtil::makeWritable($filename);
 +                      
 +                                      if (file_exists($filename)) {
-                                               $style->update(['image' => 'stylePreview-'.$style->styleID.$fileExtension]);
++                                              try {
++                                                      if (($imageData = getimagesize($filename)) !== false) {
++                                                              switch ($imageData[2]) {
++                                                                      case IMG_PNG:
++                                                                      case IMG_JPEG:
++                                                                      case IMG_JPG:
++                                                                      case IMG_GIF:
++                                                                              $style->update(['image' => 'stylePreview-'.$style->styleID.$fileExtension]);
++                                                              }
+                                                       }
+                                               }
 -                                      }
 -                                      catch (SystemException $e) {
 -                                              // broken image
++                                              catch (SystemException $e) {
++                                                      // broken image
++                                              }
                                        }
                                }
                        }