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
[Bug]: Autoloading issue for navigation container in conjunction with OPCache #15970
Comments
Thanks a lot for reporting the issue. We did not consider the issue as "Priority" or "Backlog", so we're not going to work on that anytime soon. Please create a pull request to fix the issue if this is a bug report. We'll then review it as quickly as possible. If you're interested in contributing a feature, please contact us first here before creating a pull request. We'll then decide whether we'd accept it or not. Thanks for your understanding. |
Any update / info on this? |
@GALPR As you're experiencing the issue, could you please debug it and provide a PR with the fix? |
The only fix I found that worked was to basically revert the linked change. Let me know if this is a viable solution and I will happily provide a PR. Here is the composer patch I am currently using: diff --git a/lib/Navigation/Container.php b/lib/Navigation/Container.php
index 5a57e8b..250ce89 100644
--- a/lib/Navigation/Container.php
+++ b/lib/Navigation/Container.php
@@ -39,6 +39,9 @@ declare(strict_types=1);
namespace Pimcore\Navigation;
+use RecursiveIterator;
+
class Container implements \RecursiveIterator, \Countable
{
/**
@@ -109,7 +112,7 @@ class Container implements \RecursiveIterator, \Countable
*
* @throws \Exception if page is invalid
*/
- public function addPage(Page|array $page): static
+ public function addPage($page): static
{
if ($page === $this) {
throw new \Exception('A page cannot have itself as a parent');
@@ -189,7 +192,7 @@ class Container implements \RecursiveIterator, \Countable
*
* @return bool whether the removal was successful
*/
- public function removePage(Page|int $page, bool $recursive = false): bool
+ public function removePage($page, bool $recursive = false): bool
{
if ($page instanceof Page) {
$hash = $page->hashCode();
@@ -244,7 +247,7 @@ class Container implements \RecursiveIterator, \Countable
*
* @return bool whether page is in container
*/
- public function hasPage(Page $page, bool $recursive = false): bool
+ public function hasPage($page, bool $recursive = false): bool
{
if (array_key_exists($page->hashCode(), $this->_index)) {
return true;
@@ -508,7 +511,7 @@ class Container implements \RecursiveIterator, \Countable
*
* @throws \Exception
*/
- public function current(): Page
+ public function current()
{
$this->_sort();
$hash = key($this->_index);
@@ -551,7 +554,10 @@ class Container implements \RecursiveIterator, \Countable
return $this->hasPages();
}
- public function getChildren(): ?Page
+ /**
+ * @return ?Page
+ */
+ public function getChildren(): ?RecursiveIterator
{
$hash = key($this->_index); |
I have seen this exact error message in Pimcore version 11.2.2 but I can not reliably reproduce the error. |
@LosHawlos Have you tried if my reproduction consistently leads to this issue for you? |
@GALPR I can reproduce it, but not reliably in a reduced test case. Simply putting It will be triggered when I load a page in Pimcore that does show a navigation using the Navigation Extension. But in the Pimcore Admin I see the strange effect that some pages show the navigation in editmode but fail in preview or frontend mode. So there seems to be an outside factor related to triggering the error. But: It seems to be related to the OPCache, because putting BTW. I'm running Pimcore in Docker using the image "pimcore/pimcore:php8.2-max-v3". |
@LosHawlos Thanks for the info, definitely seems related. Do you also get the same fatal error in the php.log? @brusch Any suggestions what an adequate fix could look like? |
@GALPR for me it would be fine to revert the type-hints here, but we should then add the PhpDoc again as well and leave a comment why we're not using proper type-hints. |
This should be of course just a quick-fix we need further investigate what's the root-cause of this issue. |
@brusch Should I branch this off |
@GALPR as others seem to be affected by this issue as well, I'd consider it as a bug fix and therefore it should go to |
The change was initially part of the commit: pimcore@83142b5#diff-6d072dd8e428eeff1dff129ad1056e39b8a7fdbf8273fa3aee2436a34d482ad4 See this issue for details: pimcore#15970
Pimcore version
11.0.8
Steps to reproduce
new \Pimcore\Navigation\Container()
anywherePage
class again resolves this issueActual Behavior
The page does not load anymore. I get the following exception logged in the php.log (formatted for readability):
Expected Behavior
The page should load as normal
The text was updated successfully, but these errors were encountered: