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

Nette database #20

Open
rumcais opened this issue Apr 20, 2020 · 1 comment
Open

Nette database #20

rumcais opened this issue Apr 20, 2020 · 1 comment

Comments

@rumcais
Copy link

rumcais commented Apr 20, 2020

Potřeboval bych poradit jak použít jsonrpc2 s nette database. Na jiném projektu jsem používal knihovnu dibi. A s tou to fungovalo bez problému. Můj příklad:

$server = new \Lightbulb\Json\Rpc2\Server;
$server->situace = new SituaceHandler($this->kategorieModel);
class SituaceHandler {
public $kategorieModel;
function __construct($kategorieModel)
{
$this->kategorieModel=$kategorieModel;
}
public function sendAllCategory() {
$retval=$this->kategorieModel->getAllData()->order('position')->fetchAssoc('id');
$ret = new \stdClass();
$ret->result=$retval;
return $ret;
}

Server mi vrací:
response:
{
jsonrpc : 2.0,
error : {
code : 0,
message : fopen(/app/src/app/../temp/cache/_Nette.Database.f9984012521578c37f8a2419fc007bbe/_48509200295bca30224e85dbd33b9614): failed to open stream: No such file or directory\nin file /app/src/vendor/nette/caching/src/Caching/Storages/FileStorage.php\non line 298
},
id : 0
}

@zabous
Copy link
Contributor

zabous commented Apr 21, 2020

To není problém Nette Database, ale problém toho, že Nette Database využívá Nette\Caching\Storages\FileStorage, kde je oteviraní neexistujícího souboru ošetřeno pomocí tzv. error-control operatoru @

Viz na:
https://github.com/nette/caching/blob/be02f7e597c61484cf75735370d2a3836984c82f/src/Caching/Storages/FileStorage.php#L298

Aby toto potlačení chyby fungovalo i ve vlastním error handleru, měla by v něm být tato řádka:
if (error_reporting() === 0) {
return false;
}

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

2 participants