Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
filter.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
28 Jun 2013 at 14:39 UTC
Updated:
22 Dec 2014 at 23:56 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jlindsey15 commentedThis is my first contribution to Drupal - gotta start somewhere!
Comment #2
jlindsey15 commentedThis isn't complete yet (only added one getter method), but since this is my first time here I just want to go through the patching process to make sure I can do it. More to come later...
Comment #4
jlindsey15 commentedComment #5
jlindsey15 commentedComment #6
jlindsey15 commentedAs stated before, the last patch isn't complete.
Comment #7
jlindsey15 commentedOkay it should be done (hopefully). Pretend those first two patches don't even exist... I had no idea what I was doing for a little bit :)
Comment #9
jlindsey15 commentedOops, some weird typos in the last one.
Comment #10
berdirlet's name this isCacheable().
Then you can just leave out the Returns part and just have "Whether ..." and the @return should say something like Returns TRUE if ...
The first line shouldn't be longer than 80 characters, so the explanation sentence should be on the next line, like this:
Returns the formats filter bag.
The filter bag holds the ... .
That looks incomplete ;)
variables in methods usually still use $new_weight, I also think just $weight is enough.
Looks like you have a tab instead of spaces here.
Comment #11
ivan zugec commentedRerolling patch from #9 so it works with HEAD.
The next patch will have the changes from #10.
Comment #12
kgoel commentedchanging status
Comment #13
ivan zugec commentedAttached patch implements changes mentioned in #10. I also created a test class, copied from the "FilterCrudTest" class, for the methods.
I removed the "get/setFilterBag" method because it looks like the filter_bag is handled within the filters() method.
Comment #14
ivan zugec commentedQuick question, should patches for #2016679: Expand Entity Type interfaces to provide methods, protect the properties have tests?
It looks like some do and some don't.
For example, the following patches do not have tests:
- #2015123: Expand NodeInterface to provide getters and setters
- #2026347: Adding methods to UserInterface/AccountInterface
And the following do have patches:
- #1983548: Convert contact message entities to the new Entity Field API
- #1818568: Convert files to the new Entity Field API
Anyhow, the #13 patch does have a test class. I simply copied the existing "FilterCrudTest" class and created a new class called "FilterFormatMethodsTest".
Also, the "FilterFormatMethodsTest" test class needs to be updated to follow the latest testing coding standards:
- Test methods should be public.
- And, the @file declaration needs to be updated.
Check out https://drupal.org/node/325974 for more details.
Comment #15
ivan zugec commentedComment #16
daffie commented@Ivan Zugec: I think that a lot/all of underlying postponing problems are solved. Are you still willing to work on this issue?
Comment #17
daffie commented13: FilterFormat_methods-2030641-13.patch queued for re-testing.
Comment #18
linl commentedPatch no longer applies, tagging for reroll.
Comment #19
lahoosascoots commentedRerolled.
Comment #21
lahoosascoots commentedAh, the deleted file got renamed. Added in the missing required functions.
Comment #22
lahoosascoots commentedComment #23
daffie commentedComment #24
berdirThis should be Contains \Drupal\...
DrupalUnitTestBase is now KernelTestBase.
getInfo() no longer exists, instead add @group on the class docblock, remove everything else.
This should have an @inheritdoc
This is now return $this, without description.
Cache stuff no longer exists.
Comment #25
pushpinderchauhan commentedPlease review updated patch with fixed points as @Berdir suggested in #24.
Comment #26
calebtr commentedPatch in #25 no longer applies. I will attempt a re-roll.
Comment #27
calebtr commentedI followed the re-roll instructions at https://www.drupal.org/patch/reroll. I got no conflicts and an automatic 3-way merge.
Comment #28
calebtr commentedComment #29
calebtr commentedI moved core/modules/filter/lib/Drupal/filter/Tests/FilterFormatMethodsTest.php to core/modules/filter/src/Tests/FilterFormatMethodsTest.php where the other tests live .
I also added some blank lines and made other small changes per the coding standards for files at per https://www.drupal.org/coding-standards/docs#file and for tests per https://www.drupal.org/node/325974.
Comment #31
calebtr commentedThe failed test calls a property that was renamed with https://www.drupal.org/node/1533250.I'm wee baffled as to why it didn't break anything before now.
I'll fix the test and give it another try.Edit: I was wrong about where the $timestamp_now property got changed because it is still there in Drupal\locale\Tests\LocaleUpdateBase. So my next tack is to see if
use Drupal\locale\Tests\LocaleUpdateBasewill help.Comment #32
calebtr commentedAha, I see now that
$this->timestamp_nowit is set in Drupal\locale\Tests\LocaleUpdateBase::setUp() but not actually defined anywhere, which is where patch #29, above, fails.But if it is defined, it needs to be defined as $timestampNow per the naming conventions at https://www.drupal.org/node/608152, and I can grep to find where else it needs to be changed.
Alternatively, since this is set to REQUEST_TIME in Drupal\locale\Tests\LocaleUpdateBase::setUp(), do we even need it? Why not just use the REQUEST_TIME constant in Drupal\locale\Tests\LocaleUpdateTest::testUpdateImportSourceRemote() (where the test failed)?
If we do need it, I think if it will be helpful to rename the property to $timestampRequestTime to avoid visual confusion between $timestampNow and $timestampNew.
Can we resolve this here, or is this a good case for a new issue?
Comment #33
calebtr commentedI spoke with YesCT in-person about the failed test. We agreed we should figure out what was making the test fail before making any new issues or changing anything else.
I ran LocaleUpdateTest on a local installed site and it passed against 8.0.x and my branch with this patch.
I am re-queing the patch for testing.
Comment #35
calebtr commentedOkay, #29 passed the second time around, but I found one more test that called ->get() and ->set().
In summary:
I also double-checked that the patch still applies on an up-to-date 8.0.x branch.
Comment #37
calebtr commentedHere is a fix for the PHP error in #35.
Comment #38
yesct commentedjust noting the interdiff to help with review.
Comment #39
yesct commented1.
No properties are being protected. We need to do that to be able to find the direct accesses of the properties in core and have them use the methods (and we can then tell ... maybe we wont need a method).
2.
why is this doing the set() instead of just access the property directly (it can, cause it is the class itself)
Comment #40
calebtr commentedI saw this comment in the 'Extend Block with methods()' issue I was working on - https://www.drupal.org/node/2030571#comment-7607017 - this explains why the properties are left as public.
Thoughts?
Comment #41
yesct commentedYeah, that was a long time ago. And we have tightened up our approach since then.
We should still make them protected.
Comment #42
calebtr commentedDrupal\Core\Config\Entity\ConfigEntityBase::set() does more than just set the value:
My assumption is that instanceof EntityWithPluginCollectionInterface is going to evaluate true here because
class FilterFormat extends ConfigEntityBase implements FilterFormatInterface, EntityWithPluginCollectionInterface, so we should keep using ->set().I protected the properties. The $format and $name properties have @todo labels indicating the properties need to be renamed to $id and $label respectively. I didn't do that, but I did add the getters and setters with the assumption that these properties will be renamed (ie setId(), setLabel(), getLabel()).
I searched to see if there was an issue related to renaming the properties but didn't find one. I'm not sure of the relationship between @todo and issues. The todos should be trivial to implement once the properties have been protected. I did see the comments in the parent issue (#18 and #53) regarding that $id can be a protected.
I expect this will get back to Needs Work, but lets see what the tests say anyway.
Comment #44
calebtr commentedResolving this PHP error and one more.
Comment #45
calebtr commentedAnd here is where I remember to change the status to Needs review.
Comment #47
calebtr commentedOk yeah so it looks like we don't want to protect $format after all. Whoops. I'll keep working on this.
Comment #48
calebtr commentedMaking $format a public property again.
Comment #49
calebtr commented...and setting to Needs Review again
Comment #51
calebtr commentedFixing PHP warning.
I think this will pass.
There's still two points that I see that need clarifying:
1: whether setters need to call set() or not. I think yes, but I think the counter-argument is that if we set properties directly and no tests fail then it is fine.
2: $name property is to be renamed $label, so it is affected by getLabel() and setLabel(); similarly $format property is to be renamed $id, so is affected by id() and setId().
Summary of what this patch does:
Comment #52
calebtr commentedneeds reroll.
Comment #53
calebtr commentedWrong issue.
Comment #54
calebtr commentedI'm changing all the setters per YesCT's advice.
I changed FilterFormat::name to FilterFormat::label.
Comment #56
calebtr commentedCompleting change of $name property to $label.
Comment #58
calebtr commentedUsed the wrong method in last patch.
Comment #60
calebtr commentedI found a bunch more places where label() needed to be getLabel().
Comment #62
calebtr commentedNew approach, undoing changes #60. I'm also including an interdiff from 58 because I think it will be more helpful.
Comment #64
calebtr commentedRenaming $name to $label may be beyond the scope of the issue, but in case it is not, here is another try.
Comment #66
calebtr commentedswitching all of the times I added getLabel() back to label(). This is a replacement for accessing $name directly.
Comment #68
yesct commentedyeah... why renaming name to label?
we should just be making it protected.
the @todo's to do the renaming sound like separate issues to me.
and what is the deal with the format property?
Comment #69
yesct commentedI suspect that the setId() is only used in tests and we can and should get rid of it and instead change the tests to create new things with different ids. same with setLabel. (changing the tests can be a separate issue if that is helpul)
Comment #70
calebtr commentedOk, going back to #37 (51 failed tests on re-roll) and changing only:
- setters set properties directly instead of using ->set
- a bunch of places and tests where $weight should be getWeight
For now I let $format and $name public so setLabel(0 and setId() are dropped.
I'm unable to get an interdiff here.
Comment #72
calebtr commentedUndoing changes to FilterPluginCollection.php - this extends a different class entirely.
Comment #74
berdirSee the property documentation. There is no point in having setters and getters for this, the only use case is for initial default configuration. So I think this should not exist.
This property/concept no longer exists and the methods should be removed.
The roles tests can stay as they are, with set/get.
I'm not sure about those two. I didn't read the discussion above.
Making it protected might still be a good idea. You can still use set()/get() or you can pass it as part of the $values array in entity_create().
Kernel tests are not as fast as unit tests. I'm not sure if we should write them as unit tests and have every method separate. Maybe a single test method would make more sense.
Comment #75
yesct commentedI'm confused about #74 3.
I think the tests should be re-written to respect the protectedness of the property.
Comment #76
yesct commentedyeah, the cached property was removed in #2217877: Text filters should be able to add #attached, #post_render_cache, and cache tags
it might be worth just making the properties protected and seeing what fails, and just fixing those fails.
Comment #77
daffie commentedComment #78
mile23Patch does not apply.
Comment #79
yesct commenteddone by #2384487-47: Make the class variables protected for FilterFormat
Comment #80
mile23