? ? Pending

User tests: Successful: Unsuccessful:

avatar regularlabs
regularlabs
13 May 2021

Summary of Changes

This PR adds the ability to show extra data in User Action Log.
image

The way to use this is to add an extra language key in the messageLanguageKey passed to the addLog() method, divided by a comma.
So for instance in the action log plugin:

$messageLanguageKey = 'MY_ACTIONLOG_STRING,MY_ACTIONLOG_STRING_EXTRA";

$this->addLog(array($message), $messageLanguageKey, $context);

In above example the strings could be:

MY_ACTIONLOG_STRING="User <a href='{accountlink}'>{username}</a> sent a newsletter"
MY_ACTIONLOG_STRING_EXTRA="Newsletter title: {nl_title}<br>Group: {nl_group}<br>Recipients: {nl_recipients}"

Testing Instructions

Easiest would be to just create an extra language string via the Language Overrides for PLG_SYSTEM_ACTIONLOGS_USER_UPDATED_EXTRA:

User ID: {userid}

Then save your profile.

Then in the database, change the message_language_key value for that lag entry from:

PLG_SYSTEM_ACTIONLOGS_CONTENT_UPDATED

to:

PLG_SYSTEM_ACTIONLOGS_CONTENT_UPDATED,PLG_SYSTEM_ACTIONLOGS_USER_UPDATED_EXTRA

(You can of course go wild and test this with a custom created action log plugin. Or change one of the core plugins)

Actual result BEFORE applying this Pull Request

image

Expected result AFTER applying this Pull Request

image

Documentation Changes Required

Add instructions on the ability to use the extra language string as described above.

avatar regularlabs regularlabs - open - 13 May 2021
avatar regularlabs regularlabs - change - 13 May 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 May 2021
Category Administration
avatar regularlabs
regularlabs - comment - 13 May 2021

If this is something that gets accepted, then would it be possible to also port this to Joomla 3?
The changes are minimal, and it is fully backwards compatible. It does not change anything for existing log messages or action log plugins. It just adds functionality available for extension developers (or even core).

avatar ceford
ceford - comment - 14 May 2021

Can you explain how the comma separated string keys get into the action log record in everyday use. I don't see any other method than hard-coding.


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

avatar regularlabs
regularlabs - comment - 14 May 2021

What do you mean by hard-coded?
The action log plugins are responsible for adding records to the action_logs database table.
This PR gives the (3rd party) action log plugins the ability to add extra information that is too long or messy to add as the main title.

So a 3rd party action log plugin could do something like this:

$messageLanguageKey = 'MY_ACTIONLOG_STRING,MY_ACTIONLOG_STRING_EXTRA";

$this->addLog(array($message), $messageLanguageKey, $context);

And pass on any data in the $message that can either be displayed by the first main title or by the extra info string (or both).

This PR does nothing to the behavior of any core action log plugins. So the test with the extra PLG_SYSTEM_ACTIONLOGS_USER_UPDATED_EXTRA was just a way to test if it works, without having to create an action log plugin that uses this functionality.

avatar brianteeman
brianteeman - comment - 14 May 2021

Looks like a great idea

avatar regularlabs
regularlabs - comment - 14 May 2021

I would for instance use thins for my extension DB Replacer:
image

In the panel on the Admin home screen (dashboard) nothing changes. So it still just shows:
image

avatar ceford ceford - test_item - 14 May 2021 - Tested successfully
avatar ceford
ceford - comment - 14 May 2021

I have tested this item successfully on 0c937f9

Thanks for the clarification - this works as described in the test and I understand now it is intended for use by third party plugins.


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

avatar AndySDH AndySDH - test_item - 14 May 2021 - Tested successfully
avatar AndySDH
AndySDH - comment - 14 May 2021

I have tested this item successfully on 0c937f9


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

avatar PhilETaylor
PhilETaylor - comment - 14 May 2021

Is there a reason you went for a comma separated list of language strings rather than a more normal PHP Array?

avatar regularlabs regularlabs - change - 14 May 2021
Labels Added: ? ?
avatar regularlabs
regularlabs - comment - 14 May 2021

Is there a reason you went for a comma separated list of language strings rather than a more normal PHP Array?

Because the addLog expects a string

  • It would need a lot more code changes for that to accept a mixed value (string|array): type checking, converting from string to array and/or back, etc.
  • I don't like it when a method accepts mixed data types in attributes.
  • It would change the public signature of the method... which could potentially cause issues with classes extending on that model.

So this is the path of least resistence.

avatar PhilETaylor
PhilETaylor - comment - 14 May 2021

So this is the path of least resistence.

I hear ya...

avatar joomdonation
joomdonation - comment - 15 May 2021

So I looked at the PR again and I'm unsure if we really need the change in this PR? What prevent us from merging content of the two language items into a single one and don't have to change code? For example, I can change the language item and get the result in this screenshot

user_action_logs

Also, could not say that I like the way we put multiple language items into a single field in database like this. If we can add extra language item, someone could ask why he could not add the third language item... The way we are using here looks like a workaround only.

