# |
Aug 15th 2019, 09:58 |
slackebot |
<challgren> |
# |
Aug 15th 2019, 09:55 |
slackebot |
<neon1024> |
# |
Aug 15th 2019, 09:54 |
challgren |
cake 2.x?? |
# |
Aug 15th 2019, 09:15 |
neothermic |
(in cake2) |
# |
Aug 15th 2019, 09:15 |
neothermic |
is there any way to get Cakelog::write to not echo to stdout when running unit tests? |
# |
Aug 15th 2019, 09:14 |
lubos |
@admad found the reason, when you do `formatResults` with finder on associated model (e.g. Offers) it sets `offer` property as dirty even when no change is done to `$results` so later on when I tried to save it was trying to save `offer` property which I did not expect :slightly_smiling_face: |
# |
Aug 15th 2019, 09:09 |
neon1024 |
Ah, I knew if I asked, I’d find it right away! https://github.com/dereuromark/cakephp-hashid |
# |
Aug 15th 2019, 09:09 |
neon1024 |
Anyone know where dereuromark’s plugin is which adds an obfuscation slug layer |
# |
Aug 15th 2019, 09:04 |
jotpe |
https://book.cakephp.org/authorization/1.1/en/checking-authorization.html -> there it's checked with the entity `$user->can('delete', $article)` |
# |
Aug 15th 2019, 09:03 |
jotpe |
In fact i want to enable an admin user to access all actions in a controller. But in an index action i don't have an entity |
# |
Aug 15th 2019, 09:02 |
jotpe |
How do i check the authorization for a index action in Authroization Plugin? |
# |
Aug 15th 2019, 08:41 |
spriz |
not afaik |
# |
Aug 15th 2019, 08:39 |
hmic |
oh, ah, does crud and crudview implement it on their own? |
# |
Aug 15th 2019, 08:38 |
hmic |
yeah, this paginator could use some serious love... |
# |
Aug 15th 2019, 08:38 |
hmic |
I need to report the total number back, it's API usage |
# |
Aug 15th 2019, 08:32 |
spriz |
the consumer just keeps doing `+1` to the `page` param, until a 404 is returned :) |
# |
Aug 15th 2019, 08:31 |
spriz |
we do that for heavy queries |
# |
Aug 15th 2019, 08:31 |
spriz |
or skip them :) |
# |
Aug 15th 2019, 08:31 |
spriz |
I made custom paginators a few time - it's not too much of a hassle :slightly_smiling_face: |
# |
Aug 15th 2019, 08:31 |
admad |
if those lines were rejigged a bit and the fetching of count was moved into separate method once could override that method and return count as per their custom needs |
# |
Aug 15th 2019, 08:29 |
admad |
https://github.com/cakephp/cakephp/blob/master/src/Datasource/Paginator.php#L185-L188 |
# |
Aug 15th 2019, 08:29 |
hmic |
yep, i figured that :p :( |
# |
Aug 15th 2019, 08:27 |
admad |
okay. currently `Paginator` just clones the primary query and does a `count()` on in instead of `all()` and everything is inside `Paginator::paginate()` so not very flexible |
# |
Aug 15th 2019, 08:23 |
hmic |
filter all of them, of course. so the paginator calling ->count() can't be done on the query but the resulting collection only. i am aware of the imact of it. I am just looking for a place to add/configure it to work *at all( |
# |
Aug 15th 2019, 08:21 |
admad |
i really don't see a solution to the problem.. how can you find out even the correct total count since the filtering of records would be done per page |
# |
Aug 15th 2019, 08:18 |
hmic |
I am not able to get all the data this virtual field contains in the query/db, it represents external shit. |
# |
Aug 15th 2019, 08:17 |
admad |
trying to get proper count after query is done would be PITA |
# |
Aug 15th 2019, 08:17 |
admad |
hmic: i believe the best way would be do the filtering in query itself |
# |
Aug 15th 2019, 08:13 |
hmic |
I looked into mapReduce but can't figure that (and if it would solve the paginator count issue) |
# |
Aug 15th 2019, 08:12 |
hmic |
general question: how to filter results on a virtual field (and get correct counts from the paginator)? |
# |
Aug 15th 2019, 08:11 |
hmic |
any ideas? |
# |
Aug 15th 2019, 08:11 |
hmic |
I do understand the reason behind it and am looking for another solution now. |
# |
Aug 15th 2019, 08:10 |
hmic |
*but* there is a catch on this: the paginator count is wrong |
# |
Aug 15th 2019, 08:10 |
hmic |
I could manage to filter the data by utilizing formatResults and returning a new collection with the elements I don't want removed |
# |
Aug 15th 2019, 08:09 |
hmic |
Hi, I am facing a problem with a query: I am using virtual fields and I need to filter my result by a virtual field now |
# |
Aug 15th 2019, 07:32 |
lubos |
it is too long, but only when i trying to save data which were previously formated via `formatResults` :slightly_smiling_face: |
# |
Aug 15th 2019, 07:28 |
admad |
if the db says data is too long for 255 chars than it must be |
# |
Aug 15th 2019, 07:27 |
lubos |
hmm, too difficult to explain, however the `formatResutls` is doing something odd :slightly_smiling_face: |
# |
Aug 15th 2019, 07:27 |
lubos |
sorry, my bad. when later on i try to save order entity, it throws DB error when I used `formatResults` with related `offer` property. When i skip the `formatResutls` with that `findDiscount` method, all OK |
# |
Aug 15th 2019, 07:10 |
admad |
why would a find operation try to save anything? |
# |
Aug 15th 2019, 07:05 |
slackebot |
findDiscount(Query $query, array $options) { $query ->formatResults(function ($results) ... ``` When I use this `formatResults` in the finder ORM is trying to save `offer` as json object which throws error (offer field varchar 255 exists in the orders table) |