# |
Apr 22nd 2021, 14:04 |
davinci |
it does not show the URL :S |
# |
Apr 22nd 2021, 14:02 |
kevin.pfeifer |
well, I am on Cake 4 and not cake 2 but i guess it should still have that in there |
# |
Apr 22nd 2021, 14:02 |
slackebot |
105``` |
# |
Apr 22nd 2021, 14:02 |
kevin.pfeifer |
```2021-04-15 20:14:49 Notice: Notice (8): Trying to get property 'name' of non-object in [<my-path>/templates/Projects/overview.php, line 43] Request URL: /projects/overview Referer URL: http://alfred.sunlime.cc:8000/projects/edit/395 Trace: Cake\Error\BaseErrorHandler::handleError() - CORE/src/Error/BaseErrorHandler.php, line 188 DebugKit\Plugin::DebugKit\{closure}() - ROOT/vendor/cakephp/debug_kit/src/Plugin.php, line |
# |
Apr 22nd 2021, 14:01 |
kevin.pfeifer |
The log should tell you which Request and Referer the user used to get to that error I guess you already checked that |
# |
Apr 22nd 2021, 13:44 |
davinci |
happens many times a day, so it's not just a fluke, but... |
# |
Apr 22nd 2021, 13:43 |
davinci |
I see it happening a decent amount in the logs, but have no idea how to reproduce or what to even try to get it to reproduce |
# |
Apr 22nd 2021, 13:43 |
davinci |
@kevin.pfeifer cannot reproduce :( |
# |
Apr 22nd 2021, 13:43 |
kevin.pfeifer |
if you can reproduce it i would set an `xdebug_break()` in the template and look at the available variables and the call stack |
# |
Apr 22nd 2021, 13:40 |
davinci |
This isn't the exact method, but it's pretty darn close to this simple: ```public function confirm($id = null) { $order = $this->Order->getDetails($id); $this->set(compact('order')); }``` and yet somehow, in logs, I'm seeing that the view is throwing `Undefined variable: order in...` the view file, right at the top of the View. |
# |
Apr 22nd 2021, 13:37 |
davinci |
Getting "undefined variable `order` ..." in a view where it seems clear it should always have the variable defined. Are there edge-cases that allow a view to load without setting the variables from the controller? (cakephp 2.x) |
# |
Apr 22nd 2021, 12:39 |
marius.treu |
thanks for the help! |
# |
Apr 22nd 2021, 12:39 |
marius.treu |
i saw it but didnt quite understand it to be honest lol |
# |
Apr 22nd 2021, 11:25 |
admad |
Also if you use authorization plugin it already provides the feature to redirect to required URL on authorization failure https://book.cakephp.org/authorization/2/en/middleware.html#handling-unauthorized-requests |
# |
Apr 22nd 2021, 11:17 |
admad |
@marius.treu congrats on your hack. The proper way to achieve the same would be to use a custom exception renderer https://book.cakephp.org/4/en/development/errors.html#custom-exceptionrenderer |
# |
Apr 22nd 2021, 08:42 |
slackebot |
ApplicationExceptionHandler::handleException($e); } } |
# |
Apr 22nd 2021, 08:42 |
marius.treu |
public function invokeAction(Closure $action, array $args): void { try { parent::invokeAction($action, $args); } catch (UnauthorizedResourceRequest $unauthorizedResourceRequest) { $response = $this->redirectToLandingPage(); } catch (Throwable $e) { $response = |
# |
Apr 22nd 2021, 08:41 |
marius.treu |
@admad i found the solution, you just have to overwrite the invokeAction function in the controller |
# |
Apr 22nd 2021, 06:43 |
nayakvradhit |
Ok sure thanks |
# |
Apr 22nd 2021, 06:43 |
nayakvradhit |
Yeah info.php was working strange |
# |
Apr 22nd 2021, 06:13 |
asyraf.wahianuar |
great! thanks, @kevin.pfeifer |
# |
Apr 22nd 2021, 06:11 |
kevin.pfeifer |
as stated here https://book.cakephp.org/4/en/development/sessions.html#accessing-the-session-object |
# |
Apr 22nd 2021, 06:10 |
kevin.pfeifer |
you first have to get the currrent session variable via ```$session = $this->getRequest()->getSession();``` |
# |
Apr 22nd 2021, 06:07 |
asyraf.wahianuar |
hello, im trying to write a session in cakephp 4. this is the code: $session->write('pin2', $this->request->getData('pin2')); However, it show undefined variable session. Any suggestion? |
# |
Apr 22nd 2021, 05:39 |
kevin.pfeifer |
but ok, reloading the service is pretty mandatory ^^ |
# |
Apr 22nd 2021, 05:39 |
kevin.pfeifer |
this doesn’t make sense because why did /info.php work |
# |
Apr 22nd 2021, 05:16 |
nayakvradhit |
Thanks for your help !!!! |
# |
Apr 22nd 2021, 05:15 |
nayakvradhit |
I was just starting apache without stopping apache that was the. Main cause |
# |
Apr 22nd 2021, 05:15 |
nayakvradhit |
Issue was o wasn't restarting apache |
# |
Apr 22nd 2021, 05:15 |
nayakvradhit |
I am able to resolve that webroot path now my app. Is running on ipaddress/ when I set to dcp root to webroot |
# |
Apr 22nd 2021, 05:14 |
nayakvradhit |
Hi Kevin |
# |
Apr 21st 2021, 22:25 |
rightscoreanalysis |
the plugins directory is in the project root, is that correct? Currently my project doesn't this folder |
# |
Apr 21st 2021, 17:36 |
rightscoreanalysis |
awesome thanks |
# |
Apr 21st 2021, 17:33 |
steinkel |
600 for files even more restrictive |
# |
Apr 21st 2021, 17:32 |
steinkel |
@rightscoreanalysis that'll work but it's too permissive, check the user running your php engine, usually `www-data` or `apache` and change ownership of the app/tmp folder to him, then 770 would work fine |
# |
Apr 21st 2021, 17:09 |
rightscoreanalysis |
anyone know the correct permission for the tmp folder in cake2, 777 ser recursively on the tmp works, but not sure if 777 is only required on a subfolder? |
# |
Apr 21st 2021, 15:13 |
Cyrille37 |
Hello. I'm trying to implement the deprecated Controller::isAuthorized() with the new Authentication and Authorization plugins but I could not find the way. For example in the method "canAccess()" of the "RequestAuthorizationMiddleware" I could not get an instance of the current Controller. Any idea ?? |
# |
Apr 21st 2021, 14:56 |
marius.treu |
it makes things way more easy for debugging |
# |
Apr 21st 2021, 14:46 |
marius.treu |
if there is no such thing its not too bad |
# |
Apr 21st 2021, 14:46 |
marius.treu |
instead of always wrapping the code of an action with try catch, i prefer to have a generic approach |
# |
Apr 21st 2021, 14:45 |
marius.treu |
i dont want to render exceptions (with Custom ExceptionRenderer), but i have multiple actions which throw the same error and i simply want to catch this one and react to it |