[wp-trac] [WordPress Trac] #17120: Class WP_Importer references STDIN which is not available in Web Environments
WordPress Trac
wp-trac at lists.automattic.com
Wed Apr 13 09:58:12 UTC 2011
#17120: Class WP_Importer references STDIN which is not available in Web
Environments
--------------------------+----------------------------
Reporter: dd32 | Owner:
Type: defect (bug) | Status: new
Priority: low | Milestone: Future Release
Component: Import | Version: 3.0
Severity: minor | Keywords: needs-patch
--------------------------+----------------------------
STDERR is not defined in web environments (only certain CLI environments),
you can call fopen('php://stderr'); directly, however this is not
delivered to browsers.
Since this is in the Multisite code, CLI imports might be more common, but
it's not a given that multisite imports will not be run from the web
either.
Code ref:
http://core.trac.wordpress.org/browser/trunk/wp-admin/includes/class-wp-
importer.php#L128
{{{
126 $blog = 'http://' . preg_replace(
'#^https?://#', '', $blog_id );
127 if ( ( !$parsed = parse_url( $blog ) ) ||
empty( $parsed['host'] ) ) {
128 fwrite( STDERR, "Error: can not
determine blog_id from $blog_id\n" );
129 exit();
130 }
131 if ( empty( $parsed['path'] ) )
132 $parsed['path'] = '/';
133 $blog = get_blog_details( array( 'domain'
=> $parsed['host'], 'path' => $parsed['path'] ) );
134 if ( !$blog ) {
135 fwrite( STDERR, "Error: Could not
find blog\n" );
136 exit();
137 }
}}}
I'm unsure of the best way to tackle this, Ideally in a CLI environment we
want the error outputs going to STDERR, but since that's not available or
visible to web browsers, wp_die() would be a better choice.
One potential method would be to direct wp_die() to STDERR in CLI
environments - That might cause problems with the test suite however (I'm
unsure)
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17120>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list