From 2120bda6f26004ab1be34877fd880b0f01a01902 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Fri, 3 Oct 2014 11:57:31 -0400 Subject: [PATCH] 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 --- includes/Status.php | 9 +++++++++ 1 file changed, 9 insertions(+) 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. */ -- 2.20.1