User tests: Successful: Unsuccessful:
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 .
No warnings, get the category indexed.
A warning is displayed such as:
Error loading component: com_example.section, Component not found.
Plus, the category does not get indexed.
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
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.
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
On a Joomla 3.7.0 to 3.7.2:
Without the PR:
With the PR:
Status | New | ⇒ | Pending |
Category | ⇒ | Front End Plugins |
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:
cheers
George
don't know about fix on Github. Is there a Component to test for a second one willing to test too?
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.
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.
Yes "Microphone testing is the best thing early on a Friday morning", and Saturday is for software I guess.
Email sent.
Labels |
Added:
?
|
I have tested this item
Hey guys it gets stuck continuously I am not sure if there is something that I have to do, if yes, please advice. Thanks.
Title |
|
Title |
|
yes
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
|
Looks like AppVeyor got stuck am I right ?