From: Brad Jorsch Date: Fri, 3 Oct 2014 15:57:31 +0000 (-0400) Subject: Fix Status serialization with cleanupCallback as Closure X-Git-Tag: 1.31.0-rc.0~13698^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=2120bda6f26004ab1be34877fd880b0f01a01902;p=lhc%2Fweb%2Fwiklou.git Fix Status serialization with cleanupCallback as Closure 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 --- diff --git a/includes/Status.php b/includes/Status.php index 2a9d173ec0..0a8062c2a3 100644 --- a/includes/Status.php +++ b/includes/Status.php @@ -159,6 +159,15 @@ class Status { $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. */