We already have Status objects throw away the cleanupCallback in
__wakeup. Why not also implement __sleep to not save it in the first
place?
The immediate motivation here is that cleanupCallback could be a
Closure, which causes an exception when serialization is attempted (e.g.
when trying to save the Status if an AssembleUploadChunks job fails
verification).
Note this leaves __wakeup intact, in case of old objects where
cleanupCallback is still present in the serialized representation.
Change-Id: I3aa756cd4eb5553ce0b95e7088b929b2f529abfe
$this->ok = false;
}
+ /**
+ * Don't save the callback when serializing, because Closures can't be
+ * serialized and we're going to clear it in __wakeup anyway.
+ */
+ public function __sleep() {
+ $keys = array_keys( get_object_vars( $this ) );
+ return array_diff( $keys, array( 'cleanCallback' ) );
+ }
+
/**
* Sanitize the callback parameter on wakeup, to avoid arbitrary execution.
*/