danog / MadelineProto

Async PHP client API for the telegram MTProto protocol
https://docs.madelineproto.xyz
GNU Affero General Public License v3.0
2.74k stars 617 forks source link

Class Naming Mismatch in `danog\MadelineProto\EventHandler\Pinned` #1492

Closed a-kbv closed 4 months ago

a-kbv commented 4 months ago

Describe the bug When processing updates using the danog\MadelineProto library, I encountered a RuntimeException due to an autoloader expecting a class named danog\MadelineProto\EventHandler\Pinned which is supposed to be defined in the Pinned.php file. However, the actual class name in the file is PinPinned, leading to a naming mismatch that prevents the autoloader from locating the correct class.

To Reproduce The issue occurs during the update handling process where an update to pinned messages is being wrapped.

Steps to reproduce the behavior:

  1. Run the MadelineProto event handling loop that processes updates.
  2. When an update to pinned messages is encountered, the error is thrown due to the autoloader's class name expectation.

Expected behavior I expected the autoloader to locate and load the appropriate class to handle the pinning of messages without any runtime exceptions.

Logs Here is the sanitized stack trace of the error:

An error occured while wrapping {"_":"updatePinnedMessages","pinned":false,"peer":-419887xxxx,"messages":[846xxx],"pts":208xxxx,"pts_count":0}: RuntimeException: The autoloader expected class "danog\MadelineProto\EventHandler\Pinned" to be defined in file "LOCALPATH/vendor/composer/../danog/madelineproto/src/EventHandler/Pinned.php". The file was found but the class was not in it, the class name or namespace probably has a typo. in LOCALPATH/vendor/symfony/error-handler/DebugClassLoader.php:354
Stack trace:
#0 LOCALPATH/vendor/symfony/error-handler/DebugClassLoader.php(311): Symfony\Component\ErrorHandler\DebugClassLoader->checkClass()
#1 LOCALPATH/vendor/danog/madelineproto/src/EventHandler/Pinned/PinnedGroupMessages.php(25): Symfony\Component\ErrorHandler\DebugClassLoader->loadClass()
#2 LOCALPATH/vendor/symfony/error-handler/DebugClassLoader.php(300): include('...')
#3 LOCALPATH/vendor/danog/madelineproto/src/MTProtoTools/UpdateHandler.php(481): Symfony\Component\ErrorHandler\DebugClassLoader->loadClass()
#4 LOCALPATH/vendor/danog/madelineproto/src/MTProtoTools/UpdateHandler.php(431): danog\MadelineProto\MTProto->wrapPin()
#5 LOCALPATH/vendor/danog/madelineproto/src/MTProtoTools/UpdateHandler.php(212): danog\MadelineProto\MTProto->wrapUpdate()
#6 LOCALPATH/vendor/danog/madelineproto/src/MTProtoTools/UpdateHandler.php(1246): danog\MadelineProto\MTProto->eventUpdateHandler()
#7 LOCALPATH/vendor/danog/madelineproto/src/MTProtoTools/UpdateHandler.php(1240): danog\MadelineProto\MTProto->handleUpdate()
#8 LOCALPATH/vendor/danog/madelineproto/src/Loop/Update/FeedLoop.php(97): danog\MadelineProto\MTProto->saveUpdate()
#9 LOCALPATH/vendor/danog/loop/lib/Loop.php(139): danog\MadelineProto\Loop\Update\FeedLoop->loop()
#10 LOCALPATH/vendor/danog/loop/lib/Loop.php(251): danog\Loop\Loop->loopInternal()
#11 LOCALPATH/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(597): danog\Loop\Loop->danog\Loop\{closure}()
#12 [internal function]: Revolt\EventLoop\Internal\AbstractDriver->Revolt\EventLoop\Internal\{closure}()
#13 LOCALPATH/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(497): Fiber->resume()
#14 LOCALPATH/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(553): Revolt\EventLoop\Internal\AbstractDriver->invokeCallbacks()
#15 [internal function]: Revolt\EventLoop\Internal\AbstractDriver->Revolt\EventLoop\Internal\{closure}()
#16 LOCALPATH/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php(94): Fiber->resume()
#17 LOCALPATH/vendor/revolt/event-loop/src/EventLoop/Internal/DriverSuspension.php(117): Revolt\EventLoop\Internal\AbstractDriver->Revolt\EventLoop\Internal\{closure}()
#18 LOCALPATH/vendor/amphp/amp/src/Future.php(251): Revolt\EventLoop\Internal\DriverSuspension->suspend()
#19 LOCALPATH/vendor/danog/madelineproto/src/Wrappers/Loop.php(107): Amp\Future->await()
#20 LOCALPATH/vendor/danog/madelineproto/src/AbstractAPI.php(84): danog\MadelineProto\MTProto->loop()
#21 LOCALPATH/vendor/danog/madelineproto/src/AbstractAPI.php(65): danog\MadelineProto\AbstractAPI->startAndLoopLogic()
#22 LOCALPATH/vendor/danog/madelineproto/src/EventHandler.php(78): danog\MadelineProto\AbstractAPI->startAndLoopInternal() 

Environment (please complete the following information):

Additional context Please advise on the appropriate steps to resolve this issue, whether it is a library update or a usage correction on my end.

Thank you for your attention to this matter.


danog commented 4 months ago

Please update to beta194.