Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with ext-gd on php 8 #1762

Merged
merged 1 commit into from
Dec 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Fix for issue [#1735](https://github.com/PHPOffice/PhpSpreadsheet/issues/1735) Incorrect activeSheetIndex after RemoveSheetByIndex - [PR #1743](https://github.com/PHPOffice/PhpSpreadsheet/pull/1743)
- Ensure that the list of shared formulae is maintained when an xlsx file is chunked with readFilter[Issue #169](https://github.com/PHPOffice/PhpSpreadsheet/issues/1669).
- Fix for notice during accessing "cached magnification factor" offset [#1354](https://github.com/PHPOffice/PhpSpreadsheet/pull/1354)
- Fix compatibility with ext-gd on php 8

### Security Fix (CVE-2020-7776)

Expand Down
4 changes: 3 additions & 1 deletion src/PhpSpreadsheet/Shared/Drawing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace PhpOffice\PhpSpreadsheet\Shared;

use GdImage;

class Drawing
{
/**
Expand Down Expand Up @@ -152,7 +154,7 @@ public static function angleToDegrees($pValue)
*
* @param string $p_sFile Path to Windows DIB (BMP) image
*
* @return resource
* @return GdImage|resource
*/
public static function imagecreatefrombmp($p_sFile)
{
Expand Down
8 changes: 5 additions & 3 deletions src/PhpSpreadsheet/Worksheet/MemoryDrawing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace PhpOffice\PhpSpreadsheet\Worksheet;

use GdImage;

class MemoryDrawing extends BaseDrawing
{
// Rendering functions
Expand All @@ -19,7 +21,7 @@ class MemoryDrawing extends BaseDrawing
/**
* Image resource.
*
* @var resource
* @var GdImage|resource
*/
private $imageResource;

Expand Down Expand Up @@ -62,7 +64,7 @@ public function __construct()
/**
* Get image resource.
*
* @return resource
* @return GdImage|resource
*/
public function getImageResource()
{
Expand All @@ -72,7 +74,7 @@ public function getImageResource()
/**
* Set image resource.
*
* @param resource $value
* @param GdImage|resource $value
*
* @return $this
*/
Expand Down
5 changes: 3 additions & 2 deletions src/PhpSpreadsheet/Writer/Xls/Worksheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace PhpOffice\PhpSpreadsheet\Writer\Xls;

use GdImage;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Cell\DataType;
use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
Expand Down Expand Up @@ -2254,7 +2255,7 @@ private function writePassword(): void
*/
public function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1): void
{
$bitmap_array = (is_resource($bitmap) ? $this->processBitmapGd($bitmap) : $this->processBitmap($bitmap));
$bitmap_array = (is_resource($bitmap) || $bitmap instanceof GdImage ? $this->processBitmapGd($bitmap) : $this->processBitmap($bitmap));
[$width, $height, $size, $data] = $bitmap_array;

// Scale the frame of the image.
Expand Down Expand Up @@ -2460,7 +2461,7 @@ private function writeObjPicture($colL, $dxL, $rwT, $dyT, $colR, $dxR, $rwB, $dy
/**
* Convert a GD-image into the internal format.
*
* @param resource $image The image to process
* @param GdImage|resource $image The image to process
*
* @return array Array with data and properties of the bitmap
*/
Expand Down