element119 / module-admin-opcache-report

A Magento 2 module to show some PHP OpCache-related information in the admin.
MIT License
47 stars 9 forks source link

I am having issues with Hyva_Admin. Can I use it only with Hyva_Admin? #1

Open levelzero-magento opened 1 month ago

levelzero-magento commented 1 month ago

1 exception(s): Exception #0 (OutOfBoundsException): Column(s) not found on source: log_id, admin_name, flushed_at

magtools commented 1 month ago

I have the same issue: 1 exception(s): Exception #0 (OutOfBoundsException): Column(s) not found on source: log_id, admin_name, flushed_at

Exception #0 (OutOfBoundsException): Column(s) not found on source: log_id, admin_name, flushed_at

#1 Hyva\Admin\Model\GridSource->extractColumnDefinitions() called at [vendor/hyva-themes/module-magento2-admin/ViewModel/HyvaGridViewModel.php:159]
#2 Hyva\Admin\ViewModel\HyvaGridViewModel->buildColumnDefinitions() called at [vendor/hyva-themes/module-magento2-admin/ViewModel/HyvaGridViewModel.php:149]
#3 Hyva\Admin\ViewModel\HyvaGridViewModel->getAllColumnDefinitions() called at [vendor/hyva-themes/module-magento2-admin/ViewModel/HyvaGridViewModel.php:176]
#4 Hyva\Admin\ViewModel\HyvaGridViewModel->getColumnDefinitions() called at [vendor/hyva-themes/module-magento2-admin/ViewModel/HyvaGridViewModel.php:254]
#5 Hyva\Admin\ViewModel\HyvaGridViewModel->getNavigation() called at [vendor/hyva-themes/module-magento2-admin/view/adminhtml/templates/grid.phtml:9]
#6 include() called at [vendor/magento/framework/View/TemplateEngine/Php.php:71]
#7 Magento\Framework\View\TemplateEngine\Php->render() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#8 Magento\Framework\View\TemplateEngine\Php\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#9 Magento\Framework\View\TemplateEngine\Php\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#10 Magento\Framework\View\TemplateEngine\Php\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/TemplateEngine/Php/Interceptor.php:23]
#11 Magento\Framework\View\TemplateEngine\Php\Interceptor->render() called at [vendor/magento/framework/View/Element/Template.php:263]
#12 Magento\Framework\View\Element\Template->fetchView() called at [vendor/magento/framework/View/Element/Template.php:293]
#13 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1128]
#14 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1132]
#15 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:676]
#16 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [generated/code/Hyva/Admin/Block/Adminhtml/HyvaGrid/Interceptor.php:23]
#17 Hyva\Admin\Block\Adminhtml\HyvaGrid\Interceptor->toHtml() called at [vendor/magento/framework/View/Layout.php:578]
#18 Magento\Framework\View\Layout->_renderBlock() called at [vendor/magento/framework/View/Layout.php:555]
#19 Magento\Framework\View\Layout->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#20 Magento\Framework\View\Layout->renderElement() called at [vendor/magento/framework/View/Element/AbstractBlock.php:523]
#21 Magento\Framework\View\Element\AbstractBlock->getChildHtml() called at [vendor/element119/module-admin-opcache-report/view/adminhtml/templates/flush-log.phtml:26]
#22 include() called at [vendor/magento/framework/View/TemplateEngine/Php.php:71]
#23 Magento\Framework\View\TemplateEngine\Php->render() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#24 Magento\Framework\View\TemplateEngine\Php\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#25 Magento\Framework\View\TemplateEngine\Php\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#26 Magento\Framework\View\TemplateEngine\Php\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/TemplateEngine/Php/Interceptor.php:23]
#27 Magento\Framework\View\TemplateEngine\Php\Interceptor->render() called at [vendor/magento/framework/View/Element/Template.php:263]
#28 Magento\Framework\View\Element\Template->fetchView() called at [vendor/magento/framework/View/Element/Template.php:293]
#29 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/module-backend/Block/Template.php:141]
#30 Magento\Backend\Block\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1128]
#31 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1132]
#32 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:676]
#33 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [generated/code/Magento/Backend/Block/Template/Interceptor.php:23]
#34 Magento\Backend\Block\Template\Interceptor->toHtml() called at [vendor/magento/framework/View/Layout.php:578]
#35 Magento\Framework\View\Layout->_renderBlock() called at [vendor/magento/framework/View/Layout.php:555]            
nmarcy-del commented 1 month ago

Hello,

I faced the same problem. It seems that this exception occurs if the table e199_opcache_admin_flush_history is empty. I've manually created a row in the table (with an existing admin user id) and everything now works (for a workaround)

levelzero-magento commented 1 month ago

Hello,

I faced the same problem. It seems that this exception occurs if the table e199_opcache_admin_flush_history is empty. I've manually created a row in the table (with an existing admin user id) and everything now works (for a workaround)

Perfect, and thank you for your suggestion. I confirm that I did the same, and now it works. Indeed, the table was empty.

renttek commented 1 month ago

The problem is the method Hyva\Admin\Model\GridSource::extractColumnDefinitions(), which validates the included columns against the available columns of the source.

In Line 77, the method validateConfiguredKeys is called, which throws the exception: https://github.com/hyva-themes/magento2-hyva-admin/blob/main/Model/GridSource.php#L77

A quick hack is to simply not validate the included columns if no data is present:

+        if ($allColumnKeys !== []) {
            $this->validateConfiguredKeys(keys($configuredColumns), $allColumnKeys);
+        }

This will result in the following behavior if no data is present: image

After a flush is done/data is present, the grid will display like normal.

I don't think just skipping the validation is not a good "fix" (without knowing what else could break) to contribute back to hyvä admin grids. If I find a better solution, I'll create a PR for it, but until then, a composer patch does the trick for me. (If someone else wants to create a PR for hyvä admin, please do so :slightly_smiling_face:)

renttek commented 1 month ago

I created an issue in the hyvä admin repository: https://github.com/hyva-themes/magento2-hyva-admin/issues/85

pykettk commented 1 month ago

@renttek Thanks for digging into this and posting such a helpful explanation! I can probably use a grid processor to avoid this issue but I'll dig into this a little more when I have time - hopefully I can make some time before the end of this week but, failing that, it'll likely be after Meet Magento NL and Mage Unconference.

renttek commented 1 month ago

Probably, yes :slightly_smiling_face:

If you won't find time, there is also a hackathon before the Mage Unconference and I'll try to place the topic there then :grin:

But I think a fix in the admin module would be better in the grand scheme