Closed Larke12 closed 6 months ago
Hello!
I fix the issue with this patch :
Index: Model/Post.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Model/Post.php b/Model/Post.php
--- a/Model/Post.php
+++ b/Model/Post.php (date 1714034007690)
@@ -668,7 +668,7 @@
try {
$category = $this->categoryRepository->getById($categoryId);
if ($category->getId() && $category->isVisibleOnStore($this->getStoreId())) {
- $this->_parentCategories[] = $category;
+ $this->_parentCategories[$categoryId] = $category;
}
} catch (NoSuchEntityException $e) { }
}
Index: Model/UrlResolver.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Model/UrlResolver.php b/Model/UrlResolver.php
--- a/Model/UrlResolver.php
+++ b/Model/UrlResolver.php (date 1714034007682)
@@ -187,7 +187,11 @@
$factory = Url::CONTROLLER_POST . 'Factory';
$model = $this->$factory->create()->load($postId);
- if (!$model->getCategoriesCount() || !$model->getParentCategories()->getItemById($categoryId)) {
+ if (
+ !$model->getCategoriesCount()
+ || (array_key_exists($categoryId, $model->getParentCategories())
+ && !$model->getParentCategories()[$categoryId])
+ ) {
return null;
}
}
Thank you for your report. To fix this issue, please use this fix https://github.com/magefan/module-blog/commit/195e9261cbc4eaf6efc1bbd26a07950992636573 or update the extension to the newer version 2.11.3.1 (https://github.com/magefan/module-blog/releases/tag/2.11.3.1)
Describe the bug After updating the composer package to 2.11.3 (from 2.11.0.1) the frontend blogs stopped loading, throwing the following error:
Error: Call to a member function getItemById() on array in .../vendor/magefan/module-blog/Model/UrlResolver.php:190
This appears to be due to the function
\Magefan\Blog\Model\Post::getParentCategories
no longer returning a collection, but an array. Reverting this function via an override to use the old code resolves this issue.Preconditions:
To Reproduce Steps to reproduce the behavior:
Expected behavior The blog post loads without issue.
Actual behavior The blog post does not load at all and throws only an exception with stack trace.