Jump to content

Compile error on > v4.3.25


dynweb
 Share

Recommended Posts

Starting with version 4.3.26, I get a compile error after installing/upgrading Tracy:

Compile Error: Cannot declare interface Tracy\ILogger, because the name is already in use (line 16 of site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Logger/ILogger.php)

It seems that this commit https://github.com/adrianbj/TracyDebugger/commit/10e1d3a28a2719d120325eaf4559505c3ebd98a9 is source of the error. When removing the line

if(class_exists('\Tracy\Debugger') && Debugger::isEnabled()) return;

everything is working again.

Tested on PW 3.0.184 and 3.0.200. 

Any input will be appreciated -- I have no idea where to start ?

Link to comment
Share on other sites

Hi @dynweb - sorry you're having issues with this newer versions. However, I am struggling to understand why you're seeing that error. Do you see the same problem on other sites / servers? Does a Modules > Refresh help?

Link to comment
Share on other sites

Thank you, @adrian

I can reproduce the error on my local dev server and on the live server(s).

I already tried to to refresh modules and to clean the file compiler cache, to no avail.

I still have to test it with a pristine processwire install, I will let you know...

Link to comment
Share on other sites

Thanks for looking into it further. I have upgraded several sites on several several servers with no problems so far, so there must be some setting somewhere that's causing the problem. Maybe a Tracy module setting? I fresh install would be a helpful test, thanks. 

Link to comment
Share on other sites

OK, problem solved ?

Tracy is working with a pristine PW install.

All my "customized" installs have a vendor directory where I (previously) did a

composer require nette/nette

which also installs tracy in the vendor dir. And this version is loaded first, resulting in the "Cannot declare..." error. Thank you for your help, @adrian !

Link to comment
Share on other sites

It's still weird to me though because that new line I added should prevent Tracy being loaded a second time. Do you need that composer include, or can you remove it without affecting anything else?

Link to comment
Share on other sites

20 minutes ago, adrian said:

It's still weird to me though because that new line I added should prevent Tracy being loaded a second time. Do you need that composer include, or can you remove it without affecting anything else?

Seems as if Debugger::isEnabled() returns false after a fresh composer install so it can't prevent double loading.

I just have to be careful not to require tracy/tracy via composer (or nette/nette that adds *all* packages), so this shouldn't be a major problem ? 

Link to comment
Share on other sites

Good point - perhaps I can just remove that second part of the check and leave it as simply:

if(class_exists('\Tracy\Debugger')) return;

Does that work for you with nette included via composer?

Link to comment
Share on other sites

2 hours ago, adrian said:
if(class_exists('\Tracy\Debugger')) return;

Does that work for you with nette included via composer?

Not really ? At this point, Debugger is probably not enabled, so no output at all.

if(class_exists('\Tracy\Debugger')) {
	\Tracy\Debugger::enable();
	return;
};

This one works, but the Tracy bar has none of the ProcessWire specific info (as the init() method returns early).

if(class_exists('\Tracy\Debugger')) {
	$this->wire('session')->error('Cannot activate TracyDebugger because another version is already installed, maybe via composer?');
	return;
};

This kind of error message, however, would be really helpful for people like me who don't remember the stuff they have in their vendor directory...

Link to comment
Share on other sites

3 hours ago, dynweb said:

This one works, but the Tracy bar has none of the ProcessWire specific info (as the init() method returns early).

Ah, yes of course.

4 hours ago, dynweb said:

This kind of error message, however, would be really helpful for people like me who don't remember the stuff they have in their vendor directory...

I like the idea, but the problem is that sometimes it seems like it's possible for Tracy to double load without the composer files, which is why this line was added in the first place. Maybe I need to install nette via composer myself and see if I can reproduce and come up with a better check.

Link to comment
Share on other sites

4 hours ago, adrian said:

I like the idea, but the problem is that sometimes it seems like it's possible for Tracy to double load without the composer files, which is why this line was added in the first place. Maybe I need to install nette via composer myself and see if I can reproduce and come up with a better check.

 

if(class_exists('\Tracy\Debugger', false) && Debugger::isEnabled()) return;

Works for me. We just tell PHP to skip autoloading, so it will never know about the composer version.

  • Like 1
Link to comment
Share on other sites

11 hours ago, dynweb said:

 

if(class_exists('\Tracy\Debugger', false) && Debugger::isEnabled()) return;

Works for me. We just tell PHP to skip autoloading, so it will never know about the composer version.

Awesome - thank you! I had forgotten that class_exists tries to load unless you set that optional autoload argument to false. I've made that change so the new version has it.

Thanks again.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...