Make WordPress Core

Opened 21 months ago

Last modified 21 months ago

#57884 new defect (bug)

[TinyMCE] class-wp-editor.php is emitting open_basedir restriction warning when using my own error handler

Reported by: arnolp's profile arnolp Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.9
Component: TinyMCE Keywords: dev-feedback
Focuses: Cc:

Description

My server has open basedir restrictions.

When editing a post on classical editor, on line 530, class-wp-editor checks for translations loaded for external TinyMCE 3.x plugins.

 if ( @is_file( $path . 'en_dlg.js' ) ) { ..

On standard case , "@"supress the errors as it should.

But I have, as many users, my own error handling for pushing error logs in external collector.
So "supress errors" @ seems to be non-effective;
and my logs are full of these :

"is_file(): open_basedir restriction in effect. File(/en_dlg.js) is not within the allowed path(s): (..) /wp/wp-includes/class-wp-editor.php","error_line":530

The correct way to check a potential outside of openbasedir restriction seems to be

 // Default error handler is required
    set_error_handler(null);

    // Clean last error info. You can do it using error_clean_last in PHP 7.
    @trigger_error('__clean_error_info');

    // Testing...
    @file_exists($path);

    // Restore previous error handler
    restore_error_handler();

as to why '$path' seems to be '/' ,thus checking file at server root, I have no clue ..

Change History (3)

#1 @hellofromTonya
21 months ago

  • Version changed from trunk to 3.9

Hello @arnolp,

Welcome to WordPress Core's Trac!

I'm updating the Version number from trunk (which would mean 6.2.0) to 3.9.0 which is when this code. Why? This specific code was introduced into Core via [27922] / #27610.

This ticket was mentioned in Slack in #core-test by juhise. View the logs.


21 months ago

#3 @juhise
21 months ago

  • Keywords dev-feedback added
Note: See TracTickets for help on using tickets.