bigbluebutton / bigbluebutton-api-php

Offical @BigBlueButton PHP API
https://github.com/bigbluebutton/bigbluebutton/
GNU Lesser General Public License v3.0
183 stars 199 forks source link

Request to BigBlueButton 2.7 server to retrieve recordings results in an error with api-php 2.3.0, works with 2.2.0 #254

Closed RikiTikiTawi116 closed 6 months ago

RikiTikiTawi116 commented 6 months ago

BIGBLUEBUTTON_RELEASE=2.7.0 bigbluebutton/bigbluebutton-api-php: 2.3.0 Drupal 10.2.6 php 8.2

Request to BigBlueButton server to retrieve recordings results in an error: 'Error: Typed property BigBlueButton\BigBlueButton::$urlBuilder must not be accessed before initialization in BigBlueButton\BigBlueButton->getUrlBuilder() (line 522 of /var/www/testhd.com/vendor/bigbluebutton/bigbluebutton-api-php/src/BigBlueButton.php).' being displayed on request project page (in my situation this is Drupal-based project). After that, at BigBlueButton server logs messages are displayed several times a minute, as from incoming duplicates of this request, despite the fact that on the Drupal site working with BBB API, no actions are performed at this moment that can lead to the PHP code execution. Cron jobs do not run that often.

At the same time, BIGBLUEBUTTON 2.7 works with bigbluebutton/bigbluebutton-api-php: 2.2.0 without any problems in the same case. BIGBLUEBUTTON 3.0.0-alpha.5 works with bigbluebutton/bigbluebutton-api-php: 2.3.0 flawlessly just as well.

изображение изображение изображение

GhaziTriki commented 6 months ago

Hello @RikiTikiTawi116,

Indeed some implementation have changed in 2.3.0 and unfortunately the change logs are not ready yet.

As I understand you the class VirtualEventBBB extending BigBlueButton class. If you check the BigBlueButton constructor you will find where URLBuilder class is created. You should not forget to create an instance of URLBuilder class in your extended class.

RikiTikiTawi116 commented 6 months ago

@GhaziTriki изображение Thank you for your reply! I have created UrlBuilder class.

GhaziTriki commented 6 months ago

If you have nothing special in the constructor the following one should do the job.

    public function __construct(?string $baseUrl = null, ?string $secret = null, ?array $opts = [])
    {
        parent::__construct($baseUrl, $secret, $opts);
    }

On the other hand $urlBuilder is private so you can access to it. We might need to get it back to protected to keep the way open for custom integrations or add a modifier method.

DigitalTimK commented 6 months ago

@RikiTikiTawi116

Can you please try to work with the BBB-Class? The UrlBuilder will be provided by the getter of this object.

$bbb = new BigBlueButton($baseUrl, $secret);
$urlBuilder = $bbb->getUrlBuilder();

or link this

class BbbExtension extends BigBlueButton
{
    private UrlBuilder $urlBuilder;

    public function __construct($baseUrl, $secret)
    {
        parent::__construct($baseUrl, $secret);
        $this->setHashingAlgorithm(HashingAlgorithm::SHA_256); // not needed as SHA256 is already the default
        $this->urlBuilder = $this->getUrlBuilder();                            
    }
}

Does this help?

RikiTikiTawi116 commented 6 months ago

@DigitalTimK Thank you, it works with BBB-Class without $urlBuilder and also with your constructor from second variant. Problem is I do not write all the code myself, as well as many other developers. At least half of my Drupal project is contrib modules like Virtual Event BBB, Virtual Events, Social Virtual Event BBB, being a dependency of the large-scale heavily-used Drupal profile Open Social. Extended class VirtualEventBBB is being used extensively in these modules. For a moment their respective Maintainers do not support these modules for latest versions of Drupal, BBB and BBB-api. I've performed basic upgrades to match present-day specifications, later, when everything will be production-ready, I plan to contact the Maintainers to help to update publicly-available versions of those modules. It will greatly help, if you'll return urlBuilder as protected one. However I do fully understand your reasons behind the decision to make urlBuilder private, so, if you'll choose not to reverse it, please, let me know, so I'll be able to modify mentioned codebase accordingly.

GhaziTriki commented 6 months ago

Hi @RikiTikiTawi116,

The https://github.com/bigbluebutton/bigbluebutton-api-php/releases/tag/2.3.1 fixes this scope regression issue and adds an implementation for the insertDocument API, however this implementation is completely rewritten in the next major release.

RikiTikiTawi116 commented 6 months ago

Thank you @GhaziTriki