Skip to content
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

Admin Error Message: "Call to a member function format() on false" after update to 2.11.9.2 #3449

Open
mfickers opened this issue Nov 25, 2024 · 1 comment
Assignees

Comments

@mfickers
Copy link

Preconditions

Updated our shop:
PHP 8.2 -> 8.3
Magento 2.4.7-p2 -> 2.4.7-p3
ElasticSuite: 2.11.8.2 -> 2.11.9.2

Now in admin area, a persistent error message is shown where the admin notifications should be:

Call to a member function format() on false

Magento Version : 2.4.7-p3

ElasticSuite Version : 2.11.9.2

Environment : Production

Third party modules :

Steps to reproduce

  1. Open admin area

Expected result

  1. See admin notifications

Actual result

  1. Error message shown:
    Bildschirmfoto 2024-11-25 um 11 06 34

This is the relevant entry from exception.log

==> var/log/exception.log <==
[2024-11-25T09:28:53.350800+00:00] .CRITICAL: Error: Call to a member function format() on false in /var/www/magento//vendor/smile/elasticsuite/src/module-elasticsuite-indices/Model/IndexStatusProvider.php:122
Stack trace:
#0 /var/www/magento//vendor/smile/elasticsuite/src/module-elasticsuite-indices/Model/IndexStatusProvider.php(92): Smile\ElasticsuiteIndices\Model\IndexStatusProvider->isRebuilding()
#1 /var/www/magento//vendor/smile/elasticsuite/src/module-elasticsuite-indices/Model/IndexStatsProvider.php(137): Smile\ElasticsuiteIndices\Model\IndexStatusProvider->getIndexStatus()
#2 /var/www/magento//vendor/smile/elasticsuite/src/module-elasticsuite-indices/Model/System/Message/WarningAboutClusterGhostIndices.php(122): Smile\ElasticsuiteIndices\Model\IndexStatsProvider->indexStats()
#3 /var/www/magento//vendor/smile/elasticsuite/src/module-elasticsuite-indices/Model/System/Message/WarningAboutClusterGhostIndices.php(64): Smile\ElasticsuiteIndices\Model\System\Message\WarningAboutClusterGhostIndices->getNumberOfGhostIndices()
#4 /var/www/magento//vendor/magento/module-admin-notification/Model/ResourceModel/System/Message/Collection/Synchronized.php(32): Smile\ElasticsuiteIndices\Model\System\Message\WarningAboutClusterGhostIndices->isDisplayed()
#5 /var/www/magento//vendor/magento/framework/Data/Collection/AbstractDb.php(809): Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized->_afterLoad()
#6 /var/www/magento//vendor/magento/framework/Data/Collection/AbstractDb.php(777): Magento\Framework\Data\Collection\AbstractDb->loadWithFilter()
#7 /var/www/magento//vendor/magento/framework/Data/Collection.php(847): Magento\Framework\Data\Collection\AbstractDb->load()
#8 /var/www/magento//vendor/magento/framework/Data/Collection.php(748): Magento\Framework\Data\Collection->getIterator()
#9 /var/www/magento//vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\Data\Collection->toArray()
#10 /var/www/magento//vendor/magento/framework/Interception/Interceptor.php(138): Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized\Interceptor->___callParent()
#11 /var/www/magento//vendor/magento/framework/Interception/Interceptor.php(153): Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized\Interceptor->Magento\Framework\Interception\{closure}()
#12 /var/www/magento//generated/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection/Synchronized/Interceptor.php(32): Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized\Interceptor->___callPlugins()
#13 /var/www/magento//vendor/magento/module-ui/DataProvider/AbstractDataProvider.php(263): Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized\Interceptor->toArray()
#14 /var/www/magento//vendor/magento/module-ui/Component/Listing.php(38): Magento\Ui\DataProvider\AbstractDataProvider->getData()
#15 /var/www/magento//vendor/magento/framework/View/Element/UiComponent/Context.php(250): Magento\Ui\Component\Listing->getDataSourceData()
#16 /var/www/magento//vendor/magento/framework/View/Layout/Generic.php(75): Magento\Framework\View\Element\UiComponent\Context->getDataSourceData()
#17 /var/www/magento//vendor/magento/framework/View/Layout/Generator/Structure.php(46): Magento\Framework\View\Layout\Generic->build()
#18 /var/www/magento//vendor/magento/module-ui/TemplateEngine/Xhtml/Result.php(102): Magento\Framework\View\Layout\Generator\Structure->generate()
#19 /var/www/magento//vendor/magento/module-ui/TemplateEngine/Xhtml/Result.php(124): Magento\Ui\TemplateEngine\Xhtml\Result->appendLayoutConfiguration()
#20 /var/www/magento//vendor/magento/module-ui/Component/Wrapper/UiComponent.php(73): Magento\Ui\TemplateEngine\Xhtml\Result->__toString()
#21 /var/www/magento//vendor/magento/framework/View/Element/AbstractBlock.php(1128): Magento\Ui\Component\Wrapper\UiComponent->_toHtml()
#22 /var/www/magento//vendor/magento/framework/View/Element/AbstractBlock.php(1132): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}()
#23 /var/www/magento//vendor/magento/framework/View/Element/AbstractBlock.php(676): Magento\Framework\View\Element\AbstractBlock->_loadCache()
#24 /var/www/magento//vendor/magento/framework/View/Layout.php(591): Magento\Framework\View\Element\AbstractBlock->toHtml()
#25 /var/www/magento//vendor/magento/framework/View/Layout.php(553): Magento\Framework\View\Layout->_renderUiComponent()
#26 /var/www/magento//vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#27 /var/www/magento//vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement()
#28 /var/www/magento//vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#29 /var/www/magento//vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#30 /var/www/magento//vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement()
#31 /var/www/magento//vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#32 /var/www/magento//vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#33 /var/www/magento//vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement()
#34 /var/www/magento//vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#35 /var/www/magento//vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#36 /var/www/magento//vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement()
#37 /var/www/magento//vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#38 /var/www/magento//vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#39 /var/www/magento//vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement()
#40 /var/www/magento//vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer()
#41 /var/www/magento//vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout->renderNonCachedElement()
#42 /var/www/magento//vendor/magento/framework/View/Layout.php(975): Magento\Framework\View\Layout->renderElement()
#43 /var/www/magento//generated/code/Magento/Framework/View/Layout/Interceptor.php(41): Magento\Framework\View\Layout->getOutput()
#44 /var/www/magento//vendor/magento/framework/View/Result/Page.php(260): Magento\Framework\View\Layout\Interceptor->getOutput()
#45 /var/www/magento//vendor/magento/framework/View/Result/Layout.php(171): Magento\Framework\View\Result\Page->render()
#46 /var/www/magento//generated/code/Magento/Backend/Model/View/Result/Page/Interceptor.php(23): Magento\Framework\View\Result\Layout->renderResult()
#47 /var/www/magento//vendor/magento/framework/App/Http.php(120): Magento\Backend\Model\View\Result\Page\Interceptor->renderResult()
#48 /var/www/magento//vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Http->launch()
#49 /var/www/magento//vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\Http\Interceptor->___callParent()
#50 /var/www/magento//vendor/magento/module-application-performance-monitor/Plugin/ApplicationPerformanceMonitor.php(38): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#51 /var/www/magento//vendor/magento/framework/Interception/Interceptor.php(135): Magento\ApplicationPerformanceMonitor\Plugin\ApplicationPerformanceMonitor->aroundLaunch()
#52 /var/www/magento//vendor/justbetter/magento2-sentry/Plugin/GlobalExceptionCatcher.php(78): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#53 /var/www/magento//vendor/magento/framework/Interception/Interceptor.php(135): JustBetter\Sentry\Plugin\GlobalExceptionCatcher->aroundLaunch()
#54 /var/www/magento//vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#55 /var/www/magento//generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http\Interceptor->___callPlugins()
#56 /var/www/magento//vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()
#57 /var/www/magento//pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#58 {main} {"exception":"[object] (Error(code: 0): Call to a member function format() on false at /var/www/magento//vendor/smile/elasticsuite/src/module-elasticsuite-indices/Model/IndexStatusProvider.php:122)"} []

For the index with the name mag2_default_catalog_product_20241125_091325 this method will return false instead of a valid DateTime: \Smile\ElasticsuiteIndices\Model\IndexStatusProvider::getIndexUpdatedDateFromIndexName

These are the values that produce this result:
Bildschirmfoto 2024-11-25 um 11 12 41

Actual error is thrown here: \Smile\ElasticsuiteIndices\Model\IndexStatusProvider::isRebuilding
The method annotation even expects DateTime|false for the $indexDate parameter but does not handle a false value correctly:

    private function isRebuilding(string $indexName, $indexDate): bool
    {
        if (!empty($this->workingIndexers)) {
            foreach (array_keys($this->workingIndexers) as $indexKey) {
                if (strpos((string) $indexName, $indexKey) !== false) {
                    $today = new DateTime('now');

                    return ($today->format('Y-m-d') === $indexDate->format('Y-m-d'));
                }
            }
        }

        return false;
    }

Looks like this was introduced in this commit: e208790

@mfickers
Copy link
Author

Error is gone now an hour later. Maybe this only happens during the first reindex process after the update.

@vahonc vahonc self-assigned this Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants