'Attempt to read property "childNodes" on null' and some Symphony error messages

Hi
I have pages behind login, and I got it working as suggested here

by initiating the session in sitecake.php.

But now when I try to login to Sitecake, the login is not accepted but I receive these errors in Apache error log:

[03-Oct-2024 10:06:43 UTC] PHP Deprecated: Symfony\Component\Routing\Route implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /mysite/sitecake/2.5.0/vendor/symfony/routing/Route.php on line 20
[03-Oct-2024 10:06:43 UTC] PHP Deprecated: Silex\Route implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /mysite/sitecake/2.5.0/vendor/silex/silex/src/Silex/Route.php on line 21
[03-Oct-2024 10:06:43 UTC] PHP Deprecated: Return type of Symfony\Component\Routing\RouteCollection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mysite/sitecake/2.5.0/vendor/symfony/routing/RouteCollection.php on line 54
[03-Oct-2024 10:06:43 UTC] PHP Deprecated: Return type of Symfony\Component\Routing\RouteCollection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mysite/sitecake/2.5.0/vendor/symfony/routing/RouteCollection.php on line 64
[03-Oct-2024 10:06:43 UTC] PHP Deprecated: Return type of Sitecake\Util\ObjectRegistry::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mysite/sitecake/2.5.0/src/Sitecake/Util/ObjectRegistry.php on line 326
[03-Oct-2024 10:06:43 UTC] PHP Deprecated: Return type of Sitecake\Util\ObjectRegistry::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mysite/sitecake/2.5.0/src/Sitecake/Util/ObjectRegistry.php on line 316
[03-Oct-2024 10:06:43 UTC] PHP Deprecated: Return type of Symfony\Component\HttpFoundation\ParameterBag::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mysite/sitecake/2.5.0/vendor/symfony/http-foundation/ParameterBag.php on line 220
[03-Oct-2024 10:06:43 UTC] PHP Deprecated: Return type of Symfony\Component\HttpFoundation\ParameterBag::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mysite/sitecake/2.5.0/vendor/symfony/http-foundation/ParameterBag.php on line 230
[03-Oct-2024 10:06:43 UTC] PHP Deprecated: Return type of Symfony\Component\HttpFoundation\HeaderBag::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mysite/sitecake/2.5.0/vendor/symfony/http-foundation/HeaderBag.php on line 288
[03-Oct-2024 10:06:43 UTC] PHP Deprecated: Return type of Symfony\Component\HttpFoundation\HeaderBag::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mysite/sitecake/2.5.0/vendor/symfony/http-foundation/HeaderBag.php on line 298
[03-Oct-2024 10:06:43 UTC] PHP Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /mysite/sitecake/2.5.0/vendor/symfony/http-foundation/Request.php on line 316

In the subfolder of sitecake-temp/ in the log/sitecake.log I see these messages:

[2024-10-03 10:06:44] app.WARNING: Warning (2): Attempt to read property “childNodes” on null in [/mysite/sitecake/2.5.0/src/Sitecake/Content/Element.php, line 478] Stack Trace: #0 /mysite/sitecake/2.5.0/src/Sitecake/Error/ErrorHandler.php(364): Sitecake\Error\ErrorHandler->logError() #1 /mysite/sitecake/2.5.0/src/Sitecake/Content/Element.php(478): Sitecake\Error\ErrorHandler->handleError() #2 /mysite/sitecake/2.5.0/src/Sitecake/Content/Element.php(405): Sitecake\Content\Element->createDOM() #3 /mysite/sitecake/2.5.0/src/Sitecake/Content/Element.php(200): Sitecake\Content\Element->append() #4 /mysite/sitecake/2.5.0/src/Sitecake/Content/DOM/HTMLManipulationTrait.php(125): Sitecake\Content\Element->html() #5 /mysite/sitecake/2.5.0/src/Sitecake/Content/ContentManagerAwareTrait.php(62): Sitecake\Content\ContentManager->appendTo() #6 /mysite/sitecake/2.5.0/src/Sitecake/Content/PageRenderAwareTrait.php(171): Sitecake\PageManager\Page->appendTo() #7 /mysite/sitecake/2.5.0/src/Sitecake/Content/PageRenderAwareTrait.php(41): Sitecake\Services\SessionService->ensureMetaTag() #8 /mysite/sitecake/2.5.0/src/Sitecake/Services/SessionService.php(128): Sitecake\Services\SessionService->preparePageForRender() #9 /mysite/sitecake/2.5.0/src/Sitecake/Services/Service.php(135): Sitecake\Services\SessionService->login() #10 /mysite/sitecake/2.5.0/src/Sitecake/ActionDispatcher.php(135): Sitecake\Services\Service->invokeAction() #11 /mysite/sitecake/2.5.0/src/Sitecake/ActionDispatcher.php(109): Sitecake\ActionDispatcher->invoke() #12 /mysite/sitecake/2.5.0/src/Sitecake/Sitecake.php(539): Sitecake\ActionDispatcher->dispatch() #13 /mysite/sitecake/2.5.0/src/Sitecake/Sitecake.php(517): Sitecake\Sitecake->handleRequest() #14 /mysite/sitecake/2.5.0/vendor/symfony/http-kernel/HttpKernel.php(151): Sitecake\Sitecake->Sitecake{closure}() #15 /mysite/sitecake/2.5.0/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #16 /mysite/sitecake/2.5.0/vendor/silex/silex/src/Silex/Application.php(496): Symfony\Component\HttpKernel\HttpKernel->handle() #17 /mysite/sitecake/2.5.0/vendor/silex/silex/src/Silex/Application.php(477): Silex\Application->handle() #18 /mysite/sitecake/2.5.0/src/Sitecake/Sitecake.php(505): Silex\Application->run() #19 /mysite/sitecake/2.5.0/src/app.php(16): Sitecake\Sitecake->run() #20 /mysite/sitecake.php(1): require(’…’) [] []
[2024-10-03 10:06:44] app.WARNING: Warning (2): foreach() argument must be of type array|object, null given in [/mysite/sitecake/2.5.0/src/Sitecake/Content/Element.php, line 407] Stack Trace: #0 /mysite/sitecake/2.5.0/src/Sitecake/Error/ErrorHandler.php(364): Sitecake\Error\ErrorHandler->logError() #1 /mysite/sitecake/2.5.0/src/Sitecake/Content/Element.php(407): Sitecake\Error\ErrorHandler->handleError() #2 /mysite/sitecake/2.5.0/src/Sitecake/Content/Element.php(200): Sitecake\Content\Element->append() #3 /mysite/sitecake/2.5.0/src/Sitecake/Content/DOM/HTMLManipulationTrait.php(125): Sitecake\Content\Element->html() #4 /mysite/sitecake/2.5.0/src/Sitecake/Content/ContentManagerAwareTrait.php(62): Sitecake\Content\ContentManager->appendTo() #5 /mysite/sitecake/2.5.0/src/Sitecake/Content/PageRenderAwareTrait.php(171): Sitecake\PageManager\Page->appendTo() #6 /mysite/sitecake/2.5.0/src/Sitecake/Content/PageRenderAwareTrait.php(41): Sitecake\Services\SessionService->ensureMetaTag() #7 /mysite/sitecake/2.5.0/src/Sitecake/Services/SessionService.php(128): Sitecake\Services\SessionService->preparePageForRender() #8 /mysite/sitecake/2.5.0/src/Sitecake/Services/Service.php(135): Sitecake\Services\SessionService->login() #9 /mysite/sitecake/2.5.0/src/Sitecake/ActionDispatcher.php(135): Sitecake\Services\Service->invokeAction() #10 /mysite/sitecake/2.5.0/src/Sitecake/ActionDispatcher.php(109): Sitecake\ActionDispatcher->invoke() #11 /mysite/sitecake/2.5.0/src/Sitecake/Sitecake.php(539): Sitecake\ActionDispatcher->dispatch() #12 /mysite/sitecake/2.5.0/src/Sitecake/Sitecake.php(517): Sitecake\Sitecake->handleRequest() #13 /mysite/sitecake/2.5.0/vendor/symfony/http-kernel/HttpKernel.php(151): Sitecake\Sitecake->Sitecake{closure}() #14 /mysite/sitecake/2.5.0/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #15 /mysite/sitecake/2.5.0/vendor/silex/silex/src/Silex/Application.php(496): Symfony\Component\HttpKernel\HttpKernel->handle() #16 /mysite/sitecake/2.5.0/vendor/silex/silex/src/Silex/Application.php(477): Silex\Application->handle() #17 /mysite/sitecake/2.5.0/src/Sitecake/Sitecake.php(505): Silex\Application->run() #18 /mysite/sitecake/2.5.0/src/app.php(16): Sitecake\Sitecake->run() #19 /mysite/sitecake.php(1): require(’…’) [] []
[2024-10-03 10:06:44] app.WARNING: Warning (2): Attempt to read property “length” on null in [/mysite/sitecake/2.5.0/src/Sitecake/Content/Element.php, line 412] Stack Trace: #0 /mysite/sitecake/2.5.0/src/Sitecake/Error/ErrorHandler.php(364): Sitecake\Error\ErrorHandler->logError() #1 /mysite/sitecake/2.5.0/src/Sitecake/Content/Element.php(412): Sitecake\Error\ErrorHandler->handleError() #2 /mysite/sitecake/2.5.0/src/Sitecake/Content/Element.php(200): Sitecake\Content\Element->append() #3 /mysite/sitecake/2.5.0/src/Sitecake/Content/DOM/HTMLManipulationTrait.php(125): Sitecake\Content\Element->html() #4 /mysite/sitecake/2.5.0/src/Sitecake/Content/ContentManagerAwareTrait.php(62): Sitecake\Content\ContentManager->appendTo() #5 /mysite/sitecake/2.5.0/src/Sitecake/Content/PageRenderAwareTrait.php(171): Sitecake\PageManager\Page->appendTo() #6 /mysite/sitecake/2.5.0/src/Sitecake/Content/PageRenderAwareTrait.php(41): Sitecake\Services\SessionService->ensureMetaTag() #7 /mysite/sitecake/2.5.0/src/Sitecake/Services/SessionService.php(128): Sitecake\Services\SessionService->preparePageForRender() #8 /mysite/sitecake/2.5.0/src/Sitecake/Services/Service.php(135): Sitecake\Services\SessionService->login() #9 /mysite/sitecake/2.5.0/src/Sitecake/ActionDispatcher.php(135): Sitecake\Services\Service->invokeAction() #10 /mysite/sitecake/2.5.0/src/Sitecake/ActionDispatcher.php(109): Sitecake\ActionDispatcher->invoke() #11 /mysite/sitecake/2.5.0/src/Sitecake/Sitecake.php(539): Sitecake\ActionDispatcher->dispatch() #12 /mysite/sitecake/2.5.0/src/Sitecake/Sitecake.php(517): Sitecake\Sitecake->handleRequest() #13 /mysite/sitecake/2.5.0/vendor/symfony/http-kernel/HttpKernel.php(151): Sitecake\Sitecake->Sitecake{closure}() #14 /mysite/sitecake/2.5.0/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #15 /mysite/sitecake/2.5.0/vendor/silex/silex/src/Silex/Application.php(496): Symfony\Component\HttpKernel\HttpKernel->handle() #16 /mysite/sitecake/2.5.0/vendor/silex/silex/src/Silex/Application.php(477): Silex\Application->handle() #17 /mysite/sitecake/2.5.0/src/Sitecake/Sitecake.php(505): Silex\Application->run() #18 /mysite/sitecake/2.5.0/src/app.php(16): Sitecake\Sitecake->run() #19 /mysite/sitecake.php(1): require(’…’) [] []

The script /mysite/index.php does check the session, too.

What would help? Could I update the Symfony myself?

Hi,
I got this working by:

  1. making sure the code is “require_once” instead of “require” for the login/valid session checking script
  2. for some undocumented reason our login check script - which is quite old - had this at the end of that script
    ini_set(‘session.use_only_cookies’, false);
    ini_set(‘session.use_cookies’, false);
    ini_set(‘session.use_trans_sid’, false); //May be necessary in some situations
    ini_set(‘session.cache_limiter’, null);

and now that part is removed and everything is working fine: both the normal users and page editor are required to login first in our own system, and additionally page editor must login to Sitecake in order to edit the pages.

Thanks for the update @elmer