@@ -142,9 +142,22 @@ public function createAlias($original_id, $new_id) {
142142 "properties " => array ("distinct_id " => $ original_id , "alias " => $ new_id , "token " => $ this ->_token )
143143 );
144144
145- $ options = array_merge ($ this ->_options , array ("endpoint " => $ this ->_getEndpoint (), "fork " => false ));
146- $ curlConsumer = new ConsumerStrategies_CurlConsumer ($ options );
147- $ success = $ curlConsumer ->persist (array ($ msg ));
145+ // Save the current fork/async options
146+ $ old_fork = isset ($ this ->_options ['fork ' ]) ? $ this ->_options ['fork ' ] : false ;
147+ $ old_async = isset ($ this ->_options ['async ' ]) ? $ this ->_options ['async ' ] : false ;
148+
149+ // Override fork/async to make the new consumer synchronous
150+ $ this ->_options ['fork ' ] = false ;
151+ $ this ->_options ['async ' ] = false ;
152+
153+ // The name is ambiguous, but this creates a new consumer with current $this->_options
154+ $ consumer = $ this ->_getConsumer ();
155+ $ success = $ consumer ->persist (array ($ msg ));
156+
157+ // Restore the original fork/async settings
158+ $ this ->_options ['fork ' ] = $ old_fork ;
159+ $ this ->_options ['async ' ] = $ old_async ;
160+
148161 if (!$ success ) {
149162 error_log ("Creating Mixpanel Alias (original id: $ original_id, new id: $ new_id) failed " );
150163 throw new Exception ("Tried to create an alias but the call was not successful " );
@@ -161,4 +174,4 @@ public function createAlias($original_id, $new_id) {
161174 function _getEndpoint () {
162175 return $ this ->_options ['events_endpoint ' ];
163176 }
164- }
177+ }
0 commit comments