dongzhao2725 2019-04-24 07:42
浏览 109
已采纳

Symfony 3 - 注意:unserialize():偏移量为11个字节的错误

I do not understand, I work under Symfony 3 and I just got an error when I want to go to my user administration page:

Notice: unserialize(): Error at offset 11 of 28 bytes

Symfony\Component\Debug\Exception\ ContextErrorException

in vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ArrayType.php (line 58)

However, before it worked very well, it's very strange. Several other people have already had the same problem but it is never the same cause.

I remember doing a little emptiness in my useless files of my project but I deleted that which was unused, and the commented blocks which I did not use.

If it helps to solve my problem, here is my user.php

Thanks !

EDIT : Ok I'm just very stupid. My User entity inherits from FOSUserBundle. In my database, I had a User who had the role SUPER_ADMIN. Suaf meanwhile, in my code, I deleted this role to leave only the role ADMIN, and I modified myself in the database by removing the "SUPER" too much. I did not think it would make this kind of bug, if anyone can explain to me why, for my culture.

But in any case the problem is still solved!

  • 写回答

1条回答

  • drjltlm156790 2019-04-24 07:52
    关注

    This happens because roles are stored as a serialized array, like:

    a:1:{i:0;s:16:"ROLE_SUPER_ADMIN";}
    

    See this s:16? This means that during unserialization php will take 16 symbols (which are exactly ROLE_SUPER_ADMIN).

    So, when you removed SUPER your data became

    a:1:{i:0;s:16:"ROLE_ADMIN";}
    

    and s:16 is incorrect, because now you have 10 symbols instead of 16. But php tries to get 16, which causes error.

    This leads us to conclusion that editing raw data is not a good idea.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器