Open mbeckerle-xqueue opened 2 years ago
If you send a PR I'd be happy to merge :)
Hi,
unfortunately I only found the source of the problem but I do not know how to solve it in a correct way so it still / again works. I was hoping you see the above information and have already a solution in your mind, once you are done reading :D
Hi, I've the same problem after an update to laravel 9.36.3: Illegal offset type in isset or empty. Unfortunately, I don't have the knowledge to solve this...
Please, can you give us a solution to this?
Thanks in advance.
Richard
Just for your information: I temporarily "solved" this by fixing my Laravel Framework to the latest 9.35 version
"laravel/framework": "9.35.1",
The critical commit was added in the first 9.36 release. Unfortunately I also have not really found a solution, so I hope for @Flynsarmy to better understand how it should be right.
Hi @mbeckerle-xqueue,
I will try this in a couple of days... Thanks for your comment on this!
I hope it will be fixed soon.
Thanks!
Richard
Is this issue solved ? i found this also on this 9.40.1 version. @Flynsarmy @hoekie
i can propose a quickfix for someone to include in this package:
in Flynsarmy/DbBladeCompiler/DbBladeCompilerEngine.php add
/**
* @param string $compiled_path
* @param array $data
* @return string
*/
public function getContent(string $compiled_path, array $data)
{
return $this->evaluatePath($compiled_path, $data);
}
and update \Flynsarmy\DbBladeCompiler\DbView::getContents to
protected function getContents()
{
$field = $this->config->get('db-blade-compiler.model_property');
$this->path->{$field} = $this->content_field;
$compiler = $this->engine->getCompiler();
$compiler->compile($this->path);
return $this->engine->getContent($compiler->getCompiledPath($this->path), $this->data);
}
maybe this could be improved but it works for now
Cool! Thanks @Marcel-Sass
I will try this in the next few days!
Is anyone fixing this, otherwise we have no option we need to remove the dependency?
Because we need to update the dependencies for our users.
No Solution Until Now ??
I'm fixing it with change laravel version to "laravel/framework": "9.35.1" in your_app_name/composer.json and changing APP_URL in .env from APP_URL=http://localhost:8000 to APP_URL=http://127.0.0.1:8000. Might this help you all
The problem is with the path src/Illuminate/View/Engines/CompilerEngine.php in the function get() line 61 inside if(!isset($this->compiledOrNotExpired[$path])) the variable $path is not sent as an array but full path and that's why it can't produce an array.
As solved is if(!isset($path))
Hey for everyone trying to render blade, you could use: https://laravel.com/docs/9.x/blade#rendering-inline-blade-templates Hopefully this helps!
i can propose a quickfix for someone to include in this package:
in Flynsarmy/DbBladeCompiler/DbBladeCompilerEngine.php add
/** * @param string $compiled_path * @param array $data * @return string */ public function getContent(string $compiled_path, array $data) { return $this->evaluatePath($compiled_path, $data); }
and update \Flynsarmy\DbBladeCompiler\DbView::getContents to
protected function getContents() { $field = $this->config->get('db-blade-compiler.model_property'); $this->path->{$field} = $this->content_field; $compiler = $this->engine->getCompiler(); $compiler->compile($this->path); return $this->engine->getContent($compiler->getCompiledPath($this->path), $this->data); }
maybe this could be improved but it works for now
Thank you for sharing. It solved the issue.
It looks like you closed the PR. Was there a problem with it?
If someone could test and confirm the issue is now fixed I'll close this issue.
I'm getting an error on Laravel 10 (using @section)
The only quick solution for this specific issue on Laravel 10, is adding the View Factory class to the data variable on
vendor/flynsarmy/db-blade-compiler/src/Flynsarmy/DbBladeCompiler/DbBladeCompilerEngine.php
public function getContent(string $compiled_path, array $data) { $data['__env'] = app(\Illuminate\View\Factory::class); return $this->evaluatePath($compiled_path, $data); }
And updating function getContents() on the the file (@Marcel-Sass suggestion):
vendor/flynsarmy/db-blade-compiler/src/Flynsarmy/DbBladeCompiler/DbView.php
protected function getContents() { $field = $this->config->get('db-blade-compiler.model_property'); $this->path->{$field} = $this->content_field; $compiler = $this->engine->getCompiler(); $compiler->compile($this->path);
return $this->engine->getContent($compiler->getCompiledPath($this->path), $this->data);
}
Could you please publish a new release with the fix merged in master
? thx !
It sounds like there's an issue on Laravel 10 (latest version). That'll need to get fixed before I'll make a new release. If someone wants to send a PR I'll merge.
The package does not work with Laravel 9 & Laravel 10 for now
At least the last commit on master
makes it compatible with Laravel 9 (wich is my use case, and I assume for others as well), it would be great to publish a release that fixes at least half of the problem 🙂
Done
Hi,
with an update from Laravel 9.34.0 to 9.36.3 I get this error when creating a view from database: Illegal offset type in isset or empty
I compared the files before and after the update and this is the commit that breaks this project: https://github.com/laravel/framework/commit/331bf9c2e393e9b459a05c0d01d89cf9fdd20282
In DbView (https://github.com/Flynsarmy/laravel-db-blade-compiler/blob/master/src/Flynsarmy/DbBladeCompiler/DbView.php) the path is set to be the model: $this->path = $model;
Later the content is set to $this->path->__db_blade_compiler_content_field which is then passed over getContents() to the engine: $this->engine->get($this->path, $this->gatherData())
Laravels compiler engine expects a string in "public function get($path, array $data = [])" and since that commit they even use that path an array key, which fails in the end, was currently a model is used.
I am not so deep into all the internal template handling, so I hope my findings can at least help you to fix this.
Marcus