简体   繁体   English

注意:unserialize():执行原则查询时,在偏移473个578字节处发生错误

[英]Notice: unserialize(): Error at offset 473 of 578 bytes while executing doctrine query

We are trying to execute the below doctrine query and its throwing unserialize(): Error at offset 473 of 578 bytes. 我们正在尝试执行以下原则查询及其抛出的unserialize():偏移473(578个字节)时出错。

Doctrine Query: 教义查询:

SELECT p FROM MyCompanyBundle:Person p 
WHERE p.dateOfExit IS NULL 
AND (p.passportCountry IS NULL OR p.passportCountry <> :india OR 
p.invitationId IS NOT NULL) 
AND (p.category <> :category_cl AND 
p.category <> :category_staff AND p.category <> :category_sev AND 
p.category <> :category_visitor)

As part of the above query its trying to fetch the below data and its throwing error.But the same is working as mysql query. 作为上述查询的一部分,它试图获取以下数据及其抛出错误。但是与mysql查询一样。

Mysql Table Output Mysql表输出

a:3:{s:19:"volunteering-local0";a:3:{s:8:"activity";s:23:"Mystic eye kolkata 2017";s:11:"description";s:239:"I was in ushering team and also in the flying squad consisting of only 5 odd people including me. We were told to fly around and lend our hand to anyone who needs it in the spot. And mostly the menial jobs were our responsibility 1st hand.";s:8:"location";s:7:"Kolkata";}s:19:"volunteering-local1";a:3:{s:8:"activity";s:17:"Inner Engineering";s:11:"description";s:104:"I have volunteered in the initiation day . I had the oppurtunity to be part of the kitchen works too a:3:{s:19:“ volunteering-local0”; a:3:{s:8:“活动”; s:23:“加尔各答神秘之眼2017”; s:11:“描述”; s:239 :“我当时是一支迎接团队的队伍,也是一支只由5个人组成的飞行小队,包括我在内。我们被告知飞行,并向当场需要它的任何人伸出援助之手。主要的工作是第一手的工作。手。“; s:8:”位置“; s:7:”加尔各答“;} s:19:”志愿者本地1“; a:3:{s:8:”活动“; s:17:”内部Engineering“; s:11:” description“; s:104:”我在入职那天自愿参加。我也有机会成为厨房工作的一部分

Detailed Error Description: 详细错误描述:

Symfony\\Component\\Debug\\Exception\\ ContextErrorException in vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ArrayType.php (line 58) ArrayType->convertToPHPValue('a:3:{s:19:"volunteering-local0";a:3:{s:8:"activity";s:23:"Mystic eye kolkata 2017";s:11:"description";s:239:"I was in ushering team and also in the flying squad consisting of only 5 odd people including me. We were told to fly around and lend our hand to anyone who needs it in the spot. And mostly the menial jobs were our responsibility 1st hand.";s:8:"location";s:7:"Kolkata";}s:19:"volunteering-local1";a:3:{s:8:"activity";s:17:"Inner Engineering";s:11:"description";s:104:"I have volunteered in the initiation day . I had the oppurtunity to be part of the kitchen works too', object(MySQL57Platform)) in vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php (line 316) 供应商/doctrine/dbal/lib/Doctrine/DBAL/Types/ArrayType.php中的Symfony \\ Component \\ Debug \\ Exception \\ ContextErrorException(第58行)ArrayType-> convertToPHPValue('a:3:{s:19:“ volunteering-local0 “; a:3:{s:8:”活动“; s:23:”神秘眼神加尔各答2017“; s:11:”描述“; s:239:”我参加了迎接团队,也参加了飞行小队“; s:8:”位置“; s被告知要飞来飞去,把我们的手伸出来,向当场需要它的任何人伸出援助之手。主要的工作是第一手。 :7:“ Kolkata”;} s:19:“ volunteering-local1”; a:3:{s:8:“ activity”; s:17:“ Inner Engineering”; s:11:“ description”; s: 104:“我在入职当天自愿参加。我也有机会成为厨房工作的一部分,对象(MySQL57平台))位于vendor / doctrine / orm / lib / Doctrine / ORM / Internal / Hydration / AbstractHydrator.php中(第316行)

please suggest me any ideas to resolve this doctrine issue. 请向我提出解决该学说问题的任何想法。

Before you blame Doctrine ORM about your error, let's examine your serialized array first. 在将错误归咎于Doctrine ORM之前,让我们先检查序列化的数组。

Serialized array (based on your MySQL table output): 序列化数组 (基于您的MySQL表输出):

a:3:{s:19:"volunteering-local0";a:3:{s:8:"activity";s:23:"Mystic eye kolkata 2017";s:11:"description";s:239:"I was in ushering team and also in the flying squad consisting of only 5 odd people including me. We were told to fly around and lend our hand to anyone who needs it in the spot. And mostly the menial jobs were our responsibility 1st hand.";s:8:"location";s:7:"Kolkata";}s:19:"volunteering-local1";a:3:{s:8:"activity";s:17:"Inner Engineering";s:11:"description";s:104:"I have volunteered in the initiation day . I had the oppurtunity to be part of the kitchen works too

Wait, it's a bit messy to examine the serialized array. 等等,检查序列化的数组有点混乱。 Let's make it "readable": 让我们使其“可读”:

a:3:{
    s:19:"volunteering-local0";
    a:3:{
        s:8:"activity";
        s:23:"Mystic eye kolkata 2017";
        s:11:"description";
        s:239:"I was in ushering team and also in the flying squad consisting of only 5 odd people including me. We were told to fly around and lend our hand to anyone who needs it in the spot. And mostly the menial jobs were our responsibility 1st hand.";
        s:8:"location";
        s:7:"Kolkata";
    }
    s:19:"volunteering-local1";
    a:3:{
        s:8:"activity";
        s:17:"Inner Engineering";
        s:11:"description";
        s:104:"I have volunteered in the initiation day . I had the oppurtunity to be part of the kitchen works too

By making the serialized array "readable", you can see invalid serialized object structure there. 通过使序列化数组“可读”,您可以在那里看到无效的序列化对象结构。

a:3:{
    s:19:"volunteering-local0";
    a:3:{
        s:8:"activity";
        s:23:"Mystic eye kolkata 2017";
        s:11:"description";
        s:239:"I was in ushering team and also in the flying squad consisting of only 5 odd people including me. We were told to fly around and lend our hand to anyone who needs it in the spot. And mostly the menial jobs were our responsibility 1st hand.";
        s:8:"location";
        s:7:"Kolkata";
    }
    s:19:"volunteering-local1";
    a:3:{
        s:8:"activity";
        s:17:"Inner Engineering";
        s:11:"description";
        s:104:"I have volunteered in the initiation day . I had the oppurtunity to be part of the kitchen works too"; // you miss the closing double quote and semicolon
    } // you miss the closing curly bracket
} // you miss the closing curly bracket

After fixing the structure, now you have trouble in offset errors. 修复结构后,现在您会遇到偏移误差的问题。

  • Line 1 says "a:3:value". 第1行说“ a:3:value”。 It means you have an array containing exactly 3 items inside. 这意味着您有一个内部恰好包含3个项目的数组。 But the value says you only have 2 items inside (with keys "volunteering-local0" and "volunteering-local1"). 但是该值表示您内部只有2个项目(键为“ volunteering-local0”和“ volunteering-local1”)。 So line 1 should be "a:2:value". 因此,第1行应为“ a:2:value”。

  • Line 16 says "s:104:value". 第16行说“ s:104:value”。 It means you have a string containing exactly 104 characters. 这意味着您有一个正好包含104个字符的字符串。 But the value says you only have 100 characters of string. 但是该值表示您只有100个字符的字符串。

  • There are still some invalid structures if you examine it deeper. 如果您更深入地研究它,仍然会有一些无效的结构。

The serialized array is broken, or let's say "invalid". 序列化的数组损坏,或者说“无效”。 That's why Doctrine throws an exception when it tries to unserialize the given serialized array to PHP array by calling "Doctrine\\DBAL\\Types\\ArrayType::convertToPHPValue($serializedValue)". 这就是为什么Doctrine通过调用“ Doctrine \\ DBAL \\ Types \\ ArrayType :: convertToPHPValue($ serializedValue)”尝试将给定的序列化数组反序列化为PHP数组时引发异常的原因。 Even when you try to unserialize it using PHP internal function "unserialize($serializedValue)", you will be caught in an error, too. 即使当您尝试使用PHP内部函数“ unserialize($ serializedValue)”对它进行反序列化时,也会遇到错误。 It will say "unserialize(): Error at offset 5 of 771 bytes". 它将显示“ unserialize():771字节的偏移量5处的错误”。

If I have to correct it, what I imagine of the original PHP array based on your serialized array would be: 如果必须纠正它,我对基于序列化数组的原始PHP数组的想象是:

array(
    array(
        'volunteering-local0' => array(
            'activity' => 'Mystic eye kolkata 2017',
            'description' => 'I was in ushering team and also in the flying squad consisting of only 5 odd people including me. We were told to fly around and lend our hand to anyone who needs it in the spot. And mostly the menial jobs were our responsibility 1st hand.',
            'location' => 'Kolkata',
        ),
    ),
    array(
        'volunteering-local1' => [
            'activity' => 'Inner Engineering',
            'description' => 'I have volunteered in the initiation day . I had the oppurtunity to be part of the kitchen works too',
        ],
    ],
]

And if I want the serialized array of that PHP array, it would be: 如果我想要该PHP数组的序列化数组,它将是:

a:2:{
    i:0;
    a:1:{
        s:19:"volunteering-local0";
        a:3:{
            s:8:"activity";
            s:23:"Mystic eye kolkata 2017";
            s:11:"description";
            s:239:"I was in ushering team and also in the flying squad consisting of only 5 odd people including me. We were told to fly around and lend our hand to anyone who needs it in the spot. And mostly the menial jobs were our responsibility 1st hand.";
            s:8:"location";
            s:7:"Kolkata";
        }
    }
    i:1;
    a:1:{
        s:19:"volunteering-local1";
        a:2:{
            s:8:"activity";s:17:"Inner Engineering";
            s:11:"description";
            s:100:"I have volunteered in the initiation day . I had the oppurtunity to be part of the kitchen works too";
        }
    }
}

And if I want a single line of that serialized array, it would be: 如果我想要该序列化数组的一行,它将是:

a:2:{i:0;a:1:{s:19:"volunteering-local0";a:3:{s:8:"activity";s:23:"Mystic eye kolkata 2017";s:11:"description";s:239:"I was in ushering team and also in the flying squad consisting of only 5 odd people including me. We were told to fly around and lend our hand to anyone who needs it in the spot. And mostly the menial jobs were our responsibility 1st hand.";s:8:"location";s:7:"Kolkata";}}i:1;a:1:{s:19:"volunteering-local1";a:2:{s:8:"activity";s:17:"Inner Engineering";s:11:"description";s:100:"I have volunteered in the initiation day . I had the oppurtunity to be part of the kitchen works too";}}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM