Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It's really hacky and we should fix it.
Comment | File | Size | Author |
---|---|---|---|
#44 | interdiff-1792836-44.txt | 618 bytes | damiankloip |
#44 | 1792836-44.patch | 19.52 KB | damiankloip |
#35 | 1792836-35.patch | 19.48 KB | damiankloip |
#22 | merge-1792836-22.patch | 15.58 KB | alansaviolobo |
#16 | 1792836-16.patch | 20.62 KB | damiankloip |
Comments
Comment #1
dawehnerIf we make the handler mandatory i think it would make sense to remove the static from it, as it will always alter the handler object.
Comment #2
aspilicious CreditAttribution: aspilicious commentedMy initial thought was to create an empty handler implementation. (a dummy class)
Comment #3
xjmComment #4
Kars-T CreditAttribution: Kars-T commentedI am working on it.
Comment #5
Kars-T CreditAttribution: Kars-T commentedWhat we did talk about at the vdc sprint is that:
1. Merge breakPhrase() and breakPhraseString()
2. Just return an array with array('values' => array(), 'operator' => 'and');
So I am renaming the issue.
Comment #6
Kars-T CreditAttribution: Kars-T commentedsudo drush-git si standard --db-url=mysql://d8:d8@localhost/d8 --site-name="D8 Test Site"
This is a first version. But I can't test it locally because of some problems with my virtualbox. Please tell me if this is going into the right direction.
Some comments about why I did the patch in this way.
Comment #7
dawehnerMaybe it make sense to cast the value to a integer, so we don't end up stopping if we have a single string in there.
empty is already a boolean so we just could use $force_int = !empty($this->definition['numeric']);
We should certainly use $break_phrase instead of $breakPhrase or even list($value, $operator);
Comment #8
Kars-T CreditAttribution: Kars-T commentedUpdated version with your suggestions. And I found more uses of breakPhrase() and fixed them. Please review.
Comment #10
Kars-T CreditAttribution: Kars-T commented#8: drupal-1792836-breakPhrase-v02.patch queued for re-testing.
Comment #12
damiankloip CreditAttribution: damiankloip commentedLet's try and revive this issue :)
I have made quite a few changes here:
So, I'm not sure what behaviour we want when $enforce_int is true, at the moment it gets casted, so a string will become 0 instead. The tests had NULL being returned instead of any values before. Ideas?
Comment #14
damiankloip CreditAttribution: damiankloip commentedThis one might pass.
I'm not sure about using extract().
Comment #15
dawehnerWouldn't it be easier if we call $value $nids/$tids, so it's clear what actually is going on here?
Another comment: Couldn't we use get_class($this->argument)::breakPhrase here?
Any using not to rename it to "string"?
What about array_map('intval', $return['value'])?
For two variables I see no reason in using extract? I think list() is at least way easier to read.
Comment #16
damiankloip CreditAttribution: damiankloip commentedOk, made most of those changes and switched back to list, I guess it's slightly less evil...
Not sure about the first comment. $this->argument should be a string now?
Comment #17
damiankloip CreditAttribution: damiankloip commentedOh, hang on. That part in Node.php argument validator is wrong anyway. It's passing the argument into the breakPhrase, this should be just passing in $argument and not $this->argument I think. We should try and change this to your suggestion of using get_class too.
Comment #18
Kars-T CreditAttribution: Kars-T commentedThe test results are strage.
This is the test in line 142 with "cast to int". So why is it still "0,1" and not an int? PHP Type Juggling?
The tests should get some messages so we can be sure what the result should be.
As you still do " $value = preg_split('/[+ ]/', $str);" I believe the help text should change to reflect that spaces can be used as "or". The string "If selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND)." is used in three different places. Is there any chance that this can be put and used from the HandlerBase object?
Comment #19
dawehner#16: 1792836-16.patch queued for re-testing.
Comment #21
dawehnerAdd tag
Comment #22
alansaviolobo CreditAttribution: alansaviolobo commentedre-rolled the patch
Comment #24
alansaviolobo CreditAttribution: alansaviolobo commentedmade some changes to the HandlerBase class and test. needs review.
Comment #26
damiankloip CreditAttribution: damiankloip commentedDo you have an interdiff of the changes?
Comment #27
alansaviolobo CreditAttribution: alansaviolobo commentedlet me get the patch to pass the SimpleTests. I will then upload an interdiff.
Comment #28
alansaviolobo CreditAttribution: alansaviolobo commentedI am having difficulty getting this patch to pass the tests. The problem seems to be with the regex to detect whether the operation is AND or OR. It fails on parameters like 'word1', 'wõrd1' etc.
Comment #29
damiankloip CreditAttribution: damiankloip commentedThanks for your work picking this back up!
Here is a quick bit of work on here. Converted the usage of breakString() from using list(), as this method now returns a stdClass object.
Also, I don't think we need to try and hardcode specific characters like this if we are using the u flag in the regex
/^([\X{00C0}-\x{01FF}\w\-\d]+[+ ]+)+[\X{00C0}-\X{01FF}\w\-\d]+$/u
. I think just unicode mode will suffice?Comment #31
damiankloip CreditAttribution: damiankloip commentedWe don't want to filter out 0 values from out breaking of strings.
Comment #32
damiankloip CreditAttribution: damiankloip commented31: 1792836-31.patch queued for re-testing.
Comment #33
dawehnerI do love
meh, if we would just have proper support in the language.
Comment #34
alexpottThe phrase "Works for strings" is now unneeded.
You are not really forcing a numeric check - you are forcing all values to have intval() run on them. Which is interesting - just do
php -r "print intval('0452rtrtw');"
Nope it does not return a handler anymore.
Seems a shame not to encapsulate this functionality on a protected method on HandlerBase
Not proper formatting.
Comment #35
damiankloip CreditAttribution: damiankloip commentedHow about this? I have added a method to arguments, as we really only unpack things like that there. Better names for that method welcome!
Comment #36
alexpottMissing param
Comment #38
damiankloip CreditAttribution: damiankloip commentedWhich param?
Comment #41
damiankloip CreditAttribution: damiankloip commentedDuh. Yes I see the issue :) rerolling...
Comment #42
damiankloip CreditAttribution: damiankloip commentedComment #44
damiankloip CreditAttribution: damiankloip commentedrandomName > randomMachineName
Comment #45
dawehnerYeah we could indeed think about using that functionality in other places in core. One other example could be RoleAccessCheck and so on and forth.
Comment #46
alexpottCommitted 0946b70 and pushed to 8.0.x. Thanks!