Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal Error: The string is not 64 bit long. PHP 8.2 #33

Open
waqasalieee opened this issue May 8, 2024 · 0 comments
Open

Fatal Error: The string is not 64 bit long. PHP 8.2 #33

waqasalieee opened this issue May 8, 2024 · 0 comments

Comments

@waqasalieee
Copy link

Fatal error: Uncaught bandwidthThrottle\tokenBucket\storage\StorageException:
The string is not 64 bit long. in \bandwidth-throttle\token-bucket\classes\util\DoublePacker.php: 41

Having this error when applied following code in constructor of ApiController, and tried to use consume:

`function __construct() {

    $this->storage = new FileStorage(__DIR__ . "/api.bucket");
    $this->rate    = new Rate(10, Rate::SECOND);
    $this->bucket  = new TokenBucket(10, $this->rate, $this->storage);
     //Following code executed once, then commented
     //$this->bucket->bootstrap(10);

}`

`protected function checkRateLimit() {

    if (!$this->bucket->consume(1, $seconds)) {
        http_response_code(429);
        header(sprintf("Retry-After: %d", floor($seconds)));
        exit();
    }
    //echo "Continue to API response";
    return true;

}`

I have also noticed FileStorage class is sending blank string to unpack( ) function in Double Packer on line 129.

bandwidthThrottle\tokenBucket\util\DoublePacker: :unpack('')

Please guide what's going wrong here?

@waqasalieee waqasalieee changed the title The string is not 64 bit long. PHP 8.2 Fatal Error: The string is not 64 bit long. PHP 8.2 May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant