Kdyby\Doctrine problem with unserializer

Notice: This thread is very old.
Čamo
Member | 798
+
0
-

Hello,
Can you help me with this issue? When I open browser with page on my localhost with Kdyby\Doctrine it throws me an exception which say:
Class __PHP_Incomplete_Class has no unserializer
File: …\src\Kdyby\Doctrine\Entities\SerializableMixin.php

/**
 * @param Serializable $object
 * @param string $serialized
 */
public static function unserialize(Serializable $object, $serialized)
{
    $data = unserialize($serialized);
    foreach ($data as $target => $value) {
        if (strpos($target, '::') !== FALSE) {
            list($class, $name) = explode('::', $target, 2);

After refresh it works normally. Can you explain me where is the problem?

Thanks.

Last edited by Čamo (2015-11-04 19:23)

enumag
Member | 2118
+
0
-

Which version of Kdyby/Doctrine are you using? I tried to fix it several months ago (and it helped for me): https://github.com/…a1b25b98e3fa.

Last edited by enumag (2015-11-04 22:02)

Čamo
Member | 798
+
0
-

I have “kdyby/doctrine”: “^2.3” and it seems it is the same as that fix. But it does not work.

enumag
Member | 2118
+
0
-

Can you upload a html dump generated by Tracy?

Čamo
Member | 798
+
0
-

Here is the call stack:

  1. …\vendor\nette\utils\src\Utils\Callback.php:94 source call_user_func_array (arguments)
  2. inner-code Nette\Utils\Callback:: Nette\Utils\{closure} (arguments)
  3. …\src\Kdyby\Doctrine\Entities\SerializableMixin.php:98 source unserialize (arguments)
  4. …\src\Kdyby\Doctrine\Entities\BaseEntity.php:403 source Kdyby\Doctrine\Entities\SerializableMixin:: unserialize (arguments)
  5. inner-code Kdyby\Doctrine\Entities\BaseEntity-> unserialize (arguments)
  6. inner-code session_start ()
  7. …\vendor\nette\utils\src\Utils\Callback.php:100 source call_user_func_array (arguments)
  8. …\ndoctrine\vendor\nette\http\src\Http\Session.php:99 source Nette\Utils\Callback:: invokeSafe (arguments)
  9. …\cache\Nette.Configurator\Container_e8207c675b.php:2501 source Nette\Http\Session-> start ()
  10. …\nette\bootstrap\src\Bootstrap\Configurator.php:227 source Container_e8207c675b-> initialize ()
  11. C:\Apache24\htdocs\ndoctrine\app\bootstrap.php:19 source Nette\Configurator-> createContainer ()
  12. C:\Apache24\htdocs\ndoctrine\www\index.php:6 source require (arguments)
Čamo
Member | 798
+
0
-

Whole dump or which part?

enumag
Member | 2118
+
0
-

Ok, your entity is unserialized because you put it in session for whatever reason. However the proxy autoloader should be already registered by the time session start is called. I can think of two reasons why it is not:

  1. You have Kdyby/Doctrine 2.3.0 installed, the fix is only present in 2.3.1 and newer.
  2. You don't have Kdyby\Events\DI\EventsExtension registered.

If neither is the case, I'll need to see the generated source code of your DI Container – or at least the initialize method.

Last edited by enumag (2015-11-05 00:21)

Čamo
Member | 798
+
0
-
  1. It seems it is 2.3.1 (“^2.3” should mean >=2.3.0 && <3.0.0 also the code seems as that fix)
  2. Also Kdyby\Events extension is registered

I have downloaded Martin Zlamals bolg as doctrine example and it throws me the same exception.

initialize() from DI container is here (cause Posts cannot be longer that 10000 characters.):

<?php
...
	public function initialize()
	{
		date_default_timezone_set('Europe/Prague');
		$this->getService('events.manager')->createEvent(array('Nette\DI\Container', 'onInitialize'))->dispatch($this);
		header('X-Frame-Options: SAMEORIGIN');
		header('X-Powered-By: Nette Framework');
		header('Content-Type: text/html; charset=utf-8');
		Nette\Reflection\AnnotationsParser::setCacheStorage($this->getByType("Nette\Caching\IStorage"));
		Nette\Reflection\AnnotationsParser::$autoRefresh = TRUE;
		$this->getService('session.session')->exists() && $this->getService('session.session')->start();;
		Doctrine\Common\Annotations\AnnotationRegistry::registerLoader("class_exists");
		Kdyby\Doctrine\Diagnostics\Panel::registerBluescreen($this);
		Tracy\Debugger::getBlueScreen()->collapsePaths[] = 'C:\Apache24\htdocs\ndoctrine\vendor\kdyby\doctrine\src\Kdyby\Doctrine';
		Tracy\Debugger::getBlueScreen()->collapsePaths[] = 'C:\Apache24\htdocs\ndoctrine\vendor\doctrine';
		Tracy\Debugger::getBlueScreen()->collapsePaths[] = 'C:\Apache24\htdocs\ndoctrine\app/../temp/proxies';
		Kdyby\Translation\Diagnostics\Panel::registerBluescreen();
	}
...

Last edited by Čamo (2015-11-05 01:06)

enumag
Member | 2118
+
0
-

The initialize method calls event manager when it should which means Kdyby/Events works fine.

I'm not sure what the problem is though. I'd try putting some dumps and/or exceptions into the Kdyby\Doctrine\Proxy\ProxyAutoloader class – more specificly the register and tryLoad methods. You need to find out if the ProxyAutoloader is registered (it should be), what proxy class can't be loaded (you should find that out from the stack trace of the original exception) and why the ProxyAutoloader doesn't create it.

Last edited by enumag (2015-11-05 01:46)

Čamo
Member | 798
+
0
-

Ok so the problem causes session when in the browser are opened two or more repos. Of course they share the same localhost session if I have not configured savePath for session. And so repos have foreign objects in session which do not belong to them and they cant unserialize them.

Solution is to add savePath: “%tempDir%/sessions” to neon file under session section.

enumag thanks a lot.

Last edited by Čamo (2015-11-05 04:50)