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
Added new event Archiving.makeNewArchiverObject to allow customising plugin archiving #10366
Added new event Archiving.makeNewArchiverObject to allow customising plugin archiving #10366
Conversation
@@ -194,6 +195,14 @@ private static function getPluginArchiverClass($pluginName) | |||
*/ | |||
protected function shouldProcessReportsForPlugin($pluginName) | |||
{ | |||
$shouldPreventProcessing = false; | |||
|
|||
Piwik::postEvent('PluginsArchiver.shouldProcessReportsForPlugin',[$pluginName, $this->params, &$shouldPreventProcessing]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[]
-Array notation is not compatible with PHP 5.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for catching that, fixed
Have you tested whether they will be still archived later eg when archiving everything via CLI and later requesting a report via UI? Have you tested what happens when browser archiving is disabled / enabled? To make this universally work we might need to add some more features as it might work for this specific use case but not in another use case |
Ok, I fixed code style notes. I think that any plugins blocked from archiving with that hook will not be archived in future, as archive will be completed and closed, so only archive invalidation may bring a chagne here. If you see any specific cases needing attention right now, please let me know how to proceed with this addition? |
Hi @mgazdzik
if your use case is to prevent heavy archiving of one plugin, when you skip a plugin archiving using this hook, how will you process this plugin's reports afterwards? Or do you not need the plugin's reports maybe? |
IMO the platform should take care of it and not a plugin developer as it will be basically impossible for developers to do this unless it's intention is really to never archive a report eg for a specific site. Then the event has some right to exist without tackling these issues. In such a case we should maybe rename the event so the consequences will be clear for a developer (that it won't be archived at any time unless custom work is done) |
In my case it is not necessary to process those missing plugins after archive is completed. It's that at given time it is necessary to disable certain plugin archiving (for ex. only disable actions archiving for month period for one site) and it's acceptable that this data will simply be missing, unless period is re-archived. However higher goal here is to allow all other periods/sites to finish archiving of given plugin. As for event name I'm totally up for renaming. Maybe something like |
I was more thinking of something like I think to make this event useful it would be good to have the possibility to exclude certain reports from processing during browser archiving but still execute it while running on the CLI or to still include it in the final archive of the day. Like a parameter "$isFinalArchivingForGivenPeriod" but I think we might not know when this is. It would be a nice feature to sometimes ignore archiving some archives eg when requesting "today" via browser. Then we could eg only archive some reports every hour while some others are archived every 150s. In every case it would be useful to have a report in the "final" archive for that period though. It's not in your case the case :) but it would be much more useful for others this way. Do you actually need the event or can you not take care of this in the plugin archiver class? You get all the parameters there etc. and could make it even easier testable this way etc. Otherwise maybe an event name like FYI: Maybe we could consolidate a couple of archive events under the same namespace (for Piwik 3 or Piwik 4). It's confusing to have so many different namespaces there. |
My case is strictly related to preventing other plugins from archiving under certain circumstances. As for my specific use case - I have a plugin doing something, and during this plugin working I want a controll over what other plugins will be archived. For ex. I want to prevent 'Actions' plugin from processing when certain plugin setting is defined in my plugin. However, I still want to archive Actions plugin for other cases (some idsites, some periods, etc.), in which plugin will not block archiving. Also I want Action reports and API to be still available, which rules out way of disabling plugin. I hope it clarifies a bit of what is my intention with that specific event. Please let me know which way of proceeding do you find most generic for the platform? |
Hi @mgazdzik
we reuse the namespace In the patch above we should also implement the disable() method (and add the flag in isEnabled() And also document the event similarly to http://developer.piwik.org/api-reference/events#trackermakenewvisitobject etc. If it sounds good to you please update PR and we'll get this merged for next release 👍 |
@mattab - I gave a thought to idea you described. So if I understand correctly, I should use that new hook in plugin and if logic fits - just call |
@mgazdzik Yes that's what we meant 👍 could you add a comment for the Event so the Event doc will appear automatically like on http://developer.piwik.org/api-reference/events#trackermakenewvisitobject |
@mattab sure, I've just added phpdoc. Please let me know should I improve anything in phpdoc or is it ok? |
@mgazdzik made minor suggestions in mgazdzik#1 - can you merge and then i'll merge this |
Event description more consistent
@mattab PR merged, thanks for docs suggestions |
* Fix Scheduled Reports sent one hour late in daylight saving timezones (#10443) * convert hour to send report to/from UTC, to ensure it isn't affected by daylight savings * adds update script to change existing scheduled reports to use utc time * code improvement * adds missing param * Added new event Archiving.makeNewArchiverObject to allow customising plugin archiving (#10366) * added hook to alllow plugin archiving prevention * cr code style notes * reworked PR to fit CR suggestions * added PHPDoc for hook * Event description more consistent * UI tests: minor changes * Adds test checking if all screenshots are stored in lfs * removed screenshots not stored in lfs * readds screenshots to lfs * 2.16.3-b4
* Fix depraction test: use assertDeprecatedMethodIsRemovedInPiwik3 * Fix Scheduled Reports sent one hour late in daylight saving timezones (#10443) * convert hour to send report to/from UTC, to ensure it isn't affected by daylight savings * adds update script to change existing scheduled reports to use utc time * code improvement * adds missing param * Added new event Archiving.makeNewArchiverObject to allow customising plugin archiving (#10366) * added hook to alllow plugin archiving prevention * cr code style notes * reworked PR to fit CR suggestions * added PHPDoc for hook * Event description more consistent * UI tests: minor changes * Comment out Visitor Log UI tests refs #10536 * Adds test checking if all screenshots are stored in lfs * removed screenshots not stored in lfs * readds screenshots to lfs * 2.16.3-b4 * Issue translation updates against 2.x-dev * language update * Fix bug in widget list remove where the JSON object becomes array * 2.16.3-rc1 * console command custom-piwik-js:update should work when directory is writable and file does not exist yet (#10576) * followup #10449 * Fix test (cherry picked from commit fac3d63) * Prevent chmod(): No such file or directory * Automatically update all marketplace plugins when updating Piwik (#10527) * update plugins and piwik at the same time * make sure plugins are updated with piwik * use only one try/catch * reload plugin information once it has been installed * make sure to clear caches after an update * fix ui tests * make sure to use correct php version without any extras * Additional informations passed in the hook "isExcludedVisit" (issue #10415) (#10564) * Additional informations passed in the hook "isExcludedVisit" (issue #10415) * Added better description to the new parameters * Update VisitExcluded.php * Remove two parameters not needed as better to use the Request object * Update VisitExcluded.php * remove extra two parameters in VisitExcluded constructor to prevent confusion (#10593) * Update our libs to latest #10526 * Update composer libraries to latest #10526 * Update log analytics to latest * When updating the config file failed (or when any other file is not writable...), the Updater (for core or plugins) will now automatically throw an error and cancel the update (#10423) * When updating the config file failed (or when any other file is not writable...), the Updater (for core or plugins) will now automatically throw an error and cancel the update * add integration test to check the correct exception is thrown when config not writabel * New integration test for updater * Make test better * When opening the visitor profile, do not apply the segment (#10533) * When opening the visitor profile, do not apply the segment * added ui test for profile but does work for me * next try to make ui test work * add expected screenshot * added missing doc
ref #10367