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

[4.1] Log deprecated only when explicitly requested #31143

Merged
merged 11 commits into from Aug 20, 2021

Conversation

Fedik
Copy link
Member

@Fedik Fedik commented Oct 18, 2020

Summary of Changes

Try to fix performance issue #30997.
I have added proxy method Log::deprecated(), to use for deprecation log, which doing log only when log_deprecated is On.

However here a little caveats:
First: The patch add Application dependency to Log class.
Second: The method may be called when Application is not initialized, then the method will do nothing, such logs may be missed in log output. This affect logs from bootup process. (Actually this is true for all bootup logs)

Use of trigger_error() for log for deprecated messages.

@wilsonge @HLeithner please review

Testing Instructions

Apply patch.
Enable debug.
In global config enable "Log Deprecated API"
In the debug plugin disable "Log Entries"

Open any page (example /administrator/index.php?option=com_config)
check Debug Bar and note rendering time,

Then in global config disable "Log Deprecated API", refresh the same page,
check Debug Bar and note rendering time,

Actual result BEFORE applying this Pull Request

Debug Bar does not show logs but rendering time still huge.
At administrator/index.php?option=com_config I got around 3s

Expected result AFTER applying this Pull Request

Debug Bar does not show logs and rendering time is smaller.
At administrator/index.php?option=com_config I got around 270ms

Documentation Changes Required

none

@HLeithner
Copy link
Member

I would say we should target this for 3.10 (but didn't looked at it now)

@SharkyKZ
Copy link
Contributor

Going forward trigger_error() should be used to trigger deprecation warnings.

@Fedik
Copy link
Member Author

Fedik commented Oct 18, 2020

Going forward trigger_error() should be used to trigger deprecation warnings.

I do not know what a performance of this approach.
In past I seen complains about such approach, but did not tested by myself.

@SharkyKZ
Copy link
Contributor

SharkyKZ commented Oct 18, 2020

It doesn't automatically solve the issue you're trying to solve. But if Joomla\CMS\Log\Log::add() calls for deprecation logging are being replaced by anything, it should trigger_error(). Any changes you need then should be done either in Joomla\CMS\Exception\ExceptionHandler::handleUserDeprecatedErrors() or whatever it ends up calling.

Also configuration should be read from configuration file. If Joomla\CMS\Factory::getApplication() or application's get() method gets deprecated, current code will result in infinite loop.

@Fedik
Copy link
Member Author

Fedik commented Oct 18, 2020

If Joomla\CMS\Factory::getApplication() or application's get() method gets deprecated, current code will result in infinite loop.

nope

well, can be, but that problem of that guy who will make it deprecated 😄

@SharkyKZ
Copy link
Contributor

Screenshot_2020-10-18 Maximum function nesting level of '256' reached, aborting (500 Whoops, looks like something went wron

@Fedik
Copy link
Member Author

Fedik commented Oct 18, 2020

Yea I already understood what you meant, the same is true if "Log::add" become deprecated, even with trigger_error.
Just ignore these edge cases ;)

@SharkyKZ
Copy link
Contributor

It's not an edge case. You are adding a broken dependency where there should be no dependencies. As for Log::add() getting deprecated, it's a poor example. You obviously wouldn't make Log:add() calls inside Log::add() itself.

@HLeithner
Copy link
Member

I think that's one of the rare cases we could use Factory::getContainer()->get('application');

@SharkyKZ
Copy link
Contributor

🤦‍♂️

@Fedik
Copy link
Member Author

Fedik commented Oct 18, 2020

@SharkyKZ I understood what you talked about, but this does not help to fix anything 😉
About extra dependency I have wrote in the initial comment, I did not found a better way for now.

As another idea: can try adopt Symfony ErrorHandler somehow (for catch PHP errors/deprecation), but I have no idea how it may work, and whether it will help to avoid performance issue.
With this the option log_deprecated should modify error_reporting() to enable E_USER_DEPRECATED

@Fedik
Copy link
Member Author

Fedik commented Oct 18, 2020

Well,forget all,
I think we can switch E_USER_DEPRECATED on Application bootup, and then read it in Log::deprecated

I try to test how it work, and update PR some time later.

@wilsonge
Copy link
Contributor

I don't think this is right. We have a category system specifically to ensure full interopability with other logging systems (also the category system on more complicated sites actually allows a lot of granularity via plugins). If we have performance issues we need to fix them - not hide them away. Has anyone actually tried figuring out what our performance issues are?

@Fedik
Copy link
Member Author

Fedik commented Oct 19, 2020

Has anyone actually tried figuring out what our performance issues are?

call Log::add() 3000 times, even if log_deprecated set to Off

@Fedik
Copy link
Member Author

Fedik commented Oct 19, 2020

but If you asking why Log::add() become so slow,
there a couple potential reasons: from use of regexp to load debug_backtrace, both is required log features :)

@Fedik
Copy link
Member Author

Fedik commented Oct 24, 2020

I have changed much stuff, now it better I hope 😄

Also since now, must be used @trigger_error('blabla message', E_USER_DEPRECATED) for deprectated stuff. As @SharkyKZ suggested.

@HLeithner @wilsonge check check

upd: it cannot be ported to 3.10, unless this #30317 patch will be ported also

@Fedik
Copy link
Member Author

Fedik commented Dec 2, 2020

do we have a chance to have it in, before next beta? :)

@JonasAtZwetschke
Copy link

I have tested this item ✅ successfully on 3ccf3aa


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31143.

@ghost
Copy link

ghost commented Jan 22, 2021

I have tested this item ✅ successfully on 3ccf3aa


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31143.

@richard67
Copy link
Member

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31143.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jan 22, 2021
@rdeutz
Copy link
Contributor

rdeutz commented Mar 10, 2021

I am moving this to 4.1, we are in beta and this is a new feature. Thank you all who have been working on this and bringing it to the state it is now. But if we want to get 4.0 out of the door we need to make a cut.

Side note: this decision has be discussed in the production department and the maintainers team. It's not just mine even if I support the decision.

@rdeutz rdeutz changed the base branch from 4.0-dev to 4.1-dev March 10, 2021 19:06
@rdeutz rdeutz changed the title [4.0] Log deprecated only when explicitly requested [4.1] Log deprecated only when explicitly requested Mar 10, 2021
 Conflicts:
	installation/template/message.php
@Fedik
Copy link
Member Author

Fedik commented Aug 20, 2021

conflict fixed :)

@bembelimen bembelimen added this to the Joomla 4.1 milestone Aug 20, 2021
@bembelimen bembelimen merged commit fba6758 into joomla:4.1-dev Aug 20, 2021
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Aug 20, 2021
@bembelimen
Copy link
Contributor

Thanks

@Fedik Fedik deleted the log-deprecated branch August 20, 2021 13:16
thednp pushed a commit to thednp/joomla-cms that referenced this pull request Sep 22, 2021
* log:logDeprecated

* use new log method

* new log method, improve callStack lookup

* phpcs

* phpcs

* Check deprecation logging on boot

* trigger_error everywhere

* use namespaced classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants