Skip to content

Log error with MarkdownHelper on queue/run #20

Open

Description

@marc-farre

Log:

Could not execute queued job! Message: DOMDocument::loadHTML(): Empty string supplied as input Trace:#0 [internal function]: yii\base\ErrorHandler->handleError()
#1 /app/data/modules/rss/components/MarkdownHelper.php(43): DOMDocument->loadHTML()
#2 /app/data/modules/rss/jobs/GetFeedUpdates.php(180): sij\humhub\modules\rss\components\MarkdownHelper::translateHTML()
#3 /app/data/modules/rss/jobs/GetFeedUpdates.php(280): sij\humhub\modules\rss\jobs\GetFeedUpdates->parseNewsItem()
#4 [internal function]: sij\humhub\modules\rss\jobs\GetFeedUpdates->parseNewsChannel()
#5 /app/data/modules/rss/components/RssElement.php(54): call_user_func()
#6 /app/data/modules/rss/jobs/GetFeedUpdates.php(326): sij\humhub\modules\rss\components\RssElement->each()
#7 /app/data/modules/rss/jobs/GetFeedUpdates.php(408): sij\humhub\modules\rss\jobs\GetFeedUpdates->parseNewsFeed()
#8 /app/data/modules/rss/jobs/GetFeedUpdates.php(449): sij\humhub\modules\rss\jobs\GetFeedUpdates->downloadNewsFeed()
#9 /app/code/protected/humhub/modules/queue/ActiveJob.php(33): sij\humhub\modules\rss\jobs\GetFeedUpdates->run()
#10 /app/code/protected/vendor/yiisoft/yii2-queue/src/Queue.php(246): humhub\modules\queue\ActiveJob->execute()
#11 /app/code/protected/vendor/yiisoft/yii2-queue/src/cli/Queue.php(147): yii\queue\Queue->handleMessage()
#12 /app/code/protected/vendor/yiisoft/yii2-queue/src/drivers/db/Queue.php(83): yii\queue\cli\Queue->handleMessage()
#13 [internal function]: yii\queue\db\Queue->yii\queue\db\{closure}()
#14 /app/code/protected/vendor/yiisoft/yii2-queue/src/cli/Queue.php(117): call_user_func()
#15 /app/code/protected/vendor/yiisoft/yii2-queue/src/drivers/db/Queue.php(93): yii\queue\cli\Queue->runWorker()
#16 /app/code/protected/vendor/yiisoft/yii2-queue/src/drivers/db/Command.php(56): yii\queue\db\Queue->run()
#17 [internal function]: yii\queue\db\Command->actionRun()
#18 /app/code/protected/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#19 /app/code/protected/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams()
#20 /app/code/protected/vendor/yiisoft/yii2/console/Controller.php(184): yii\base\Controller->runAction()
#21 /app/code/protected/vendor/yiisoft/yii2/base/Module.php(534): yii\console\Controller->runAction()
#22 /app/code/protected/vendor/yiisoft/yii2/console/Application.php(181): yii\base\Module->runAction()
#23 /app/code/protected/vendor/yiisoft/yii2/console/Application.php(148): yii\console\Application->runAction()
#24 /app/code/protected/vendor/yiisoft/yii2/base/Application.php(392): yii\console\Application->handleRequest()
#25 /app/code/protected/yii(29): yii\base\Application->run()
#26 {main}

Maybe just at the beginning of the translateHTML method we should add:

        if (!$html) {
            return '';
        }

Activity

  1. StevenJoynt commented on Apr 4, 2022

    @StevenJoynt
    Owner

    Trace shows
    #2 /app/data/modules/rss/jobs/GetFeedUpdates.php(180): sij\humhub\modules\rss\components\MarkdownHelper::translateHTML()

    There isn't a call to translateHTML on line 180 of GetFeedUpdates in my version - it's later on at line 198. Has some code been deleted by accident?

    Simply returning an empty string will stop the exception happening, but it looks like something has gone wrong earlier - the feed should have some contents or it's not a feed! It's probably right that an exception is being thrown in this case.

    Is this a feed that has worked ok in the past? Can you access the feed using a different reader app or browser to see what should be displayed?

  2. marc-farre commented on Apr 15, 2022

    @marc-farre
    Author

    Thanks.
    I'm sorry, but I don't have enough time to investigate and it's not installed on a Humhub that I manage.
    The line number was different because it was the version 1.0.0.
    I updated the module version to 1.0.2 and now I have this error:

    [](https://hub.transition-space.org/admin/logging#)Could not execute queued job! Message: DOMDocument::loadHTML(): Empty string supplied as input Trace:#0 [internal function]: yii\base\ErrorHandler->handleError()
    #1 /app/data/modules/rss/components/MarkdownHelper.php(43): DOMDocument->loadHTML()
    #2 /app/data/modules/rss/jobs/GetFeedUpdates.php(198): sij\humhub\modules\rss\components\MarkdownHelper::translateHTML()
    #3 /app/data/modules/rss/jobs/GetFeedUpdates.php(301): sij\humhub\modules\rss\jobs\GetFeedUpdates->parseNewsItem()
    #4 [internal function]: sij\humhub\modules\rss\jobs\GetFeedUpdates->parseNewsChannel()
    #5 /app/data/modules/rss/components/RssElement.php(54): call_user_func()
    #6 /app/data/modules/rss/jobs/GetFeedUpdates.php(347): sij\humhub\modules\rss\components\RssElement->each()
    #7 /app/data/modules/rss/jobs/GetFeedUpdates.php(429): sij\humhub\modules\rss\jobs\GetFeedUpdates->parseNewsFeed()
    #8 /app/data/modules/rss/jobs/GetFeedUpdates.php(475): sij\humhub\modules\rss\jobs\GetFeedUpdates->downloadNewsFeed()
    #9 /app/code/protected/humhub/modules/queue/ActiveJob.php(33): sij\humhub\modules\rss\jobs\GetFeedUpdates->run()
    #10 /app/code/protected/vendor/yiisoft/yii2-queue/src/Queue.php(246): humhub\modules\queue\ActiveJob->execute()
    #11 /app/code/protected/vendor/yiisoft/yii2-queue/src/cli/Queue.php(147): yii\queue\Queue->handleMessage()
    #12 /app/code/protected/vendor/yiisoft/yii2-queue/src/drivers/db/Queue.php(83): yii\queue\cli\Queue->handleMessage()
    #13 [internal function]: yii\queue\db\Queue->yii\queue\db\{closure}()
    #14 /app/code/protected/vendor/yiisoft/yii2-queue/src/cli/Queue.php(117): call_user_func()
    #15 /app/code/protected/vendor/yiisoft/yii2-queue/src/drivers/db/Queue.php(93): yii\queue\cli\Queue->runWorker()
    #16 /app/code/protected/vendor/yiisoft/yii2-queue/src/drivers/db/Command.php(56): yii\queue\db\Queue->run()
    #17 [internal function]: yii\queue\db\Command->actionRun()
    #18 /app/code/protected/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
    #19 /app/code/protected/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams()
    #20 /app/code/protected/vendor/yiisoft/yii2/console/Controller.php(184): yii\base\Controller->runAction()
    #21 /app/code/protected/vendor/yiisoft/yii2/base/Module.php(534): yii\console\Controller->runAction()
    #22 /app/code/protected/vendor/yiisoft/yii2/console/Application.php(181): yii\base\Module->runAction()
    #23 /app/code/protected/vendor/yiisoft/yii2/console/Application.php(148): yii\console\Application->runAction()
    #24 /app/code/protected/vendor/yiisoft/yii2/base/Application.php(392): yii\console\Application->handleRequest()
    #25 /app/code/protected/yii(29): yii\base\Application->run()
    #26 {main}
    
  3. StevenJoynt commented on Apr 16, 2022

    @StevenJoynt
    Owner

    Could you tell me the URL of the RSS feed, so I can investigate the problem?

  4. marc-farre commented on Apr 16, 2022

    @marc-farre
    Author
  5. ArchBlood commented on Aug 5, 2022

    @ArchBlood
    Contributor

    @funkycram I'll look at it later tonight if that's okay with @StevenJoynt

  6. ArchBlood commented on Aug 6, 2022

    @ArchBlood
    Contributor

    @funkycram could you have your client try the following and see if it works?

    MarkdownHelper.zip

  7. marc-farre commented on Aug 6, 2022

    @marc-farre
    Author

    Thanks @ArchBlood .
    This file seems to have confusions between static and non static variables.
    E.g. the variable public static $logFileHandle is called by private static function log($text) with $this->logFileHandle.
    It should be static::$logFileHandle

  8. marc-farre commented on Aug 6, 2022

    @marc-farre
    Author

    Thanks @ArchBlood .
    This file seems to have confusions between static and non static variables.
    E.g. the variable public static $logFileHandle is called by private static function log($text) with $this->logFileHandle.
    It should be static::$logFileHandle

  9. ArchBlood commented on Aug 7, 2022

    @ArchBlood
    Contributor

    Thanks @ArchBlood .
    This file seems to have confusions between static and non static variables.
    E.g. the variable public static $logFileHandle is called by private static function log($text) with $this->logFileHandle.
    It should be static::$logFileHandle

    Yes, originally I was going to use static::logFileHandle using $ shouldn't make much of a difference should it? Overall I believe that the file itself could be retouched and refactored better. 🤔

  10. ArchBlood commented on Aug 7, 2022

    @ArchBlood
    Contributor

    So in turn the following should be displayed, once jobs run I see no errors actively;

        private static function log($text) {
            if (static::logFileHandle) {
                fwrite(static::logFileHandle, $text);
            }
        }

    I would also like to note that the other way didn't show any types of errors either, but only tested with PHP 8.0.x, further test on other versions would be recommended as well.

  11. marc-farre commented on Aug 9, 2022

    @marc-farre
    Author

    Then, what is the difference with your new MarkdownHelper class that could solve the bug?
    See diff merge here: https://www.diffchecker.com/Y4URXxmJ

    Thanks.

  12. ArchBlood commented on Aug 9, 2022

    @ArchBlood
    Contributor

    Then, what is the difference with your new MarkdownHelper class that could solve the bug?
    See diff merge here: https://www.diffchecker.com/Y4URXxmJ

    Thanks.

    $this-> calls the public function, whether it's static or not, within the class, that's about it.

  13. ArchBlood commented on Aug 9, 2022

    @ArchBlood
    Contributor

    Here's another example;

    <?php
    
    class greeting
    {
      public static function welcome()
     {
        echo "Hello World!";
      }
    
      public function __construct()
     {
        self::welcome();
      }
    }
    
    new greeting();
    ?>

    You'll always get the response Hello World! this way, the same can be said for variable functions when using $this-> in place of using the standard self:: or static::.

  14. marc-farre commented on Aug 10, 2022

    @marc-farre
    Author

    OK, thanks, but I cannot see the difference with your new MarkdownHelper class that could solve this bug.
    However, I tried your code, but now there are no error, with both codes (original and yours), so I cannot tell if it solves the bug.
    Anyway, thanks for the code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions