• Resolved nicmare

    (@nicmare)


    Out of the blue i get this fatal error when trying to activate this awesome plugin:

    [18-Apr-2023 13:09:47 UTC] PHP Fatal error: Cannot declare class ComposerAutoloaderInitfaf42c5f235c65e8397793ae676be6da, because the name is already in use in /Users/nicb/_htdocs/mybricks2023/wp-content/plugins/query-monitor/vendor/composer/autoload_real.php on line 5

    but i used it before in the same project. what could be the cause / source of the problem?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter nicmare

    (@nicmare)

    i already remove it entirely and installed it again. i disabled every other plugin. always getting this error.

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Is there a wp-content/db.php file in place on your site? If so, does it belong to Query Monitor? If so, can you try deleting it please and then reactivating Query Monitor?

    Let me know how it goes.

    Thread Starter nicmare

    (@nicmare)

    holy sh*t this was the issue! i mean it was there but i removed it now then activated query monitor again and voila its working again! thank you a million @johnbillion !!

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    So that’s an issue that’s popped up a handful of times in the last decade or so and as far as I can tell it’s due to due the opcode cache on the server not always handling symlinks correctly. I’ve never had a chance to look into it because it goes away as soon as the file is deleted.

    Glad that was the issue.

    I’m having same issue on my staging site. I tried deleting wp-content/db.php both in main wp-content folder and (strangely) a wp-content folder in Query Monitor plugin folder. Didn’t help.

    A side note, Query Monitor runs perfectly on my live site.

    damien_vancouver

    (@damien_vancouver)

    The problem is that query-monitor creates an *absolute* link to the db.php file out of your wp-content. Then if you clone the site or copy it elsewhere, this link can point to somehwere you don’t hvae permission to.

    My db.php looked like this:

    db.php -> /home/olduser/public_html/wp-content/plugins/query-monitor/wp-content/db.php

    and it was red and angry because the newuser did not have access.

    I removed the symlink and re-added it relative instead:

    rm db.php
    ln -s plugins/query-monitor/wp-content/db.php

    if the plugin were to add the symbolic link this way (using a relative path to the wp-content folder) then it would not be so fragile and blow up when the site was cloned.

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Unfortunately using a relative symlink by default isn’t an option for two reasons:

    • The symlink() function in PHP cannot create a relative symlink on a Windows environment.
    • It’s not guaranteed that a relative path can be found between the wp-content directory and the db.php file in the plugin, for example if the plugin directory points elsewhere via the WP_PLUGIN_DIR constant. This is much more common than you might think.

    I just encountered this issue as well when I deployed my staging site to live: it crashed the site due to the symlink being absolute. I understand what you’re saying about using a relative symlink not being possible. I wonder if it’s worth at least printing an admin notice about this when the plugin is first activated, to warn users in case they move their site that they may need to update or recreate the link?

    Alternatively, is there a way to make the plugin work without this symlink? Can it find and use the actual db.php in the plugin directory?

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    You can delete the db.php file complete and QM will work fine, just with a little less info.

    I will try to find some time to look into how to avoid a fatal error under this condition.

    I have the same issue, deleting db.php change anything

    Fatal error: Cannot declare class ComposerAutoloaderInitad25d53a23099da4b0886b4f6754360e, because the name is already in use in /var/www/html/wordpress/…/plugins/query-monitor/vendor/composer/autoload_real.php on line 5

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Can you provide a list of the plugins that are active on your site please?

    Same problem. Deleting db.php doesn’t help.

    List of active plugins on site…

    ad-inserter
    admin-user-message
    all-in-one-wp-migration
    antispam-bee
    aryo-activity-log
    broken-link-checker
    classic-editor
    companion-auto-update
    generateblocks
    generateblocks-pro
    google-sitemap-generator
    gp-premium
    index.php
    insert-headers-and-footers
    mailgun
    query-monitor
    setowp
    wordpress-importer
    wordpress-seo
    wordpress-seo-premium
    wp-fail2ban
    wp-fastest-cache
    wp-smushit
    wpforms-lite
    wpmudev-updates

    I’m use to working on the command line, so if there’s any fix you’d like tested, pass it along + I’ll report back what occurs.

    File containing this class include…

    ack -ilr ComposerAutoloaderInitad25d53a23099da4b0886b4f6754360e .
    query-monitor/vendor/autoload.php
    query-monitor/vendor/composer/autoload_real.php

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.