[wp-trac] [WordPress Trac] #54385: Fatal error uploading media on PHP8

WordPress Trac noreply at wordpress.org
Fri Nov 19 22:39:01 UTC 2021


#54385: Fatal error uploading media on PHP8
-------------------------------------------------+-------------------------
 Reporter:  stevegs                              |       Owner:
                                                 |  adamsilverstein
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  normal                               |   Milestone:  5.9
Component:  Media                                |     Version:  2.5
 Severity:  normal                               |  Resolution:
 Keywords:  php8 has-patch needs-dev-note has-   |     Focuses:
  unit-tests                                     |
-------------------------------------------------+-------------------------

Comment (by stevegs):

 Replying to [comment:31 adamsilverstein]:
 > In [attachment:"54385.10.diff"]
 > * Cleaned up strings, doc blocks a bit.
 > * Improved test case structure
 > * Add some new test cases for typical values after researching exif
 values that are passed to the function in our use.
 >
 > props @jrf for feedback on the GitHub draft PR.
 >
 > Thanks for the feedback @stevegs and @TobiasBg...  re: `str_contains`,
 in the latest patch I use `substr_count( $str, '/' )` to ensure the string
 contains one and only one `/` which @jrf suggested on the PR. What do you
 think?

 This seems to be the most elegant solution.  I've checked that
 `substr_count('2//5', '/')` returns 2, as does `substr_count('2/24/5',
 '/')` - so it will catch more than one / whether consecutive or not.  And
 it's backward compatible with PHP7.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54385#comment:33>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list