Luracast / Restler

Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and/or RESTful API
http://luracast.com/products/restler/
GNU Lesser General Public License v2.1
1.36k stars 315 forks source link

@throttle error, does it require ratelimit or something? #663

Closed abides closed 3 years ago

abides commented 3 years ago

Hello,

/**
 * Home Index
 *
 * @throttle 200
 *
 */
public function index()
{
    return $this->init;
}

Its actually working and delay request for 200ms but gives an error;

{"error":{"code":500,"errno":8,"message":"Undefined index: throttle","file":"\/var\/www\/tarama\/vendor\/restler\/framework\/Defaults.php","line":357}}

Does it require something else?

Arul- commented 3 years ago

What is the version of restler you are using? We tried with Restler 5, it works fine

abides commented 3 years ago

"restler/framework": "5.0.8"

Have php 7.4.18 also have fatal error handler and error_reporting(E_ALL); on development mode to see all kind of problematic stuff. Probably this trigger notice or something?

Edit: yes undefined index is php notice. Should i disable notices or this should be fixed?

Arul- commented 3 years ago

Can you try changing Line 357 of Defaults.php to the following

if (isset(Defaults::$validation[$name]) && is_array(Defaults::$validation[$name])) {

And then see if the error disappears

I could not reproduce the error so, need to fix it on yours. I tried with the following code throttle.zip

abides commented 3 years ago

Error (notice) dissapear with that. I'm against to make changes on the vendor code to fix something since its come back with first update. Can you change the master too if this change does not affect anything else?

Thank you, best regards.

Arul- commented 3 years ago

Done!