avatar regularlabs
regularlabs - comment - 15 May 2021

@joomdonation Because that will also make that extra info show up in the control panel on the dashboard. Which we don't want, as it is supposed to stay clean and simple.

avatar regularlabs
regularlabs - comment - 15 May 2021

Regarding the 'workaround': yes, of course it would be nice to have a separate table column for this string, and add it as the 3rd attribute in the addLog() method (pushing $context to the 4th).
But like explained before, I don't think we are at a stage now to cause that much disruption and BC breaks for something like this.

Even more so if we also push this change down to Joomla 3 (which I hope may be done!)

avatar joomdonation
joomdonation - comment - 15 May 2021

Because that will also make that extra info show up in the control panel on the dashboard. Which we don't want, as it is supposed to stay clean and simple.

Thanks Peter. I understand the reason now.

of course it would be nice to have a separate table column for this string, and add it as the 3rd attribute in the addLog() method (pushing $context to the 4th)

We can always add that new parameter to the end, thus backward compatible, and the code would be nicer and gain a tiny performance improvement. But I'm unsure if it is really needed. I would do that if it is possible, but that's just my personal feeling. If everyone else is OK, I'm fine.

Even more so if we also push this change down to Joomla 3 (which I hope may be done!)

From what I see, look like maintainers does not accept new features anymore. So guess this could not be backported to Joomla 3.

avatar joomdonation
joomdonation - comment - 15 May 2021

@regularlabs If you don't want to make that extra change, please let us know. We will ping testers for testing it again and let's maintainers make decision.

avatar regularlabs
regularlabs - comment - 15 May 2021

Well, the change to the addLog() method still means:

  • It would change the public signature of the method... which could potentially cause issues with classes extending on that model.
avatar regularlabs
regularlabs - comment - 15 May 2021

I am happy to change it. But I cannot oversee the issues it might cause...

avatar joomdonation
joomdonation - comment - 15 May 2021

I could not see reason someone would extends that class or override that method. So if you could make the change, that would be great. But please only do that if you think that it's right. Otherwise, keep it as how it is and let's maintainers decide about it. This is just my personal feedback.

avatar regularlabs
regularlabs - comment - 15 May 2021

And it would change from:

public function addLog($messages, $messageLanguageKey, $context, $userId = null)

to:

public function addLog($messages, $messageLanguageKey, $context, $userId = null, $messageLanguageKeyExtra = '')

Which to me does not seem very logical, tbh.

avatar joomdonation
joomdonation - comment - 15 May 2021

Which to me does not seem very logical, tbh.

Agree. But sometime we will have to accept the illogical for backward compatible reason :)

avatar regularlabs
regularlabs - comment - 15 May 2021

There is a ActionLogPlugin::addLog() too, with the same signature. That would also need changing.

avatar regularlabs
regularlabs - comment - 15 May 2021

So I would say: let the maintainers decide about it...

avatar HLeithner HLeithner - change - 15 May 2021
Title
[J4.0] Adds ability to show extra data in User Action Log
[J4.1] Adds ability to show extra data in User Action Log
avatar HLeithner HLeithner - edited - 15 May 2021
avatar HLeithner
HLeithner - comment - 15 May 2021

Can you please rebase this on 4.1 or I can do it for you. Adding this could make sense but not for 4.0 at this state

avatar HLeithner HLeithner - change - 15 May 2021
Title
[J4.1] Adds ability to show extra data in User Action Log
[4.1] Adds ability to show extra data in User Action Log
avatar HLeithner HLeithner - edited - 15 May 2021
avatar PhilETaylor
PhilETaylor - comment - 15 May 2021

Can you please rebase this on 4.1

Is there a date for that release, or timeframe after Joomla 4.0.0 Stable decided yet?

avatar regularlabs
regularlabs - comment - 15 May 2021

Why not for Joomla 4.0? It doesn't change any core behavior...
And release of Joomla 4 stable is still 18 months away!

avatar brianteeman
brianteeman - comment - 15 May 2021

sed -i 's/months/hours/g'

avatar regularlabs
regularlabs - comment - 15 May 2021

"Can you please rebase this on 4.1"
Nope, not doing that. Joomla 4.0 is far from done. I tried again to improve the current Joomla. But alas.

Joomla 3 has been stale for ages - 350 million children have been born since Joomla 3.9.0 released.
Joomla 4 is not ready, but for some weird reason, 'we' decide to not accept things that improve it (for core or extension developers), but push anything to a next version that will probably take another 300 million babies before it sees the light of days.

This sucks the fun right out of trying to contribute.

I know, I know... writing this here solves nothing and s same-old same-old.
But again, I feel like I wasted my freaking time and am again deciding to forget about trying to contribute to a big slow behemoth. Of to my own coding.

Do with this what you want.

PS: next time I create a PR for whatever, please close it and refer me to this!

avatar regularlabs regularlabs - change - 15 May 2021
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2021-05-15 10:33:43
Closed_By regularlabs
Labels Added: ?
Removed: ?
avatar regularlabs regularlabs - close - 15 May 2021

Add a Comment

Login with GitHub to post a comment