? Failure

User tests: Successful: Unsuccessful:

avatar eorisis
eorisis
26 May 2017

This PR fixes the index() method of the "Plugin Smart Search - Categories" so that the element of the extension being checked is correct.

Pull Request for Issue #15850 .

Expected result

No warnings, get the category indexed.

Actual result

A warning is displayed such as:
Error loading component: com_example.section, Component not found.
Plus, the category does not get indexed.

System information (as much as possible)

PHP Built On: Linux development-server 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30) x86_64
Database Version: 5.5.55-0+deb8u1
Database Collation: utf8mb4_unicode_ci
Database Connection Collation: utf8mb4_general_ci
PHP Version: 5.6.30-0+deb8u1
Web Server: Apache
WebServer to PHP Interface: cgi-fcgi
Joomla! Version: Joomla! 3.7.2 Stable [ Amani ] 22-May-2017 09:46 GMT
Joomla! Platform Version: Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
User Agent Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0

The Fix

Explode $item->extension and take the first value of the array as the actual element of the extension into a variable $extension_element and then use that variable in all the rest of the index() method.

Additional comments

When a component uses category sections such as com_example.section, every such category gets stored in the "categories" table, "extension" column, with such a value and not just the extension element. While the "Content - Smart Search" and "Smart Search - Categories" plugins are enabled, if you attempt to save, trash, publish/unpublish a category, the method index() in /plugins/finder/categories/categories.php takes the $item from the database and does not check the extension value before proceeding, but directly fires the following check:

// Check if the extension that owns the category is also enabled.
if (JComponentHelper::isEnabled($item->extension) == false)
{
	return;
}

In this case isEnabled() will pass the wrong value to load() which will consider it a fatal error on this part:

if (empty(static::$components[$option]))
{
	/*
	 * Fatal error
	 *
	 * It is possible for this error to be reached before the global JLanguage instance has been loaded so we check for its presence
	 * before logging the error to ensure a human friendly message is always given
	 */

	if (JFactory::$language)
	{
		$msg = JText::sprintf('JLIB_APPLICATION_ERROR_COMPONENT_NOT_LOADING', $option, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'));
	}
	else
	{
		$msg = sprintf('Error loading component: %1$s, %2$s', $option, 'Component not found.');
	}

	JLog::add($msg, JLog::WARNING, 'jerror');

	return false;
}

This will cause a warning displayed in the browser that looks like this:
Error loading component: com_example.section, Component not found.

Also, it will not get indexed by the Smart Search component. I am not aware of what else wrong happens. I was able to track this problem since Joomla 3.7.0 (still exists in 3.7.2) because of the changes in the above methods, while in 3.6.5 and older it would pass unnoticed.

If we observe the file /administrator/components/com_categories/models/category.php we see that the section part of a category is being taken into account in various of places such as in getForm() populateState() and preprocessForm()

In particular by taking a look at this part in populateState()

[...]
$extension = $app->input->get('extension', 'com_content');
$this->setState('category.extension', $extension);
$parts = explode('.', $extension);

// Extract the component name
$this->setState('category.component', $parts[0]);

// Extract the optional section name
$this->setState('category.section', (count($parts) > 1) ? $parts[1] : null);
[...]

We see nothing like this being done in the index() method in /plugins/finder/categories/categories.php

Testing Instructions

On a Joomla 3.7.0 to 3.7.2:

Without the PR:

  1. Install a component that uses categories with sections.
  2. Enable "Content - Smart Search" and "Smart Search - Categories" plugins.
  3. Create a category in the component and click on Save.
  4. Observe the Warning.
  5. Check that the category did not get indexed in the Smart Search component.

With the PR:

  1. Install a component that uses categories with sections.
  2. Enable "Content - Smart Search" and "Smart Search - Categories" plugins.
  3. Create a category in the component and click on Save.
  4. You get no warning anymore.
  5. Check that the category got indexed in the Smart Search component now.
avatar eorisis eorisis - open - 26 May 2017
avatar eorisis eorisis - change - 26 May 2017
Status New Pending
avatar eorisis eorisis - edited - 26 May 2017
avatar joomla-cms-bot joomla-cms-bot - change - 26 May 2017
Category Front End Plugins
avatar eorisis
eorisis - comment - 26 May 2017

Looks like AppVeyor got stuck am I right ?

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 27 May 2017

@eorisis which Component that uses Categories with Sections to install?

avatar eorisis
eorisis - comment - 27 May 2017

Hey @ franz-wohlkoenig

Is github fixed ? cause I still see the issue closed. I guess it should be open first ? I got no idea.

In any case, I can send you something but two things:

  1. It should not be considered a promo.
  2. You keep it private cause it is a commercial extension.
    Send me an email and I will reply with a zip :-)

cheers
George

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 27 May 2017

don't know about fix on Github. Is there a Component to test for a second one willing to test too?

avatar eorisis
eorisis - comment - 27 May 2017

Sure just inform him about the situation and ask him to send me an email as well and I will send him too.
Otherwise I don't know some other component myself taking advantage of category sections.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 27 May 2017

I don't know a second one who will test, but we need it – so if another Person want to test, send George an E-Mail too.

avatar eorisis
eorisis - comment - 27 May 2017

Yes "Microphone testing is the best thing early on a Friday morning", and Saturday is for software I guess.
Email sent.

avatar rdeutz rdeutz - change - 27 May 2017
The description was changed
Labels Added: ?
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 27 May 2017

I have tested this item successfully on eb69998


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

avatar franz-wohlkoenig franz-wohlkoenig - test_item - 27 May 2017 - Tested successfully
avatar eorisis
eorisis - comment - 30 May 2017

Hey guys it gets stuck continuously I am not sure if there is something that I have to do, if yes, please advice. Thanks.

avatar Hackwar
Hackwar - comment - 3 Jun 2018

I've created a new PR from this for Joomla 4.0: #20658

avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Apr 2019
Title
Plugin Smart Search - Categories, does not check the extension element (Ref #15850)
Plugin Smart Search - Categories, does not check the extension element
avatar franz-wohlkoenig franz-wohlkoenig - edited - 19 Apr 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Apr 2019
Title
Plugin Smart Search - Categories, does not check the extension element
Categories, does not check the extension element
avatar franz-wohlkoenig franz-wohlkoenig - edited - 19 Apr 2019
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 19 Jul 2019

I've created a new PR from this for Joomla 4.0: #20658

@Hackwar so can this PR be closed?

avatar Hackwar
Hackwar - comment - 19 Jul 2019

yes

avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Jul 2019
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2019-07-19 17:48:17
Closed_By franz-wohlkoenig
Labels Removed: J3 Issue
avatar franz-wohlkoenig franz-wohlkoenig - close - 19 Jul 2019

Add a Comment

Login with GitHub to post a comment