admin管理员组文章数量:1395785
I have a problem which I can't figure out. I have a collection of object which sometimes can be very big. I have to store the entire collection as a serialized transient. The problem is that when the serialized string has more than 60000 characters the insertion in the DB fails.
Why? I checked the wp_options table and the "value" column is a longtext. Which holds 4GB of data, am I right?
I have a problem which I can't figure out. I have a collection of object which sometimes can be very big. I have to store the entire collection as a serialized transient. The problem is that when the serialized string has more than 60000 characters the insertion in the DB fails.
Why? I checked the wp_options table and the "value" column is a longtext. Which holds 4GB of data, am I right?
Share Improve this question asked Feb 10, 2020 at 12:39 SebaSbsSebaSbs 1011 bronze badge 3- What's the specific error you're getting? It might not be getting as far as the database, e.g. if the database driver is rejecting the string or maybe PHP's serialization. – Rup Commented Feb 10, 2020 at 12:46
- But that does feel like you ought to break up the transient: are you going to need all 60K's worth of data every time you read it? Or can you divide it up into more specific values, or filter out fields you're serializing that you won't actually need when you're consuming the list, or write the transient as the summary of data you actually need, or something else etc. – Rup Commented Feb 10, 2020 at 12:48
- 1 Are you using memcached or some other object cache? Those might have their own limits on value size. – Vitauts Stočka Commented Feb 10, 2020 at 15:01
1 Answer
Reset to default 0I found the problem! Everything was ok with the transient, the problem was that I'm using php's substr() to cut an object property value if exceeds maximum characters. When in that string there was an accented character there was a problem with the encoding. So the serialized collection had an encoding issue at character 60000... I fixed it using substr_mb() and specifying UTF-8 as encoding.
Hard to debug this issue since wpdb doesn't throw any error when there is an encoding problem.
本文标签: databasesettransient fails if the value has more than 60000 characters
版权声明:本文标题:database - set_transient fails if the value has more than 60.000 characters 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744758331a2623598.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论