Make WordPress Core

Opened 6 years ago

Closed 15 months ago

Last modified 4 weeks ago

#49979 closed defect (bug) (worksforme)

file_get_contents(): read of 8192 bytes failed with errno=21 Is a directory in /wp-includes/l10n.php on line 1096

Reported by: lwangaman's profile Lwangaman Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.4
Component: I18N Keywords: has-patch reporter-feedback
Focuses: Cc:

Description

Using PHP 7.4.5 I have started getting this error when editing pages in the admin area. Seems like "." and ".." are now being read along with the files in a directory perhaps.

For now I have patched my l10n.php with a further check if $file is a directory:

<?php
        /**
         * Filters the file path for loading script translations for the given script handle and text domain.
         *
         * @since 5.0.2
         *
         * @param string|false $file   Path to the translation file to load. False if there isn't one.
         * @param string       $handle Name of the script to register a translation domain to.
         * @param string       $domain The text domain.
         */
        $file = apply_filters( 'load_script_translation_file', $file, $handle, $domain );

        if ( ! $file || ! is_readable( $file ) || is_dir($file) ) {
                return false;
        }

        $translations = file_get_contents( $file );

Change History (7)

#1 @SergeyBiryukov
6 years ago

  • Keywords reporter-feedback removed

This ticket was mentioned in PR #257 on WordPress/wordpress-develop by kraftbj.


6 years ago
#2

Defensive coding to avoid an error when trying to file_get_contents of a directory.

I think this is an incomplete solution, though, as _why_ is a directory being passed. This would at least prevent the PHP warning.

Trac ticket: https://core.trac.wordpress.org/ticket/49979

#3 @kraftbj
6 years ago

  • Keywords has-patch added; needs-patch removed

#4 @ocean90
6 years ago

  • Keywords reporter-feedback added

Hello @Lwangaman, welcome to WordPress Trac!

Thanks for the report. Are you able to check what the value of $file is when a warning is thrown? Does it happen with specific plugins active? Adding a random is_dir() check should be avoided as it doesn't fix the root cause and this is probably also an issue for plugins using the filters in load_script_translations().

#5 @swissspidy
15 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

@SergeyBiryukov commented on PR #257:


4 weeks ago
#6

Thanks for the PR! Closing for now, as the associated Trac ticket has been closed.

gclapps0612-cmd commented on PR #257:


4 weeks ago
#7

Repor

On Fri, Dec 26, 2025, 07:18 Sergey Biryukov *@*.*>
wrote:

Closed #257 <https://github.com/WordPress/wordpress-develop/pull/257>.


Reply to this email directly, view it on GitHub
<https://github.com/WordPress/wordpress-develop/pull/257#event-21758785223>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BXZWJXARDJ4TUT7R2Y5EFAT4DURPRAVCNFSM6AAAAACQBZVO6OVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMRRG42TQNZYGUZDEMY>
.
You are receiving this because you are subscribed to this thread.Message
ID: *@*.*
com>

Note: See TracTickets for help on using tickets.