Closed (fixed)
Project:
Context
Version:
8.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
28 Feb 2018 at 19:09 UTC
Updated:
11 Jun 2021 at 17:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
pobster commentedSo I gave it a go ... but TBH ... it doesn't work properly due to "Fatal error: Maximum execution time of 30 seconds exceeded..." but I feel though it's a good start? I was hoping for a pointer or two and I'll (or anyone) can finish it off (and the "Context (all)" will be similar enough I'm sure).
Comment #3
perkeWould love to see this moving forward.... can't provide code but will happily test and provide feedback
Comment #4
Kaz de Groot commentedThis probably requires some changes in the main context system, as this patch currently creates an infinite loop.
Basically, on evaluate, activeContexts is fired, which runs evaluate for all conditions on all contexts, and thus will fire the evaluate on the Context (any) condition, which will then fire activeContexts, etc.
Based on the description, some technique should be employed that would only run the Context (all) check after all the other conditions have fired; but I don't think there is mechanism for that currently. Another way would be to duplicate the context triggering logic within the plugin, but that would be hard to maintain.
Comment #5
etroid commentedA first stab at making this work. Similarly to the D7 version, we'll have to evaluate the contexts directly as they are being referenced in the `context_any` plugin.
Comment #6
etroid commentedComment #7
etroid commentedFixed some code style issues
Comment #8
etroid commentedComment #9
etroid commentedAlso include context (all) condition plugin this time.
Comment #10
etroid commentedComment #11
etroid commentedFixed an issue with duplicate plugin id
Comment #12
etroid commentedIncluded cache context support.
Comment #13
etroid commentedComment #14
etroid commentedFixed an issue around negated contexts. These conditions probably need some testing
Comment #15
strozx commentedI tested with different conditions and reactions and it look like it works
Comment #16
ilgnerfagundes commentedHi guys, I was unable to apply the patch. You may have to update
Comment #17
paulocsPatch needs re-roll
Comment #18
deaom commentedI re-rolled the patch, but the asterisk (*) is not working (fatal error is thrown because null is returned), so I'm currently debugging why as it seems this was also not working in the D7 version.
Comment #20
deaom commentedI created a new fork as it's more manageable and pushed the re-rolled patch with the asterisks/wildcard handling. Needs additional testing.
If necessary I can also upload the .patch file. Setting to needs review.
Comment #21
paulocsHi @DeaOm,
I was testing it and I found a bug.
Steps to reproduce:
1) Create a context that will add a block if the current page is the front page.
2) Create a second context with "Context (any)" condition, add the context created in step 1 and add a page title reaction.
3) Save it and see the error below:
Comment #22
deaom commentedHi @paulocs, I could reproduce your bug. I pushed changes for that bug/issue to the MR, so setting status to needs review.
Comment #23
paulocsI found another error when adding a context id that does not exist.
The site totally crashes if I write a wrong context id and I'm not even able to edit the context and fix it.
I tested it with
Context (any).Comment #24
deaom commentedAdded the updated code to context any and all condition. Not sure how to actually handle the wrong name, as the code will work, but the user will have no idea that the entered context name is wrong. Here is kinda assumed you know what you are doing, so the complete crash of the page of course is not correct, but maybe some kind of a warning could be displayed? For when user mistypes or something. Setting it to needs review and we'll see from there.
Comment #25
larisse commentedI tested and the re-rrol works. But when I adding a context that not exist, it's save normally. I tested in Drupal 7 to see how this case works there and I see that when adding a context that not exists, it's save normally too.
Comment #26
paulocsThanks!
It looks good to me as well.
I'll commit and add it to the next release.
Comment #28
paulocs