• Resolved Marcelo Pedra

    (@kent-brockman)


    Hello guys, I started having this php error every time a new site is added to a WP multisite. It’s happenning the same as reported in this other topic:
    https://www.ads-software.com/support/topic/error-when-adding-new-site?replies=5

    The server is running on PHP 5.4.29, MySQL 5.6.16, Apache 2.4.9, and there are less than 30 sites here. All of them works well. The sites are correctly created, yet this error appears, and looks like it is thrown when the resulting page try to be shown. I simply hit the Back button in the browser, refresh the sites screen and continue working.

    This is the php error shown in screen:

    Warning: fopen(/home/SITENAME/public_html/wp-content/plugins/EMPTY): failed to open stream: No such file or directory in /home/SITENAME/public_html/wp-includes/functions.php on line 3879

    Warning: fread() expects parameter 1 to be resource, boolean given in /home/SITENAME/public_html/wp-includes/functions.php on line 3882

    Warning: fclose() expects parameter 1 to be resource, boolean given in /home/SITENAME/public_html/wp-includes/functions.php on line 3885

    Warning: Cannot modify header information – headers already sent by (output started at /home/SITENAME/public_html/wp-includes/functions.php:3879) in /home/SITENAME/public_html/wp-includes/pluggable.php on line 1121

    (The real folder path was replaced with “SITENAME”)

    Looks like it’s trying to open something inexistent (/home/SITENAME/public_html/wp-content/plugins/EMPTY)…

    I tried deactivating the Plugin Manager and then I can create sites without issues.

    What may be causing this?
    Anybody else having these issues?
    Any fix either?

    Thanks!

    https://www.ads-software.com/plugins/multisite-plugin-manager/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Marcelo Pedra

    (@kent-brockman)

    OH BOY, I THINK I FOUND WHERE THE BUG IS…

    I further investigated the error in /wp-includes/functions.php, line 3879. This line is inside function get_file_data() which is supposed to read the first 8Kb of metadata in plugins and themes, so an error here could be caused to trying to open an undefined or inexistent filename, or, let’s say, the function is called with incorrect params, or none at all.

    * Retrieve metadata from a file.
    *
    * Searches for metadata in the first 8kiB of a file, such as a plugin or theme.
    * Each piece of metadata must be on its own line. Fields can not span multiple
    * lines, the value will get cut at the end of the first line.
    *
    * If the file data is not within that first 8kiB, then the author should correct
    * their plugin file and move the data headers to the top.
    *
    * @see https://codex.www.ads-software.com/File_Header
    *
    * @since 2.9.0
    * @param string $file Path to the file
    * @param array $default_headers List of headers, in the format array(‘HeaderKey’ => ‘Header Name’)
    * @param string $context If specified adds filter hook “extra_{$context}_headers”

    The problem here starts when Plugin Manager is network activated. The question is when and from where is called the function get_file_data() with erroneous params. I did a grep in the same folder and I see these scripts call the function:
    /wp-includes/class-wp-theme.php: to identify metadata when listing themes.
    /wp-includes/i10n.php: to identify metadata in PO translation files (.po).
    /wp-admin/includes/plugin.php: to identify metadata in plugins.
    /wp-admin/includes/class-wp-upgrader.php: to identify metadata from available updates.

    Also, I found some other plugins are calling this function from its code:
    – jetpack
    – backwpup (network activated)
    – wpmudev-updates
    – woocommerce

    I tried deactivating backwpup and W3 total cache, but the issue persists. So, they aren’t a culprit.

    Please notice that in my Plugin Manager configuration I had not a single plugin set to be auto activated on site creation. I just have a couple VISIBLE (set as All Users) and others set as NONE.

    Then, I decided to set ONE plugin to be autoactivated, JetPack, why not, it’s a handy plugin. Then I created one site, and the PHP errors have gone… SO, IT’S JUST A SMALL, TINY, UNDETECTED BUG, THAT COMES UP WHEN YOU DONT SET AT LEAST ONE PLUGIN TO BE AUTOACTIVATED.
    So, here you have the tips to fix it and my name to mention in the changelog ??

    Cheers!

    OMG, thank you.

    Thread Starter Marcelo Pedra

    (@kent-brockman)

    Still unresolved. Waiting for the author answer ??

    Still waiting ??

    Thread Starter Marcelo Pedra

    (@kent-brockman)

    No updates since April. Looks like this could’ve been abandoned… ??

    Anyway, as I stated in the first post, the workaround is to set at least one plugin to be autoactivated. Then you’ll be ok.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP errors when adding new sites’ is closed to new replies.