kriss_feed
kriss_feed copied to clipboard
Notice: unserialize() [function.unserialize]: Error at offset
Try to find out why there are some data corruption. For now I don't think it's because of kriss_feed as used php functions are :
PHPPREFIX
. base64_encode(gzdeflate(serialize($this->_data)))
. PHPSUFFIX
and
$this->_data = unserialize(
gzinflate(
base64_decode(
substr(
file_get_contents($this->dataFile),
strlen(PHPPREFIX),
-strlen(PHPSUFFIX)
)
)
)
);
The problem is that php seems to fail to serialize the data.
This issue will be here to list php versions and try to find why there is such strange problem :-( #140 #159
I didn't read all the source or the way you coded it, but it seems that you're not using any locking mechanism. So, what if the user tries to read or write data while a cronjob is writing at the same time ? You should try to replace file_get_contents and file_put_contents everywhere by manual reads, and then use the flock function to force the other threads to wait the end of an operation to start another.
EDIT : it seems that file_put_contents has a flag named "LOCK_EX", maybe it's an easier solution.
I've thought about that but the strange thing is that the data is well written meaning for me that it's not linked to a concurrent access to the file. Actually, it's possible to unzip and decode the file. The problem occurs when unserializing the data. For example : I've got this on problematic data :
aFy8gDA0k7DF:{ia:2s:10at10:"64879083:101t10atee";
while it should look like this :
s:12:"1pXdLQZlExjw";a:2:{i:0;i:1364966392;i:1;i:1;}
I don't know if it's possible that this is effectively link to LOCK
I've added a LOCK_EX when writing data and cache https://github.com/tontof/kriss_feed/commit/175d8882004aff2f6e2518f2ac171d7f606fe549 Wait and see