Skip to content

Commit 7c06073

Browse files
committed
[Messenger] Fix opcache preload with alias classes
1 parent ce41f1e commit 7c06073

File tree

8 files changed

+32
-8
lines changed

8 files changed

+32
-8
lines changed

Transport/AmqpFactory.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,7 @@ public function createExchange(\AMQPChannel $channel): \AMQPExchange
3333
return new \AMQPExchange($channel);
3434
}
3535
}
36-
class_alias(AmqpFactory::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpFactory::class);
36+
37+
if (!class_exists(\Symfony\Component\Messenger\Transport\AmqpExt\AmqpFactory::class, false)) {
38+
class_alias(AmqpFactory::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpFactory::class);
39+
}

Transport/AmqpReceivedStamp.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ public function getQueueName(): string
3737
return $this->queueName;
3838
}
3939
}
40-
class_alias(AmqpReceivedStamp::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpReceivedStamp::class);
40+
41+
if (!class_exists(\Symfony\Component\Messenger\Transport\AmqpExt\AmqpReceivedStamp::class, false)) {
42+
class_alias(AmqpReceivedStamp::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpReceivedStamp::class);
43+
}

Transport/AmqpReceiver.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,7 @@ private function findAmqpStamp(Envelope $envelope): AmqpReceivedStamp
136136
return $amqpReceivedStamp;
137137
}
138138
}
139-
class_alias(AmqpReceiver::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpReceiver::class);
139+
140+
if (!class_exists(\Symfony\Component\Messenger\Transport\AmqpExt\AmqpReceiver::class, false)) {
141+
class_alias(AmqpReceiver::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpReceiver::class);
142+
}

Transport/AmqpSender.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,7 @@ public function send(Envelope $envelope): Envelope
7575
return $envelope;
7676
}
7777
}
78-
class_alias(AmqpSender::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpSender::class);
78+
79+
if (!class_exists(\Symfony\Component\Messenger\Transport\AmqpExt\AmqpSender::class, false)) {
80+
class_alias(AmqpSender::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpSender::class);
81+
}

Transport/AmqpStamp.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,7 @@ public static function createWithAttributes(array $attributes, self $previousSta
7474
);
7575
}
7676
}
77-
class_alias(AmqpStamp::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpStamp::class);
77+
78+
if (!class_exists(\Symfony\Component\Messenger\Transport\AmqpExt\AmqpStamp::class, false)) {
79+
class_alias(AmqpStamp::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpStamp::class);
80+
}

Transport/AmqpTransport.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,7 @@ private function getSender(): AmqpSender
9292
return $this->sender = new AmqpSender($this->connection, $this->serializer);
9393
}
9494
}
95-
class_alias(AmqpTransport::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransport::class);
95+
96+
if (!class_exists(\Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransport::class, false)) {
97+
class_alias(AmqpTransport::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransport::class);
98+
}

Transport/AmqpTransportFactory.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ public function supports(string $dsn, array $options): bool
3232
return 0 === strpos($dsn, 'amqp://') || 0 === strpos($dsn, 'amqps://');
3333
}
3434
}
35-
class_alias(AmqpTransportFactory::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransportFactory::class);
35+
36+
if (!class_exists(\Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransportFactory::class, false)) {
37+
class_alias(AmqpTransportFactory::class, \Symfony\Component\Messenger\Transport\AmqpExt\AmqpTransportFactory::class);
38+
}

Transport/Connection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,4 +588,7 @@ private function getRoutingKeyForMessage(?AmqpStamp $amqpStamp): ?string
588588
return (null !== $amqpStamp ? $amqpStamp->getRoutingKey() : null) ?? $this->getDefaultPublishRoutingKey();
589589
}
590590
}
591-
class_alias(Connection::class, \Symfony\Component\Messenger\Transport\AmqpExt\Connection::class);
591+
592+
if (!class_exists(\Symfony\Component\Messenger\Transport\AmqpExt\Connection::class, false)) {
593+
class_alias(Connection::class, \Symfony\Component\Messenger\Transport\AmqpExt\Connection::class);
594+
}

0 commit comments

Comments
 (0)