# |
Dec 12th 2019, 14:05 |
yadav.manu36 |
Hi all I have facing some issue with cookies so please help me. I have created cookie on signup page like below: if($this->request->getQuery('referral') andand !$cookies->has('referralCode')){ $cookie = (new \Cake\Http\Cookie\Cookie('referralCode')) ->withValue($this->request->getQuery('referral')) ->withExpiry(new \DateTime('+1 year')) ->withPath('/') |
# |
Dec 12th 2019, 13:32 |
neothermic |
so https://book.cakephp.org/3/en/views/helpers/form.html#customizing-the-templates-formhelper-uses and https://book.cakephp.org/3/en/views/helpers/form.html#adding-custom-widgets be my reading? |
# |
Dec 12th 2019, 13:31 |
dereuromark |
the latter also, with a custom widget |
# |
Dec 12th 2019, 13:30 |
dereuromark |
order is easy, custom template code |
# |
Dec 12th 2019, 13:28 |
neothermic |
in cake 3, is there a way to either: a) change the order of the selects rendered for a date input, or b) make it spit out a HTML5 date picker? |
# |
Dec 12th 2019, 13:27 |
info315 |
if a child crash, the daemon itself will restart it. if the main daemon crashes systemd will restart it |
# |
Dec 12th 2019, 13:20 |
challgren |
What happens when the process crashes? |
# |
Dec 12th 2019, 13:18 |
dereuromark |
respawning as I showed above every x minutes is a safer and less error prone concept. |
# |
Dec 12th 2019, 13:18 |
dereuromark |
thats an anti pattern IMO, for php related background work. |
# |
Dec 12th 2019, 13:15 |
info315 |
Long Running^^: `Active: active (running) since Mo 2019-11-18 09:31:05 CET; 3 weeks 3 days ago` |
# |
Dec 12th 2019, 13:13 |
info315 |
Ok perfect, thanks! |
# |
Dec 12th 2019, 13:12 |
ndm |
If the automatic reconnect doesn't work, I'd check why it doesn't work though, and then maybe implement a custom retry command / strategy. |
# |
Dec 12th 2019, 13:10 |
ndm |
Probably best to throw an `isConnected()` in there too, but yes, that should work, assuming only a single connection is being used... |
# |
Dec 12th 2019, 13:09 |
info315 |
If yes i assume this is the way to go? ``` $connection = $SystemsettingsTable->getConnection(); $connection->disconnect(); $connection->connect();``` |
# |
Dec 12th 2019, 13:08 |
info315 |
@ndm perfect I will try this with an testing shell if the reconnecting thing is still required with cake4. |
# |
Dec 12th 2019, 13:04 |
ndm |
@info315 You can always call `disconnect()/connect()` on the connection, but that should happen automatically now, check `\Cake\Database\Connection::getDisconnectRetry()` |
# |
Dec 12th 2019, 13:01 |
dereuromark |
E.g. https://github.com/dereuromark/cakephp-queue has been processing millions of DB based jobs like this. without a single incident. maybe a better fit, if you want to have a simple and single connection until job finishs and closes the worker down. especially for low traffic sites the perfect fit, because of its 0 dependencies and lightweight approach. |
# |
Dec 12th 2019, 13:00 |
info315 |
that's as good as reconnect. |
# |
Dec 12th 2019, 13:00 |
info315 |
how can i open and close a the mysql session with cakephp? |
# |
Dec 12th 2019, 12:59 |
steinkel |
^this |
# |
Dec 12th 2019, 12:59 |
dereuromark |
why dont they open up the connection as needed? they should trigger a php job, open and close after done. |
# |
Dec 12th 2019, 12:59 |
info315 |
but this issue is beyond the queue. because my worker is a php daemon (a cakephp command to be exactly). |
# |
Dec 12th 2019, 12:58 |
info315 |
RabbitMq and Gearman |
# |
Dec 12th 2019, 12:58 |
dereuromark |
what queue solution are you using? the right ones all dont have these issues. |
# |
Dec 12th 2019, 12:58 |
info315 |
i just need to reconnect to the database, thats all. |
# |
Dec 12th 2019, 12:57 |
info315 |
i dont have any memory issues |
# |
Dec 12th 2019, 12:57 |
steinkel |
you get rid of potential memory leaks for long running php daemons this way too |
# |
Dec 12th 2019, 12:57 |
info315 |
so there is no public method to reconnect to the database? |
# |
Dec 12th 2019, 12:56 |
steinkel |
@info315 in that case I usually set the daemon to die after processing X jobs, and configure monit or systemd to keep it alive |
# |
Dec 12th 2019, 12:56 |
dereuromark |
well, with that we dont have any such issue at all. |
# |
Dec 12th 2019, 12:56 |
info315 |
@dereuromark i have a job queue |
# |
Dec 12th 2019, 12:56 |
dereuromark |
nook24: you might want to use a job queue instead :slightly_smiling_face: |
# |
Dec 12th 2019, 12:51 |
slackebot2 |
error. For this reason my cake2 daemon just reconnects to the database straight after it gets a new job. This is no "my query is slow", "or your code is bad" issue. |
# |
Dec 12th 2019, 12:51 |
info315 |
Its not a long running SQL query... I have a daemon which is running in the background 24/7. It sleeps until it gets a job todo. By default, CakePHP connects to the database, if the daemon starts (`systemctl stat foo.service`). If the daemon now sleeps for 3 days because of there is no job to do, the database server close the connection. If than Cakephp wants to query something because of an incoming job, you get an mysql has gone away |
# |
Dec 12th 2019, 12:51 |
jotpe |
Maybe you need the field to be accessible? |
# |
Dec 12th 2019, 12:50 |
jotpe |
:thinking_face: |
# |
Dec 12th 2019, 12:49 |
neon1024 |
Yes, it seems to be fine in the entity, but when it hits Twig is vanishes |
# |
Dec 12th 2019, 12:48 |
jotpe |
? |
# |
Dec 12th 2019, 12:48 |
jotpe |
And in your Controller its working @neon1024 |
# |
Dec 12th 2019, 12:47 |
neon1024 |
https://book.cakephp.org/3/en/orm/entities.html#accessors-mutators |
# |
Dec 12th 2019, 12:47 |
kevin.pfeifer |
i dont know what you mean with ``Entity accessor methods`` |