? ? ? Pending

User tests: Successful: Unsuccessful:

avatar sakiss
sakiss
17 Feb 2020

Summary of Changes

It triggers events after performing the basic finder indexer's actions.
The Indexer performs 3 tasks (index, delete, purge), though no any event triggered after they are finished.

Performing further actions can be very useful in cases like:
Caching, Meta-data generation, Filters generation, Logging.

Testing Instructions

Lets generate some log records for each event.

Open the file: plugins/finder/content/content.php

Within the class add/append the following code:

      	/**
	 * Triggered after saving an item or after running the indexer.
	 *
	 * @param   Result  $item
	 * @param   Int     $linkid
	 *
	 */
	public function onFinderIndexAfterIndex(Result $item, $linkId)
	{
		\Joomla\CMS\Log\Log::addLogger(array('text_file' => 'finder.log.php'), \Joomla\CMS\Log\Log::ALL, array('finder_plugin'));
		\Joomla\CMS\Log\Log::add('onFinderIndexAfterIndex Run after:' . $linkId, \Joomla\CMS\Log\Log::INFO, 'finder_plugin');
	}

	/**
	 * Triggered after deleting an item or pressing 'Delete' in com_finder.
	 * @param int $linkId
	 *
	 */
	public function onFinderIndexAfterDelete($linkId)
	{
		\Joomla\CMS\Log\Log::addLogger(array('text_file' => 'finder.log.php'), \Joomla\CMS\Log\Log::ALL, array('finder_plugin'));
		\Joomla\CMS\Log\Log::add('onFinderIndexAfterDelete Run after:' . $linkId, \Joomla\CMS\Log\Log::INFO, 'finder_plugin');
	}

	/**
	 * Triggered after purging (press 'Clear Index') in com_finder.
	 */
	public function onFinderIndexAfterPurge()
	{
		\Joomla\CMS\Log\Log::addLogger(array('text_file' => 'finder.log.php'), \Joomla\CMS\Log\Log::ALL, array('finder_plugin'));
		\Joomla\CMS\Log\Log::add('onFinderIndexAfterPurge Run after', \Joomla\CMS\Log\Log::INFO, 'finder_plugin');
	}

Expected result

After appending the above code, log events will be created for each Indexer's actions.
You can check the log records in the file: administrator/logs/finder.log.php

  1. Saving an existing article in com_content, 2 log records should be created:
    a. One with the message: onFinderIndexAfterDelete Run after
    b. One with the message: onFinderIndexAfterIndex Run after

  2. Pressing the "Clear Index" in the com_finder, 1 log record should be created with the message: onFinderIndexAfterPurge

  3. Deleting an item in com_finder, 1 log record should be created, with the message: onFinderIndexAfterDelete Run after

  4. Pressing the "Index" in the com_finder, multiple log records (as many as the indexed articles) should be created with the message: onFinderIndexAfterIndex Run after

*As it is clear all the above is just for testing purpose.

Documentation Changes Required

Not sure

avatar sakiss sakiss - open - 17 Feb 2020
avatar sakiss sakiss - change - 17 Feb 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 17 Feb 2020
Category Administration com_finder
f069f47 17 Feb 2020 avatar sakiss CS
avatar sakiss sakiss - change - 17 Feb 2020
Labels Added: ?
avatar sakiss sakiss - change - 17 Feb 2020
The description was changed
avatar sakiss sakiss - edited - 17 Feb 2020
avatar sakiss sakiss - change - 17 Feb 2020
The description was changed
avatar sakiss sakiss - edited - 17 Feb 2020
avatar sakiss sakiss - change - 17 Feb 2020
The description was changed
avatar sakiss sakiss - edited - 17 Feb 2020
avatar sakiss sakiss - change - 17 Feb 2020
The description was changed
avatar sakiss sakiss - edited - 17 Feb 2020
avatar sakiss sakiss - change - 17 Feb 2020
Title
[4.0] Trigger events after any Finder action (index, delete, purge)
[4.0] Trigger events on Finder actions (index, delete, purge)
avatar sakiss sakiss - edited - 17 Feb 2020
avatar sakiss sakiss - change - 17 Feb 2020
The description was changed
avatar sakiss sakiss - edited - 17 Feb 2020
avatar mateoAdi
mateoAdi - comment - 18 Feb 2020

I have tested this item successfully on 3e1674f

Works as described


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

avatar mateoAdi mateoAdi - test_item - 18 Feb 2020 - Tested successfully
avatar lefabdu51
lefabdu51 - comment - 24 Feb 2020

I have tested this item successfully on 3e1674f

I have tested this item succesfully - SHA: 3e1674


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

avatar lefabdu51 lefabdu51 - test_item - 24 Feb 2020 - Tested successfully
avatar SharkyKZ SharkyKZ - change - 24 Feb 2020
Status Pending Ready to Commit
avatar SharkyKZ
SharkyKZ - comment - 24 Feb 2020

RTC.


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

avatar rdeutz rdeutz - close - 24 Feb 2020
avatar rdeutz rdeutz - merge - 24 Feb 2020
avatar rdeutz rdeutz - change - 24 Feb 2020
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-02-24 19:56:40
Closed_By rdeutz
Labels Added: ? ?

Add a Comment

Login with GitHub to post a comment