-
Notifications
You must be signed in to change notification settings - Fork 340
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
Virtual Category module suddenly throwing errors #1985
Comments
Is there a way to determine what the cause is? It seems like ->getVirtualRule() is returning a string when an object is expected. |
After commenting out line 116 in Preview.php I am now manually saving categories that don't have is_virtual attribute, found by query:
This seems to save the info for those categories. I hope that this resolves it; it's over 100 categories so may take some time. EDIT: All of them have the attribute now, but still the same problem. Now I'm checking the other 'virtual' attributes, looks like some of them don't exist for certain categories somehow. EDIT: I looped through it all, some don't have a virtual_rule, but I can't fix that by saving category when the category can't load said rules for saving in the first place... So I added them in manually. Looks like they are categories that get imported (but some of them have been there for years), rather than created through the backend. Still, even after all that being fixed, it still doesn't work. |
Manually adding a check to verify if the virtualrule is an object and if not to exectute the ReadHandler seems to resolve it for me.
That said, it seems like this shouldn't be necessary and makes me wonder why it doesn't work out of the box (anymore) |
You are right, the "check if object and call the read handler if it's not" should not be needed since the read handler is supposed to be called every time we load a category. That's not the first time I see this kind of issue by the way, despite I've never been able to reproduce it by myself. I think this is really due to the fact that some categories do not have any value for virtual_rule (that's step 1) and then, for unknown reasons, we don't go through the read handler when loading them (that's step 2), and we run into failure. I'm wondering what could cause the read handler not being called when loading a category. However, there's not much I can do myself here, since I'm not able to reproduce it. Maybe your scenario is detailed enough to be reproduced, we'll try to have a look but since this one seems to be very specific to something unknow, it's not high priority for now : we never faced it on a Luma/Venia even if the sample data in this case does not have particular Regards |
Yes, the weird thing is that it was working fine before and then suddenly it wasn't anymore. I see that the readhandler is supposed to be applied in the ResourceModel. I'll see if I can find something related to that. I did a quick search last time that came up empty though. EDIT: Didn't find anything that extends the same Magento collection. |
Still can't wrap my head around it. In the ResourceModel/VirtualCategory/Collection the getVirtualRule() definitely returns an object, but then when you navigate to one of the pages it is suddenly just a string? |
Yes unfortunately I came to the same conclusion but never reproduced it. Maybe something related to caching, or to Varnish fragments for the layered navigation in some edge cases ? |
Unfortunately, we don't use Varnish. We use redis for all our caching (seperate instance for session and cache) And it also happens in the backend on category management page. It also either works entirely or not at all, not specific to any category or such. Same stuff happens even when cache is disabled and so forth. Ultimately, I can only conclude it must have something to do with the resourcemodel or the categorymodel itself somehow. |
Small update: I test if it works primarily on the backend so the frontend is undisturbed. By modifying Preview.php I can make it load normally. What I noticed today was that Virtual Categories still load fine regardless, but normal ones do not. Interesting data point to say the least. |
One thing I have noticed is that the store_id for the rule in the resourcemodel is 0 (of course), but when loading a category in "All store views" it ends up adopting the default storeview for the current category root instead of the admin storeview. I can't compare with a working version myself, unfortunately. Might be completely normal. Just trying to note down differences that could point in the right direction. |
I have the same issue with es 2.9.6 and magento 2.3.6 |
exact same issue for us with magento version 2.3.5 and elasticsuite version ~2.9.0. lots of times, same error generated in log/exception.log file. Is there any solution for this bug? |
Soooo, still not sure what the cause is, but after installing https://github.com/creatuity/magento2-interceptors module, I no longer experience this issue. Perhaps a bug in Magento core regarding interceptor generation in certain edge cases? |
I have since disabled the interceptor module, upgraded to 2.4.2 and Elasticsuite to 2.10.3 and it works without issue again. |
We don't use interceptors module. This bug started appearing to us today, after we've upgraded magento from 2.4.1 to 2.4.2 and also a lot of other modules. (So hard to tell, whether it was the magento update, or which module exactly...) Here is our error stacktrace:
|
I checked the error and I think I know the issue and steps to reproduce. Issue appeared for me when I tried to debug one thing after clicking Ajax call execute this action `private function initLayer()
Later on method https://github.com/Smile-SA/elasticsuite/blob/2.10.x/src/module-elasticsuite-virtual-category/Search/Request/Product/Attribute/Aggregation/Category.php#L87 is called and As a fix it seems that line https://github.com/Smile-SA/elasticsuite/blob/2.10.x/src/module-elasticsuite-catalog/Controller/Navigation/Filter/Ajax.php#L113 should be changed into:
|
Has anyone managed to get to the bottom of this? We've been seeing this error in our logs for months now. We're on M2.4.2CE and ES2.10.3
From what we can tell, we're not having any issue from a user perspective, but the error is added to our logs throughout the day. |
I'm getting the same error here
|
In my case $virtualRule is null. Perhaps category is loaded without this attribute. Stack trace points there: @blanioo also pointed that incorrect category instance is loaded somewhere |
I am also getting similar issue on Magento 2.4.5 P2 report.CRITICAL: TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, first array member is not a valid class name or object in vendor/smile/elasticsuite/src/module-elasticsuite-virtual-category/Helper/Rule.php:76 What is the fix? |
#2931 this PR should fix this. Imho your solution @blanioo was not enough, because there are also some strange cases where the virtualRule is here, but not empty, just the "text based" value and not the object. So I added an authoritative call to the read handler in such cases. I'm still not able to reproduce this however, it's probably very dependant on other modules in the call stack. Regards |
Fix #1985 Ensure proper loading of virtual categories rules.
Fix #1985 Ensure proper loading of virtual categories rules.
After updating some packages (not elasticsuite itself) with composer (none of them related to layered navigation), Virtual Category module throws an error:
For frontend:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, class '{"type":"Smile\\ElasticsuiteVirtualCategory\\Model\\Rule\\Condition\\Combine","attribute":null,"operator":null,"value":"1","is_value_processed":null,"aggregator":"all"}' not found in vendor/smile/elasticsuite/src/module-elasticsuite-virtual-category/Helper/Rule.php on line 67
And for backend:
main.CRITICAL: Error: Call to a member function getCategorySearchQuery() on string in vendor/smile/elasticsuite/src/module-elasticsuite-virtual-category/Model/Preview.php:116
And for virtual categories on backend:
main.CRITICAL: Error: Call to a member function loadPost() on string in vendor/smile/elasticsuite/src/module-elasticsuite-virtual-category/Controller/Adminhtml/Category/Virtual/Preview.php:144
The odd thing is; it was working perfectly fine before. I had this error about two weeks ago, but then after a while of trying to figure it out and debugging, I turned the module back on and it worked normally again.
Looking through the history of issues; this seems to appear every once in a while, but no real conclusive answer.
Preconditions
Magento Version : 2.4.0
ElasticSuite Version : 2.10.1
Environment : Production
Third party modules : Loads, none of them impact layered navigation, however (fully handled by elasticsuite)
Steps to reproduce
No clue how to reproduce, given that it happened out of the blue.
I do use optimizers on every category which is why I guess all categories go 500
Expected result
Category pages load normally
Actual result
Category page returns error 500 and logs the critical error in system.log
The text was updated successfully, but these errors were encountered: