# |
May 15th 2019, 13:41 |
neon1024 |
Maybe `rm -rf vendor andand composer clearcache andand composer install` ? |
# |
May 15th 2019, 13:38 |
neon1024 |
`composer why-not intercom/intercom-php` ? |
# |
May 15th 2019, 13:36 |
spriz |
`intercom/intercom-php:^4.0.0 php-http/guzzle6-adapter` is no problem - but `intercom/intercom-php:^4.0.2 php-http/guzzle6-adapter` suddenly is :thinking_face: |
# |
May 15th 2019, 13:34 |
spriz |
I know this is a composer-related question and not cake, but I guess this is a piece of cake for someone but me - can someone explain me why composer is getting to the concluison to install v1.1.0 out of (seemingly) nowhere?! :) https://gist.github.com/Spriz/54801e1e9e29d5a7340263f372c3fab0 |
# |
May 15th 2019, 13:34 |
admad |
you should be able to do what you want |
# |
May 15th 2019, 13:28 |
waspinator |
@admad so this is expected behavior, and I should be able to do what I want by understanding https://github.com/cakephp/cakephp/blob/master/src/ORM/Marshaller.php ? |
# |
May 15th 2019, 13:26 |
m.hoffs |
Anyone has a bit spare time to help me with debugging ? |
# |
May 15th 2019, 13:16 |
admad |
so you need to dig into the marshaller and see why it does so :slightly_smiling_face: |
# |
May 15th 2019, 13:15 |
waspinator |
but only if the ids are the same. If I add two different users to the group it works as expected, saving the join data as well |
# |
May 15th 2019, 13:14 |
slackebot |
} ``` |
# |
May 15th 2019, 13:14 |
slackebot |
=> [], '[repository]' => 'Users' } ], '[new]' => false, '[accessible]' => [ 'name' => true, 'users' => true ], '[dirty]' => [ 'users' => true, 'modified' => true ], '[original]' => [ 'modified' => object(Cake\I18n\FrozenTime) { 'time' => '2019-05-15T12:19:14+00:00', 'timezone' => 'UTC', 'fixedNowTime' => false } ], '[hasErrors]' => false, '[errors]' => [], '[invalid]' => [], '[repository]' => 'UserGroups' |
# |
May 15th 2019, 13:14 |
slackebot |
'[virtual]' => [], '[hasErrors]' => false, '[errors]' => [], '[invalid]' => [], '[repository]' => 'UserGroupsUsers' }, '[new]' => false, '[accessible]' => [ 'username' => true, 'user_groups' => true, '_joinData' => true ], '[dirty]' => [ '_joinData' => true ], '[original]' => [ '_joinData' => [ 'role' => 'student' ] ], '[hasErrors]' => false, '[errors]' => [], '[invalid]' |
# |
May 15th 2019, 13:14 |
waspinator |
@admad it ignores the second association ``` object(App\Model\Entity\UserGroup) { 'id' => (int) 1, 'name' => 'test', 'users' => [ (int) 0 => object(App\Model\Entity\User) { 'id' => (int) 2, 'username' => 'test', '_joinData' => object(Cake\ORM\Entity) { 'role' => 'student', '[new]' => true, '[accessible]' => [ '*' => true ], '[dirty]' => [ 'role' => true ], '[original]' => [], |
# |
May 15th 2019, 13:07 |
dereuromark |
I need to manually Router::connect() everywhere |
# |
May 15th 2019, 12:57 |
dereuromark |
Still cant find my routes in the component test case |
# |
May 15th 2019, 12:57 |
dereuromark |
@spriz Nope, I got those and doesnt work. I even manually loaded routes.php file and did Router::reload() before that one. |
# |
May 15th 2019, 12:52 |
admad |
@waspinator show the debug of entity after calling `patchEntity()` |
# |
May 15th 2019, 12:39 |
waspinator |
so the relationship for user 2 being a `teacher` in this group is lost |
# |
May 15th 2019, 12:39 |
waspinator |
in the example, only the first is saved |
# |
May 15th 2019, 12:38 |
waspinator |
if the `id`s of the users are different it works |
# |
May 15th 2019, 12:38 |
waspinator |
yes, it has a primary key. it works most of the time, but not for a case where the ids are the same. For example, adding the same user to a user group but with different roles ``` object(ArrayObject) { name => 'test' users => [ (int) 0 => [ 'id' => (int) 2, '_joinData' => [ 'role' => 'student' ] ], (int) 1 => [ 'id' => (int) 2, '_joinData' => [ 'role' => 'teacher' ] ] ] } ``` |
# |
May 15th 2019, 12:36 |
admad |
does your join table have primary key? |
# |
May 15th 2019, 12:35 |
admad |
`through` config is only for association setup, not patchEntity() |
# |
May 15th 2019, 12:34 |
slackebot |
$this->belongsToMany('Students', [ 'through' => 'CoursesMemberships', ]); } } class CoursesMembershipsTable extends Table { public function initialize(array $config) { $this->belongsTo('Students'); $this->belongsTo('Courses'); } } ``` |
# |
May 15th 2019, 12:34 |
waspinator |
@admad so that would be in the `through` table or as the third parameter of `patchEntity()`? I pretty much have this table setup ``` class StudentsTable extends Table { public function initialize(array $config) { $this->belongsToMany('Courses', [ 'through' => 'CoursesMemberships', ]); } } class CoursesTable extends Table { public function initialize(array $config) { |
# |
May 15th 2019, 12:30 |
admad |
@waspinator you would configure it in the association config |
# |
May 15th 2019, 12:29 |
spriz |
Besides that, last time we had issues with routes and plugins we had missed something when doing https://book.cakephp.org/3.0/en/development/application.html#adding-the-new-http-stack-to-an-existing-application, and moved some things around between `webroot/index.php`, `config/bootstrap.php` and `src/Application` so maybe double check that list @dereuromark:slightly_smiling_face: |
# |
May 15th 2019, 12:29 |
waspinator |
it works fine otherwise. just not when two items have the same ids |
# |
May 15th 2019, 12:28 |
waspinator |
I have a through model, not sure what I need to configure for this specific case though. |
# |
May 15th 2019, 12:28 |
admad |
@waspinator have you configured the `through` model? |
# |
May 15th 2019, 12:24 |
waspinator |
how would I make `patchEntity` take `_joinData` into considerations when processing `belongsToMany` data? I want to add two relationships with the same `foreignKey` and `targetForeignKey`, but with different `_joinData`. In `beforeMarshal` I can see both items, but in `beforeSave` only the first one is there. |
# |
May 15th 2019, 12:21 |
spriz |
We resolved some issue with no routes in our test, but I see now that we solved it by moving to Routes middleware :S |
# |
May 15th 2019, 12:15 |
admad |
I have subscribed to that issue :( |
# |
May 15th 2019, 12:14 |
spriz |
and `<phpunit colors="true" bootstrap="./tests/bootstrap.php">` in your `phpunit.xml`? |
# |
May 15th 2019, 12:14 |
spriz |
You do have a `require $root . '/config/bootstrap.php';` in your `plugins/PluginName/tests/bootstrap.php` @dereuromark? |
# |
May 15th 2019, 12:13 |
spriz |
Done :slightly_smiling_face: https://github.com/rectorphp/rector/issues/1431 |
# |
May 15th 2019, 12:08 |
dereuromark |
that one contains the RoutingMiddleware, but I am not sure how to invoke this fake Application.php class in TestApp/App namespace |
# |
May 15th 2019, 12:08 |
admad |
@spriz i would definitely open an issue in that case |
# |
May 15th 2019, 12:08 |
dereuromark |
Application in test_files is also not loaded right now. |
# |
May 15th 2019, 12:07 |
spriz |
Ah, so not in terms of how do you make the integration test cases pick up the routes @dereuromark? :P |
# |
May 15th 2019, 12:06 |
spriz |
not only in dry-run :) |