[wp-trac] [WordPress Trac] #58121: WP_Filesystem_SSH2::put_contents() assumes that PHP's file_put_contents() always returns in int
WordPress Trac
noreply at wordpress.org
Wed Apr 12 19:25:53 UTC 2023
#58121: WP_Filesystem_SSH2::put_contents() assumes that PHP's file_put_contents()
always returns in int
----------------------------+------------------------------
Reporter: pbiron | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Filesystem API | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
----------------------------+------------------------------
Comment (by pbiron):
No. And `WP_Filesystem_SSH2::put_contents()` does use strict comparison
when checking the return value from `file_put_contents()` so I don't think
any errors/warnings would be raised if `file_put_contents()` were to
return `false`.
So, maybe there's no change needed, but I just wanted to get other
opinions about whether we should change the conditional to:
{{{#!php
<?php
if ( false === $ret || strlen( $contents ) !== $ret ) {}
}}}
to avoid the call to `strlen()` when it's not necessary for an early
return.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58121#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list