Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot declare class Perflab_Server_Timing_Metric #1150

Closed
slh012 opened this issue Apr 16, 2024 · 10 comments
Closed

Cannot declare class Perflab_Server_Timing_Metric #1150

slh012 opened this issue Apr 16, 2024 · 10 comments
Labels
[Type] Bug An existing feature is broken

Comments

@slh012
Copy link

slh012 commented Apr 16, 2024

Bug Description

[16-Apr-2024 12:35:05 UTC] PHP Fatal error: Cannot declare class Perflab_Server_Timing_Metric, because the name is already in use in /home/DOMAIN/wp-content/plugins/performance-lab/includes/server-timing/class-perflab-server-timing-metric.php on line 14

Steps to reproduce

Access any web page

Screenshots

Additional Context

  • PHP Version: 7.4
  • OS: [e.g. iOS] Linux
  • Browser: [e.g. chrome, safari] Chrome
  • Plugin Version: [e.g. 22] See below
  • Device: [e.g. iPhone6] PC/Chrome

Contributors: wordpressdotorg
Requires at least: 6.4
Tested up to: 6.5
Requires PHP: 7.0
Stable tag: 3.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: performance, site health, measurement, optimization, diagnostics

@slh012 slh012 added the [Type] Bug An existing feature is broken label Apr 16, 2024
@westonruter
Copy link
Member

This seems to be something unique to your setup. Do you by chance have multiple copies of the Performance Lab plugin active somehow?

@jamesozzie
Copy link

A couple of additional reports of this added to this support topic, one whereby a user shared their Site Health info. I haven't been able to replicate the same, upgrading from 2.9.0 to 3.

@westonruter
Copy link
Member

As we chatted about earlier, I suspect this may be a problem with the WP update mechanism and possibly in relation to PHP's OPcache (maybe Core-60397?). If the OPCache is not flushed during upgrade, then it can possibly load stale PHP files which can result in this issue. Nevertheless, flushing of the OPcache is supposed to be done by core when plugins are updated.

@slh012
Copy link
Author

slh012 commented Apr 17, 2024

I'll re-enable the plugin and clear the cache and get back to you.

@mukeshpanchal27
Copy link
Member

This sounds like a cache-related issue. If somehow the root server-timing code files didn't get removed during the plugin upgrade, it could still be not called through the plugin.

In the previous versions (2.9, 2.8, etc..), we loaded those files like this:

require_once PERFLAB_PLUGIN_DIR_PATH . 'server-timing/class-perflab-server-timing-metric.php';
require_once PERFLAB_PLUGIN_DIR_PATH . 'server-timing/class-perflab-server-timing.php';
require_once PERFLAB_PLUGIN_DIR_PATH . 'server-timing/load.php';
require_once PERFLAB_PLUGIN_DIR_PATH . 'server-timing/defaults.php';

And in version 3.0, we changed it to:

require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/class-perflab-server-timing-metric.php';
require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/class-perflab-server-timing.php';
require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/load.php';
require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/defaults.php';

So there is no way to load the previous location files.

Could you please share the code from your root load.php file and a screenshot of the plugin files so we can troubleshoot it further?

@mfru
Copy link

mfru commented Apr 18, 2024

Hi, the same happened to a client of mine, the error started popping up on April 16th

[16-Apr-2024 01:25:01 UTC] PHP Fatal error: Cannot declare class Perflab_Server_Timing_Metric, because the name is already in use in /home/redacted/public_html/wp-content/plugins/performance-lab/includes/server-timing/class-perflab-server-timing-metric.php on line 14

After reading this thread I noticed that there is an includes folder present as well as a server-timing folder.

After renaming the server-timing folder the error goes away. So I think it is safe to delete as the newer code is present.

What I can't explain is how the error began. The plugin is not scheduled to auto-update, but on April 16th the new includes folder was created.

image

@westonruter
Copy link
Member

@mfru Very interesting that there is both an includes and a server-timing directory, as the server-timing directory was removed in 3.0.0. In fact, I see quite a few files that are not present in the 3.0.0 release, including:

  • admin
  • build-cs
  • modules
  • default-enabled-modules.php
  • module-i18n.php
  • uninstall.php

These files are only in the 2.9.0 release.

So it seems that WordPress core's plugin update was not completely successful. I suggest downloading plugin ZIP from WordPress.org and re-installing it to make sure only the expected files are present.

@westonruter
Copy link
Member

Another user who experienced the same issue: #1180

@LloydConrade
Copy link

Experienced the same issue also from 15/16-April-2024. Renaming the server-timing folder as suggested by @mfru rectified the issue. (What was more confusing in my instance was that the .com.au domain name was not renewed 12 days before domain name expiry, as apparently required of .com.au domains, leading to an accumulation of issues one on top of the other.)

@westonruter
Copy link
Member

It seems this is not a problem with the plugin itself but rather with WordPress's plugin update routine. So I'm going to close this, as the best place to report this problem would be in Trac.

@westonruter westonruter closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature is broken
Projects
None yet
Development

No branches or pull requests

6 participants