Logs for #cakephp

Page 5 of 36,478, showing 100 records out of 3,647,701 total, starting on record 401, ending on 500

# At Username Text
# Jan 22nd, 22:44 luizcmarin Perhaps some more information will help. I'm trying to use https://github.com/josbeir/cakephp-filesystem to make uoploads of images. But it's hard ...
# Jan 22nd, 22:39 luizcmarin does anyone know anything about this type of error?
# Jan 22nd, 22:13 luizcmarin I have a type => 'File' field for uploading an image. It is mysql, varchar (255). I am now getting the "Object of class Laminas \ Diactoros \ UploadedFile error could not be converted to string." What type should be used in the database? I installed the plugin https://github.com/josbeir/cakephp-filesystem.
# Jan 22nd, 20:24 challgren Install the suggestions if your going to use them such as storing them in a cloud provider
# Jan 22nd, 20:23 luizcmarin @challgren install suggests ?
# Jan 22nd, 20:21 luizcmarin I hope it is easy to use...
# Jan 22nd, 20:19 challgren `composer require josbeir/cakephp-filesystem`
# Jan 22nd, 20:19 challgren Yes release 2.0.1
# Jan 22nd, 20:18 luizcmarin https://github.com/josbeir/cakephp-filesystem :+1: I will follow here. Right?
# Jan 22nd, 20:17 luizcmarin :man-facepalming:
# Jan 22nd, 20:17 luizcmarin I didn't translate your message correctly ...
# Jan 22nd, 20:17 challgren Only the plugins with :strawberry: are cake 4 comp
# Jan 22nd, 20:16 challgren https://cakesf.slack.com/archives/C053DPNGT/p1579654134254800
# Jan 22nd, 20:15 luizcmarin @challgren
# Jan 22nd, 20:15 luizcmarin and there is only this 'master'
# Jan 22nd, 20:15 luizcmarin yea. I followed your link and got this
# Jan 22nd, 20:13 challgren The friendsofcake/awesome list has good plugins that are cake 4 ready
# Jan 22nd, 20:12 luizcmarin ops moment
# Jan 22nd, 20:12 challgren @luizcmarin why are you using a 3 plugin with cake 4?
# Jan 22nd, 20:10 luizcmarin I will change this to start
# Jan 22nd, 20:09 luizcmarin https://github.com/Xety/Cake3-Upload
# Jan 22nd, 20:09 ricksaccous are you using a plugin or writing file handling on your own?
# Jan 22nd, 20:09 ricksaccous make sure you can reference it
# Jan 22nd, 20:08 ricksaccous @luizcmarin generally you want to store the name of the file (maybe filesize/mimetype) and then move the file into a local directory
# Jan 22nd, 20:07 luizcmarin I'm trying to upload my first files. The fields are varchar (255) (mysql). It returns the image error. As I said, it is my first test and I do not know how to solve this type of error. Please, any guidance?
# Jan 22nd, 19:48 FredSavagely Oh, looks like you might be right: https://github.com/cakephp/authentication/blob/master/src/View/Helper/IdentityHelper.php
# Jan 22nd, 19:46 ndm Views have access to the request via `$this->request` too
# Jan 22nd, 19:43 ricksaccous you might as well do that, i think they had an identity helper
# Jan 22nd, 19:42 FredSavagely Like, assign the response of `$this->request->getAttribute('identity')` to the view?
# Jan 22nd, 19:42 FredSavagely Do I just need to assign the identity to the view and then use that to check?
# Jan 22nd, 19:41 ricksaccous they have that but if it doesn't have what you want then you should figure out a way to handle it on your own
# Jan 22nd, 19:41 ricksaccous https://book.cakephp.org/authorization/2/en/middleware.html#identity-decorator
# Jan 22nd, 19:40 ricksaccous oh, within the view...
# Jan 22nd, 19:40 ricksaccous https://github.com/cakephp/authorization
# Jan 22nd, 19:39 ricksaccous yeah, there's docs for the authorization plugin
# Jan 22nd, 19:37 FredSavagely Is there a resource somewhere that can show me how to use authorization within the view in CakePHP 4?
# Jan 22nd, 17:56 jslamka5685 I am already ordering the query. I will make sure I am not overlooking something
# Jan 22nd, 17:55 ricksaccous show what you're attempting if you want
# Jan 22nd, 17:55 ricksaccous or you can simply ->order() the query you are paginating
# Jan 22nd, 17:55 ricksaccous you can set it in the paginator settings via 'order'
# Jan 22nd, 17:54 jslamka5685 How can I grab the latest 20 sort ASC?
# Jan 22nd, 17:54 ricksaccous why not just sort by created ASC
# Jan 22nd, 17:53 jslamka5685 I planned to sort by created DESC then reverse the order so the conversation appears like what youd see in your SMS app on a phone
# Jan 22nd, 17:53 ricksaccous if you don't care about sorting by other means
# Jan 22nd, 17:53 ricksaccous also you can either use paginator links or simply order the query you are paginating
# Jan 22nd, 17:52 ricksaccous this doesn't explain why you have to reverse the item order
# Jan 22nd, 17:52 ricksaccous ok...
# Jan 22nd, 17:50 jslamka5685 messaging between two users
# Jan 22nd, 17:50 jslamka5685 It is to display a conversation
# Jan 22nd, 17:50 ricksaccous @jslamka5685 this is the problem you are trying to solve right?
# Jan 22nd, 17:49 ricksaccous are you wanting to reverse them because of possible nulls?
# Jan 22nd, 17:49 ricksaccous ....
# Jan 22nd, 17:49 mark.mikkelson couldn't you just use ?sort=dateanddirection=desc
# Jan 22nd, 17:40 jslamka5685 How can I reverse the item order in a pagintor object?
# Jan 22nd, 17:39 jslamka5685 To do this, I believe I need to select records in descending order and then reverse them
# Jan 22nd, 17:39 jslamka5685 When working with Cake3x paginator, I am looking to get the latest records in ASC order.
# Jan 22nd, 17:25 mark.mikkelson Afternoon all. (in 3.7.7) I'm trying to disable the CSRF middleware for a route or just entirely for the full cake app, but having no joy. I've implemented what's documented here: https://book.cakephp.org/3/en/controllers/middleware.html#cross-site-request-forgery-csrf-middleware (ie. modified application.php and config/routes.php) however, end up getting the same error "Error: Missing CSRF token cookie" when im making json posts to
# Jan 22nd, 17:25 slackebot my end point ( /tickets/update ) . I have this in my routes.php : `Router::scope('/tickets', function (RouteBuilder $routes) {` `});`
# Jan 22nd, 17:19 matt thanks for helping guys
# Jan 22nd, 17:18 matt deleting the table i felt was a good approch
# Jan 22nd, 16:33 neon1024 ..and allows easier re-indexing
# Jan 22nd, 16:26 ricksaccous that would invalidate the key constraint though, but i don't know if that wuold stop you from destroying/recreating the table
# Jan 22nd, 16:26 ricksaccous that's what i tend to do
# Jan 22nd, 16:26 ricksaccous after that use logic to refill the data if the data is necessary
# Jan 22nd, 16:26 ricksaccous destroy the table in a migration and recreate it
# Jan 22nd, 16:25 ricksaccous when trying to change the primary key to another column it's usually not worth it
# Jan 22nd, 16:25 matt i think it worked but when it tried to backfill the table it sets all to 0
# Jan 22nd, 16:25 matt PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY' in /home/vagrant/Apps/clubtrac.local/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php:16
# Jan 22nd, 16:24 ndm https://book.cakephp.org/phinx/0/en/migrations.html#working-with-foreign-keys
# Jan 22nd, 16:24 matt will try that
# Jan 22nd, 16:23 ndm So there's a foreign key constraint that you need to drop first
# Jan 22nd, 16:23 matt gives me this error
# Jan 22nd, 16:22 matt DOException: SQLSTATE[HY000]: General error: 1553 Cannot drop index 'PRIMARY': needed in a foreign key constraint in /home/vagrant/Apps/clubtrac.local/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php:16
# Jan 22nd, 16:22 ndm Also what does "doesn't work" mean exactly?
# Jan 22nd, 16:22 ndm Have you changed your respective CakePHP table class accordingly too?
# Jan 22nd, 16:21 matt doesnt work
# Jan 22nd, 16:21 matt i tried this
# Jan 22nd, 16:21 matt ``` $table->addColumn('id','integer', [ 'length' => 11, 'null' => false, 'default' => null, ]); $table->changePrimaryKey(['id']);```
# Jan 22nd, 16:20 ndm @matt There's the `changePrimaryKey()` method: https://book.cakephp.org/phinx/0/en/migrations.html#changing-the-primary-key
# Jan 22nd, 16:15 matt ```attendees(id,member_id,occ_id) - new table```
# Jan 22nd, 16:15 em That could clarify this situation a little bit i think
# Jan 22nd, 16:15 matt ```attendees(member_id,occ_id) - old table```
# Jan 22nd, 16:14 matt i need the new primary key to be a 'id' column
# Jan 22nd, 16:14 matt How do i change the primary key of table that was earlier using a composite key from a migration?
# Jan 22nd, 16:13 ndm I wonder if the validator should maybe pass a custom flag into the context argument, so that one could properly determine how the method is invoked
# Jan 22nd, 16:12 ndm You're welcome
# Jan 22nd, 16:10 em @ndm now i see that isEmptyAllowed() has no data parameter at all :) And i got about custom validation, Thank you :)
# Jan 22nd, 16:09 ndm You need to understand that these rules are invoked in different scenarios, and account for no data being present accordingly. In forms, the rule will be invoked to determine whether to set the `required` attribute on the HTML element. If you can't work out something that works in both form context and actual data validation context, then you'll probably need a custom validation rule instead.
# Jan 22nd, 16:06 em @ndm Okay, so i should not use $validator->notEmptyString() for that purpose, right ?
# Jan 22nd, 16:04 ndm The form context couldn't pass any data even if it wanted to, as the validator API (`\Cake\Validation\Validator::isEmptyAllowed()`) doesn't support that
# Jan 22nd, 16:02 ndm If you are referring to it being invoked when you create form controls (as opposed to validation being executed when you patch/create your entity with the submitted form data), then yes, that is expected.
# Jan 22nd, 16:00 em @ndm In controller i get my user entity with $this->Users->get($id); Then i pass this user entity into the view. There i create form like this: ```<?php echo $this->Form->create($user); ?> <?php echo $this->Form->control('firstname') ?> <?php echo $this->Form->control('lastname', ) ?> <?php echo $this->Form->submit(__('Save')); ?> <?php echo $this->Form->end(); ?>``` So, i do not specify any context for this form. I expected that data will be
# Jan 22nd, 16:00 slackebot passed to validator, but it does not. Is it expected like this ?
# Jan 22nd, 15:58 ndm you're welcome
# Jan 22nd, 15:57 ndm @em In which context (application wise) is the data empty? Are you specifically refering to when its invoked as a part of creating form controls? In that case it's expected to be empty, as the form context doesn't try to pass in any data
# Jan 22nd, 15:56 crayfishuk @ndm thanks :)
# Jan 22nd, 15:50 crayfishuk Good advice re being familiar with the destination - obvious when you say it out loud :grinning:
# Jan 22nd, 15:50 crayfishuk Good point. We've been in v2 for years. Only recently getting our heads round v3!
# Jan 22nd, 15:49 em ```$validator->notEmptyString('name', __('Specify your name'), function($context) { if (isset($context['data']['role'])) { return $context['data']['role'] === 'partner'; } return false; });``` I have trouble with $context[‘data’]. Somehow it is always empty even if i add entity to $this->Form->create($user); Does anyone have any ideas ? I use cake 4 version
# Jan 22nd, 15:49 ndm @crayfishuk That really depends on the complexity of the application. You most likely won't get it into a working state just by using the upgrade tool, I've yet to see even one application for which that worked, but if it's not to complex, and largely follows the conventions, then an upgrade could be the way to go to avoid all the repetitive tasks. I'd always recommend to first make yourself familiar with the version that you're upgrading too, to