Fix Magefan Blog 2.15 / PHP 8.4 compatibility in fulltext collection#28
Open
nige-one wants to merge 1 commit into
Open
Fix Magefan Blog 2.15 / PHP 8.4 compatibility in fulltext collection#28nige-one wants to merge 1 commit into
nige-one wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Magefan Blog 2.15.x declares
getStoreId(): intonMagefan\Blog\Model\ResourceModel\Post\Collection. The override inComwrap\ElasticsuiteBlog\Model\ResourceModel\Post\Fulltext\Collectionhas no return type, so the class fails to load with a fatal signature-compatibility error (related: #27).Additionally, PHP 8.4 deprecates implicitly nullable parameters, which affects the
$connection/$resourceconstructor parameters.Why not just cast (as in #26)?
Simply declaring
getStoreId(): intis not enough: oncatalogsearch_result_indexthe collection is built withoutsetStoreId()being called, so$this->storeIdisnull.nullunder the: intsignature →TypeError, search page returns HTTP 500.(int)(i.e. store0, as proposed in Fix incompatibile methods declaration #26) → the Elasticsuite request builder resolves theblog_post/second_blog_postindex alias for store 0, which does not exist. The resultingLogicException("blog_post index does not exist yet. Make sure everything is reindexed.") is swallowed by the block, so blog results silently disappear from search and each search request writes ~285 lines of exception traces to the log. (Measured on Magento 2.4.8-p5 / PHP 8.4 / Magefan Blog 2.15.1.)Fix
Fall back to the current store from the store manager when no store filter was set. This queries the correct per-store index and produces the same results as an explicit
setStoreId()call:Both changes are running in production on Magento 2.4.8-p5 with PHP 8.4, Magefan Blog 2.15.1 and Smile Elasticsuite: search returns 200 on all store views with blog results present and no new log entries.