Have Chunked upload jobs bail if cannot associate with session.
authorBrian Wolff <bawolff+wn@gmail.com>
Mon, 8 Jul 2013 01:37:02 +0000 (22:37 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Mon, 8 Jul 2013 02:30:39 +0000 (23:30 -0300)
Also add docs about how suhosin.session.encrypt tends to break
this (I was thinking about throwing an exception if the setting was
on in RequestContext::importScopedSession, but the docs seem to
indicate that you can tweak how the session is encrypted, so it
sounds like somebody could set up their php so everything worked).

Bug: 48371
Change-Id: I5a471c1f941fce046451fbb9abce1c830185cabb

includes/DefaultSettings.php
includes/context/RequestContext.php
includes/job/jobs/AssembleUploadChunksJob.php
includes/job/jobs/PublishStashedFileJob.php

index f9d280f..6447316 100644 (file)
@@ -323,6 +323,9 @@ $wgAllowImageMoving = true;
  * Enable deferred upload tasks that use the job queue.
  * Only enable this if job runners are set up for both the
  * 'AssembleUploadChunks' and 'PublishStashedFile' job types.
+ *
+ * @note If you use suhosin, this setting is incompatible with
+ *   suhosin.session.encrypt.
  */
 $wgEnableAsyncUploads = false;
 
index cb26dcf..b9dbe77 100644 (file)
@@ -417,7 +417,9 @@ class RequestContext implements IContextSource {
         * This will setup the session from the given ID. This is useful when
         * background scripts inherit context when acting on behalf of a user.
         *
-        * $param array $params Result of RequestContext::exportSession()
+        * @note suhosin.session.encrypt may interfere with this method.
+        *
+        * @param array $params Result of RequestContext::exportSession()
         * @return ScopedCallback
         * @throws MWException
         * @since 1.21
index 4fe1753..6237e56 100644 (file)
@@ -42,6 +42,15 @@ class AssembleUploadChunksJob extends Job {
                                return false;
                        }
 
+                       if ( count( $_SESSION ) === 0 ) {
+                               // Empty session probably indicates that we didn't associate
+                               // with the session correctly. Note that being able to load
+                               // the user does not necessarily mean the session was loaded.
+                               // Most likely cause by suhosin.session.encrypt = On.
+                               $this->setLastError( "Error associating with user session. Try setting suhosin.session.encrypt = Off" );
+                               return false;
+                       }
+
                        UploadBase::setSessionStatus(
                                $this->params['filekey'],
                                array( 'result' => 'Poll', 'stage' => 'assembling', 'status' => Status::newGood() )
index 5114dc0..5a24f93 100644 (file)
@@ -42,6 +42,16 @@ class PublishStashedFileJob extends Job {
                                return false;
                        }
 
+                       if ( count( $_SESSION ) === 0 ) {
+                               // Empty session probably indicates that we didn't associate
+                               // with the session correctly. Note that being able to load
+                               // the user does not necessarily mean the session was loaded.
+                               // Most likely cause by suhosin.session.encrypt = On.
+                               $this->setLastError( "Error associating with user session. Try setting suhosin.session.encrypt = Off" );
+                               return false;
+                       }
+
+
                        UploadBase::setSessionStatus(
                                $this->params['filekey'],
                                array( 'result' => 'Poll', 'stage' => 'publish', 'status' => Status::newGood() )