Skip to content

Commit

Permalink
Media: Stop using and deprecate set_imagick_time_limit(). Seems it …
Browse files Browse the repository at this point in the history
…causes more problems than it solves.

Follow-up to #52569 and [55404].

Props: dsar, antpb, audrasjb, SergeyBiryukov, hberberoglu, mtxz, densityapps, ekazda, matt_fw, soulseekah, mikeschroder, azaozz.

Fixes: #58202.

git-svn-id: https://develop.svn.wordpress.org/trunk@56250 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
azaozz committed Jul 17, 2023
1 parent be1cb45 commit 924df26
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/wp-includes/class-wp-image-editor-imagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,23 @@ protected function update_size( $width = null, $height = null ) {
* This function, which is expected to be run before heavy image routines, resolves
* point 1 above by aligning Imagick's timeout with PHP's timeout, assuming it is set.
*
* However seems it introduces more problems than it fixes,
* see https://core.trac.wordpress.org/ticket/58202.
*
* Note:
* - Imagick resource exhaustion does not issue catchable exceptions (yet).
* See https://github.com/Imagick/imagick/issues/333.
* - The resource limit is not saved/restored. It applies to subsequent
* image operations within the time of the HTTP request.
*
* @since 6.2.0
* @since 6.3.0 This method was deprecated.
*
* @return int|null The new limit on success, null on failure.
*/
public static function set_imagick_time_limit() {
_deprecated_function( __METHOD__, '6.3.0' );

if ( ! defined( 'Imagick::RESOURCETYPE_TIME' ) ) {
return null;
}
Expand Down Expand Up @@ -329,8 +335,6 @@ public function resize( $max_w, $max_h, $crop = false ) {
return $this->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h );
}

self::set_imagick_time_limit();

// Execute the resize.
$thumb_result = $this->thumbnail_image( $dst_w, $dst_h );
if ( is_wp_error( $thumb_result ) ) {
Expand Down Expand Up @@ -597,8 +601,6 @@ public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = nu
$src_h -= $src_y;
}

self::set_imagick_time_limit();

try {
$this->image->cropImage( $src_w, $src_h, $src_x, $src_y );
$this->image->setImagePage( $src_w, $src_h, 0, 0 );
Expand Down

0 comments on commit 924df26

Please sign in to comment.