Logs for #cakephp

Page 18 of 36,922, showing 100 records out of 3,692,143 total, starting on record 1,701, ending on 1,800

# At Username Text
# Jun 29th 2021, 22:27 ndm You can't, neither is there syntax for it, nor would it work, as `matching()` uses an `INNER` join, so it's always exclusive. You need to use a `LEFT` join instead, and apply your conditions on the main query.
# Jun 29th 2021, 22:26 joey.mukherjee I saw that, but couldn't figure out how best to add the "matching" portion.
# Jun 29th 2021, 22:21 khalil @joey.mukherjee from the docs: ```$query = $articles->find()->where(function (QueryExpression $exp, Query $query) { // Use add() to add multiple conditions for the same field. $author = $query->newExpr()->or(['author_id' => 3])->add(['author_id' => 2]); $published = $query->newExpr()->and(['published' => true, 'view_count' => 10]); return $exp->or([ 'promoted' => true,
# Jun 29th 2021, 22:21 slackebot $query->newExpr()->and([$author, $published]) ]); });```
# Jun 29th 2021, 22:18 khalil Guys, I have a question, not directly related to CakePHP, but more on db schema level, but I kinda need advise in case someone went through this before. On a CakePHP e-commerce website, I'm working on product variations / attributes, Like, we have Size, Color, Make etc..., and the product can have any combination of these with specific prices, for instance, Size Large Red Leather for $10, Size Medium Red Leather $9 etc... and I'm
# Jun 29th 2021, 22:18 slackebot kinda confused with the database schema to make this happen, I'm trying to avoid EAV as much as I can, and I was thinking of using a json column type in MySQL, but since i have never used it before, I'm a bit concerned about performance, especially after what I read online that it has poor performance, and eventually I will need to query the attributes in the json field, so any advise regarding this is welcome!
# Jun 29th 2021, 22:16 joey.mukherjee How do I do an OR on a query that has a where or a matching. Something like : ->or (where (['TEST_TYPE' => 'WATR']), matching ('GroundWaterTests')) I want either TEST_TYPE is WATR or there is a related row in another table?
# Jun 29th 2021, 22:13 khalil Hello! congrats on the 4000+ members :)
# Jun 29th 2021, 22:13 kevin.pfeifer btw: we hit 4000+ members in the slack support channel :partying_face:
# Jun 29th 2021, 22:11 tyler.adam.lazenby ```public function setUp(): void { parent::setUp(); $state_owner = TableRegistry::getTableLocator()->get('StateOwners')->get(1); $operator = TableRegistry::getTableLocator()->get('Operators')->find()->first(); $this->order = file_get_contents(join(DS, [ROOT, 'tests', 'Resource', 'order.json'])); $registry = new ComponentRegistry(); $Woocommerce = new WoocommerceComponent($registry); $order =
# Jun 29th 2021, 22:11 slackebot json_decode($this->order, TRUE); $products = $order['line_items']; $line_items = $Woocommerce->getLineItems($products); $commission = $Woocommerce->getCommission($line_items); $this->OrderNotification = new OrderNotificationMailer([ 'state_owner_email' => $state_owner->state_owner_email, 'content' => compact('state_owner', 'commission', 'operator', 'order', 'line_items') ]); } public function
# Jun 29th 2021, 22:11 slackebot testSend(): void { $this->OrderNotification->send(); }```
# Jun 29th 2021, 22:11 tyler.adam.lazenby on the test
# Jun 29th 2021, 22:11 tyler.adam.lazenby kinda funny how much setup I had to do to make sure the email went through
# Jun 29th 2021, 22:11 kevin.pfeifer instead of the default Cake\Mailer\Renderer you can set a custom view instance
# Jun 29th 2021, 22:10 tyler.adam.lazenby almost through this
# Jun 29th 2021, 21:28 tyler.adam.lazenby what does the viewRender property of the mailer do?
# Jun 29th 2021, 20:21 kevin.pfeifer but if you manually create the mailer object anyways you should be fine
# Jun 29th 2021, 20:21 kevin.pfeifer But I currently don’t know if you can send reusable emails (like https://book.cakephp.org/4/en/core-libraries/email.html#creating-reusable-emails) via the queue mail task. I have already created an issue for that.
# Jun 29th 2021, 20:16 tyler.adam.lazenby Working on getting my data first and then going to see if I need to update to alpha... because I need to make sure I have some complex calculations done... by the end of the dasy
# Jun 29th 2021, 20:16 tyler.adam.lazenby @kevin.pfeifer I know I know... especially with abstraction
# Jun 29th 2021, 20:08 dereuromark Try the New alpha, I soon release then stable
# Jun 29th 2021, 19:58 kevin.pfeifer sometimes documentation is not that bad :)
# Jun 29th 2021, 19:57 tyler.adam.lazenby I was poking around in the source code and wasn't seeing that
# Jun 29th 2021, 19:57 tyler.adam.lazenby COOL
# Jun 29th 2021, 19:57 tyler.adam.lazenby oh ok
# Jun 29th 2021, 19:50 kevin.pfeifer https://github.com/dereuromark/cakephp-queue/tree/master/docs#using-built-in-email-task Here you can see that you can pass on a mailer object when creating the task => therefore yes, HTML mails are possible
# Jun 29th 2021, 19:42 tyler.adam.lazenby Hey @dereuromark Does your queue plugin default email task support sending HTML emails?
# Jun 29th 2021, 19:18 jadelbe418 I am running into some issues with sorting logic on a beforeFind() getting applied to constraints in the buildRules() when it should not be, on some legacy Cake 3 code I maintain. I was wondering if there is a better approach to implementing this than what I have in place. I wrote my question out with code samples on SO:
# Jun 29th 2021, 19:18 slackebot https://stackoverflow.com/questions/68184422/restrict-query-results-on-beforefind-table-call-back-without-breaking-buildrul
# Jun 29th 2021, 16:42 umer936 Yes, i get it while developing on Windows with PHPStorm. Never figured how to fix so I just run phpcs manually instead
# Jun 29th 2021, 16:04 japerlman @kevin.pfeifer Thanks for the feedback, I appreciate it.
# Jun 29th 2021, 15:31 ndm You gotta be careful with the term "request", that could easily be interpreted as "HTTP request", but I guess you're most likely referring to invoking some kind of read operation on a query/result in one and the same HTTP request? An answer to your question probably depends on how you generate the result set, how/where you apply the mapping, if you possibly reassign results, etc... so a code example might help here.
# Jun 29th 2021, 15:25 kevin.pfeifer @japerlman I would say either way is totally OK, it just depends what you/your customer prefers as a frontend experience and what you as a developer are more used to.
# Jun 29th 2021, 15:23 dereuromark Well, it is possible the the intoduced warning is a bit too harsh for some use cases, sure
# Jun 29th 2021, 15:22 japerlman I have very limited experience in web app dev and want to make sure I'm not approaching things incorrectly. If you were making an app that is just mostly data in/data out forms and reports is there any benefit to doing the backend in cakephp and exposing the api to a react front end? I've done two apps in the past 100% in cakephp 2 and 3 and I'm struggling with all the extra work to do the backend in cakephp and the frontend in
# Jun 29th 2021, 15:22 slackebot react just because 'it is the modern way'. am I wasting my time and is there anything 'wrong' with just doing it 100% in cakephp like I've done previously?
# Jun 29th 2021, 15:11 ndm Of course, I just don't see why it would be a problem in this specific case, unless the association is actually using a different target. Maybe I've overlooked that, and that is actually the case.
# Jun 29th 2021, 15:07 dereuromark npm: Sure, if those were fullly identical. but you could configure them slightly different each time, and in that case it would silently use a different one than you might want. So I guess that might have been the reason for the warning and the core to be a bit more strict since 4.1+
# Jun 29th 2021, 15:05 ndm @conehead Did you check if using `getTarget()` makes a difference, like `$this->Users->Books->getTarget()->find()->...`?
# Jun 29th 2021, 15:03 ndm Didn't follow the whole saga... but that looks a bit weird, why would using the same alias be a problem here when the parent is a different object? Shouldn't that work fine if the target/classname are the same? :thinking_face:
# Jun 29th 2021, 14:35 dereuromark what we wish and reality often dont go hand in hand. While I agree with u, it is not feasible here, unfortunately
# Jun 29th 2021, 14:34 conehead Not convenient to have: Users->contain(['UsersTags']); Employees->contain(['EmployeesTags']); I'd prefer to have: Users->contain(['Tags']); Employees->contain(['Tags']); and use some internal alias
# Jun 29th 2021, 14:33 dereuromark thus the unique names here (aliases).
# Jun 29th 2021, 14:33 dereuromark well, relations (assoc) have to be unique across the project to allow the registry to not confuse them.
# Jun 29th 2021, 14:33 kevin.pfeifer yes
# Jun 29th 2021, 14:33 conehead that sucks :P
# Jun 29th 2021, 14:32 slackebot => 'projects_projects', 'foreignKey' => 'parent_id', 'targetForeignKey' => 'child_id' ] );```
# Jun 29th 2021, 14:32 kevin.pfeifer i e.g. use that to create child and parent projects like that ``` $this->belongsToMany( 'ParentProjects', [ 'className' => 'AlfredProjects.Projects', 'joinTable' => 'projects_projects', 'foreignKey' => 'child_id', 'targetForeignKey' => 'parent_id' ] ); $this->belongsToMany( 'ChildProjects', [ 'className' => 'AlfredProjects.Projects', 'joinTable'
# Jun 29th 2021, 14:32 conehead Ah...but that would mean in every conain I would have to use the Alias name as well?
# Jun 29th 2021, 14:29 kevin.pfeifer the first parameter is the alias. see the example here where hasOne is used to join on addresses multiple times https://book.cakephp.org/4/en/orm/associations.html#hasone-associations
# Jun 29th 2021, 14:27 dereuromark The alias is the name, so yes
# Jun 29th 2021, 14:19 conehead It is not just for behaviors, but for associations as well. Can I set the alias directly when setting an association? According to the documentation it is not a possible key https://book.cakephp.org/4/en/orm/associations.html#belongstomany-associations
# Jun 29th 2021, 14:18 erwane Autoanswer : pass the remember_me data in hidden field : https://github.com/andrej-griniuk/cakephp-two-factor-auth/issues/19
# Jun 29th 2021, 14:13 dereuromark i dont follow. how is setting it through manual table different? its both config. and couldn't this be adapted to some kind of auto-config flag? so it can work across all Tables then as improvement directly on the behavior? sounds useful if you extensively use it.
# Jun 29th 2021, 14:10 conehead @dereuromark Guess tomorrow I will try to create my own table class that will automatically set the alias to $Alias$AssocName for each and every association. Setting in the config does work for your plugin, but won't work for other associations as the alias cannot be set there
# Jun 29th 2021, 14:05 erwane hi, it's me again ;) I'm trying to configure TFA Authentication plugin (https://github.com/andrej-griniuk/cakephp-two-factor-auth) with the `CookieAuthenticator aka remember_me` The request loose the `remember_me` field in the intermediate check form and cookie is not set. Someone already has this issue ?
# Jun 29th 2021, 13:51 kevin.pfeifer this event is being dispatched by • `findOrCreate` https://github.com/cakephp/cakephp/blob/ab052da10dc5ceb2444c29aef838d10844fe5995/src/ORM/Table.php#L1624 • `save` https://github.com/cakephp/cakephp/blob/ab052da10dc5ceb2444c29aef838d10844fe5995/src/ORM/Table.php#L1875 • `saveMany` https://github.com/cakephp/cakephp/blob/ab052da10dc5ceb2444c29aef838d10844fe5995/src/ORM/Table.php#L2266 not anywhere else. So if you do
# Jun 29th 2021, 13:51 slackebot a transaction yourself you will need to dispatch that event yourself too
# Jun 29th 2021, 13:44 birdy247 If saving inside a transaction, does the afterSaveCommit not get called?
# Jun 29th 2021, 13:34 dereuromark I would do it in the init config, but yeah that sounds like it would solve it
# Jun 29th 2021, 13:24 slackebot { $this->addBehavior('Tag'); $this->Tags->setAlias($this->getAlias . 'Tags'); ...``` But I got a feeling it is not possible because if it was this easy, it would probably be already automatically in it?
# Jun 29th 2021, 13:24 conehead Yes, that goes into the right direction. Although I don't see it as an issue of your plugin, but as an general Cake issue. Issue is even the wrong word. It is convenient the way it is described in the documentation, but it looks like duplicate assoc names can be used. @dereuromark Do you think it would solve the problem to override the alias for each Table? Something like this: ```public function initialize(array $config): void
# Jun 29th 2021, 13:19 theblackbird.eu Okay i really think it's a problem with the htaccess because I can open any catalog on the server through the domain... But it's not cake releated so I'll look elswere, thank you all for help.
# Jun 29th 2021, 13:12 dereuromark @conehead true. once you know more, feel free to update any docs here. So far I only know about https://github.com/dereuromark/cakephp-tags/tree/master/docs#multiple-tags-per-model docs, which kind of include the case of multiple such relations also across different tables then implicitly, but not explicitly (yet).
# Jun 29th 2021, 13:11 theblackbird.eu `App.base` seems to work, no obvious side effects either
# Jun 29th 2021, 13:07 theblackbird.eu I generate relative URLs using eg. `$this->Url->build('/')`
# Jun 29th 2021, 13:06 ndm Try setting `App.base` to an empty string. No guarantee you're not running into side effects with that.
# Jun 29th 2021, 13:05 kevin.pfeifer well do you actually generate absolute URLs or relative URLs?
# Jun 29th 2021, 12:57 theblackbird.eu And.. it also did nothing..
# Jun 29th 2021, 12:56 theblackbird.eu To the domain? yeah
# Jun 29th 2021, 12:56 admad `'https://yourdomain'`
# Jun 29th 2021, 12:55 admad then explicitly set `App.fullBaseUrl` in app.php
# Jun 29th 2021, 12:55 theblackbird.eu I can still access through /subdirectory and / and cake is adding /subdirectory/ to all urls
# Jun 29th 2021, 12:54 theblackbird.eu Well it changed nothing
# Jun 29th 2021, 12:54 admad you can't rely on cake's default when your server config is wacko :)
# Jun 29th 2021, 12:53 theblackbird.eu In the webroot? No, i'll try that
# Jun 29th 2021, 12:52 admad @theblackbird.eu did you add `RewriteBase /subdirectory` to the htacces in webroot foler?
# Jun 29th 2021, 12:50 conehead Yes, pretty much every Entity has Tags. And pretty much every Entity has AuditLogs. And many Entities are linked to each other, which have same AssocNames as well. I do have tested the software around 60%, which is by far not enough for an error that partly just silently fails. I just checked the Associations and Behaviors documentation and could not find any info about it. In my opinion there should be a fat warning, that
# Jun 29th 2021, 12:50 slackebot association names should be unique over the whole project (at least when only using cake magic)
# Jun 29th 2021, 12:49 theblackbird.eu I would just change apache config, but sadly i'm using hosting so i don't have access to configs or anything on the server. All i can do is htaccess really..
# Jun 29th 2021, 12:39 dereuromark just ignoring the chaining found error wont solve your issues
# Jun 29th 2021, 12:38 dereuromark Have Users and Books both tags? That might explain it. Here you need to indeed tell the behavior to alias the respective junction assocs, to make sure they are unique (Tagged => XTagged and YTagged)
# Jun 29th 2021, 12:36 kevin.pfeifer well do you have tests written for your app?
# Jun 29th 2021, 12:36 conehead And I just had the case with saving now, where it does not even throw an error, just ignores and does not save the tags.
# Jun 29th 2021, 12:35 conehead Pretty much every entity on my software uses Tags :( And I think this might affect everything that finds/saves Entities through other Tables. So I gotta be afraid that something is not working anymore whenever I use $this->Table1->Table2->find/save
# Jun 29th 2021, 12:34 slackebot (from <https://book.cakephp.org/4/en/installation.html#apache>) I can access all routes and files with proper urls but there is a problem. Whenever i use Url helper it appends the directory name to the url. For example doing `$this->Url->build('/')` gives me `domain.com/subdirectory` instead of `domain.com/`. Both of those url work when i open them in browser. How can i stop this from
# Jun 29th 2021, 12:34 slackebot happening? I don't want directory name in my url. Is it a problem with my .htaccess or cakephp config or something else?
# Jun 29th 2021, 12:34 theblackbird.eu Hello, I'm struggling with urls in Cakephp 4 and hope someone can help. Due to how server is set up i have to use .htaccess to redirect everything for a domain from root folder to subdirectroy - i sadly can't change that. I have my .htaccess set up and it seems to be working: <https://pastebin.com/Nt6cXjiQ> Both app root and webdirectory .htaccess are default
# Jun 29th 2021, 12:33 kevin.pfeifer well If you don't use any other BelongsToMany associations with the same alias on multiple tables you should be fine
# Jun 29th 2021, 12:31 conehead it screws up other stuff. This is just one case I found
# Jun 29th 2021, 12:31 conehead My problem is not how to fix it...my problem is more that I don't know if
# Jun 29th 2021, 12:29 kevin.pfeifer why it works one way but not the other could be a bug
# Jun 29th 2021, 12:29 kevin.pfeifer I would guess the easiest solution for you would be to define one association as UserTags and one as BookTags
# Jun 29th 2021, 12:28 conehead And the targets differs. Both Tables use "Tags" and that is the reason why it does fail when finding through an association
# Jun 29th 2021, 12:26 conehead Yes
# Jun 29th 2021, 12:26 kevin.pfeifer well this only means, that there is an association present with the same alias but different targets or foreignkeys
# Jun 29th 2021, 12:21 conehead Not sure if it should be this way or if this breaks other stuff for me as well :(
# Jun 29th 2021, 12:20 conehead https://github.com/cakephp/cakephp/commit/1335605f8c68e7bac19cbc1028e6e7c7f2b479fa
# Jun 29th 2021, 12:03 conehead But the point is, it is working with the TableLocator, but not with the association. Just trying to find out what changed with cake 4.1