Don't put large blob data in objectcache
Don't put large blob data in objectcache

--- a/include/git/blob/Blob.class.php
+++ b/include/git/blob/Blob.class.php
@@ -11,6 +11,13 @@
 {
 
 	/**
+	 * Large blob threshold
+	 *
+	 * @var int
+	 */
+	const LargeBlobSize = 5242880;	// 5 megs
+
+	/**
 	 * The blob data
 	 *
 	 * @var string
@@ -234,10 +241,15 @@
 	 */
 	public function __sleep()
 	{
-		if (!$this->dataEncoded)
+		$properties = array('data', 'dataRead', 'dataEncoded', 'binary', 'size');
+
+		if ($this->dataRead && strlen($this->data) > GitPHP_Blob::LargeBlobSize) {
+			$this->data = null;
+			$this->dataRead = false;
+		}
+		
+		if ($this->dataRead && !$this->dataEncoded)
 			$this->EncodeData();
-
-		$properties = array('data', 'dataRead', 'dataEncoded', 'binary', 'size');
 
 		return array_merge($properties, parent::__sleep());
 	}

comments