Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#24539 closed defect (bug) (fixed)

Imagick gives E_STRICT notice on PHP 5.4 due to queryFormats() static call

Reported by: kirasong's profile kirasong Owned by: markjaquith's profile markjaquith
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.5
Component: Media Keywords: has-patch
Focuses: Cc:

Description

While using imagick, an E_STRICT notice is generated when queryFormats() is called statically:
https://bugs.php.net/bug.php?id=64945

If a PHP module specifies ZEND_ACC_ALLOW_STATIC, then calling that method statically creates this warning:
Strict Standards: Non-static method Imagick:queryformats() should not be called
statically in /wp-includes/class-wp-image-editor-imagick.php on line 100

Since the author is intentionally allowing static calls (and this particular check does not depend on the specific instance), it's not ideal that PHP has this behavior, since we are using the module as it is intended.

It seems like there are a couple of options:
1) We could add an @ in front of the call
2) We could temporarily create an Imagick object that we don't load anything into, and use that, then destroy it.

I don't particularly like either option, but there it is.

Initial patches attached.

Attachments (2)

24539.at.diff (523 bytes) - added by kirasong 12 years ago.
24539.newObject.diff (683 bytes) - added by kirasong 12 years ago.

Download all attachments as: .zip

Change History (8)

@kirasong
12 years ago

#1 @SergeyBiryukov
12 years ago

  • Milestone changed from Awaiting Review to 3.6

#2 follow-up: @nacin
12 years ago

If this is a bug in Imagick, I would just eat the E_STRICT (as in, wontfix) until it gets fixed upstream.

#3 in reply to: ↑ 2 ; follow-up: @kirasong
12 years ago

Replying to nacin:

If this is a bug in Imagick, I would just eat the E_STRICT (as in, wontfix) until it gets fixed upstream.

Based on the information I have at the moment, it seems like more of a PHP 5.4 _doing_it_wrong() in terms of over-enforcement of class design, but agreed that upstream Imagick can work around this problem in a more future-compatible way.

As mentioned in the bug report, I am not a fan of either of the options available to us for suppressing/working around the notice. If we're fine with the notice existing on PHP 5.4 under Imagick until it's updated upstream (and with hosts), then I'm fine with that.

The downside is that In the meantime, if WP_DEBUG is enabled on PHP 5.4 and Imagick is used, then some things will break (like image edit previews) while it remains enabled.

#4 in reply to: ↑ 3 @markjaquith
12 years ago

Replying to DH-Shredder:

The downside is that In the meantime, if WP_DEBUG is enabled on PHP 5.4 and Imagick is used, then some things will break (like image edit previews) while it remains enabled.

I don't think breaking is acceptable. I'd go with the @-silencing.

#5 @markjaquith
12 years ago

  • Owner set to markjaquith
  • Resolution set to fixed
  • Status changed from new to closed

In 24568:

@-silence an Imagick call that causes a warning in PHP 5.4.

props DH-Shredder. fixes #24539.

#6 @nacin
12 years ago

In 24765:

Confirm we are dealing with an Imagick object. see #24539.

Note: See TracTickets for help on using tickets.