Closed (fixed)
Project:
User Points
Version:
7.x-2.x-dev
Component:
Code: userpoints
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
23 Aug 2011 at 23:00 UTC
Updated:
15 Mar 2013 at 20:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
BenK commentedSubscribing
Comment #2
berdirThinking about it, it's actually more like that having a field for the userpoints total ( and having the possibility for multiple fields) + the ability to categorize using a referenced taxonomy term reference replaces the current categorization feature and not transaction bundles.
So me might want to split this one up as well and first through out the current categorization stuff (assigning myself as I've started with this already) and later worry about how to embed bundles.
Comment #3
moonray commentedEDIT: scrap this, seems 7.x-2.x already takes care of my issue.
Comment #4
mradcliffeBranched #1870674: Categorization with default taxonomy term reference field and views for categorization per #2.
Comment #5
mradcliffeHere's an initial patch ignoring rules and services sub-modules.
Comment #7
mradcliffeThis should fix mosts of the tests except the rules one.
Not sure why field ui is changing its behavior. I think it's because of all the nested local tasks that are provided by Entity API.
Comment #9
berdirLooks good.
I think we should add a default type during installation and call that default or something like that. My goal for 7.x-2.x is to make sure that the module still works out of the box for the default use case.
Also, we need one for upgrading from 7.x-1.x anyway, and we could use rely on it in the tests as well (although we shouldn't anywhere else).
The upgrade path is going to be non-trivial with all these changes, so we should add some test coverage for that at some point, doesn't need to happen here though, upgrade tests are tricky...
Can we also add a redirect here if there is just one type, similar to how node/add works?
Should be CheckS, LoadS and so on. (The existing code is probably most wrong too, all we can do is make new code as good as possible :))
Should be @return bool.
Comment #10
mradcliffeYes, that all makes sense.
Comment #11
berdirHm, that comment doesn't seem to make sense? $txn in this case is actually a user id.
This stuff is a mess, we might want to use a separate argument for user and transaction. But that will probably require a few changes, so possibly a follow up. But I think that your changes here are not correct (also those below)
What still should work is going to userpoints/add/$uid and have the user pre-filled..
There is a problem with this change.
We have a API function with a required argument for something that is configured through the UI , can be deleted and so on. This means that nobody can actually use this function without having the user to present a configuration form for this.
I'm thinking that we should have a default type (maybe even prevent to delete that) and then default to that if it's not set.
We can still change later but it would make this patch and the transition to bundles easier/smaller.
Comment #12
mradcliffeAlso, bundle paths not changed in admin.inc, and something else that was bothering me enough to wake up early and then forget.
Comment #13
mradcliffeI'm still working on things, but I am not sure what to do about
> What still should work is going to userpoints/add/$uid and have the user pre-filled..
The thing I usually do is make the entity form a multi-step form that requires a bundle to be selected first (or default bundle used). I don't know if this fits the ease-of-use of having $uid or other things filled in.
Comment #14
mradcliffeHere's an approach with a multistep form. I am not sure if you want to depend on ctools or not so this is the old-school multistep.
Comment #16
mradcliffeThat's a lot of fails. I was afraid of instantiating an entity and calling a save method on it during install, but I was wrong.
Comment #17
mradcliffeWorking on this again. Not many changes.
I'm not sure if there is anything left to do on this task other than an UpdatePathTestCase. This allows for bundles, but doesn't do anything with them as that's what the other tasks may be for (including migration of points category to bundle or points category to taxonomy term field).
Comment #18
berdirYes, it's time to get this in. Will do a manual test and test the upgrade path asap.
Upgrade path tests would be valuable but it's quite some work to set it up. Not a blocker to get this in but I would like t have some before 7.x-2.x can become stable. Can you open a critical task to add (basic) upgrade path test coverage?
Some feedback on the update function:
The version number should be 7200.
This is not a reliable thing to do, you need to copy the definition.
Imagine that a later update would add another column and we'd add a second update function to add it accordingly. This one would then however already get the latest one which would result in conflicts.
Similarly, it is not reliable to use entity API functions. Entity API always works with the latest schema defined in hook_schema() and would try to write to columns that might not exist yet. Needs to be a manual db_insert() query.
Should look like this:
Comment #19
mradcliffeOkay, thanks for the feedback. I switched to creating the bundle with entity api from patch 5 due to the number of fails. I'll try again.
Comment #20
berdirYes, that's fine for hook_install() but update functions are a very tricky business...
Comment #21
mradcliffeI had to use entity_info_cache_clear() during the update to get the updated schema. This could be the case if someone updates code and runs the update immediately. Interdiff shows an extra commit with me futzing around with that.
Comment #23
mradcliffeOops, dyslexic/reversed diff.
Comment #24
berdirvariable_del() doesn't have a second argument.
Will do some manual testing later, would like to know why exactly that cache clear is necessary (not saying it's wrong, just want to understand it) and to test the adjusted user interfaces.
Comment #25
berdirThis can be simplified a bit, you can directly pass the array you pass to values to fields, doing this separately is only useful if you have multiple rows to insert.
I don't think we need this at all. There are almost no core update functions that return something and we already described what the update function does in the docblock. I think it's only useful to return something if it's relevant to the user, e.g. he might need to do something.
Also, $updated is never set.
I tried it out manually and got some errors when trying to run the update. We might have to add a try/catch to the entity_info_alter () hook in case caches are cleared before the update is run. Also not sure if the entity cache clear in the update function isn't actually counter-productive, as it then seems to try to rebuild that information before the schema cache is cleared.
And, I noticed that after a cache clear, the default bundle is gone, which is because you used the 0x02 status, which means "ENTITY_IN_CODE" and that again means that entity.module will automatically delete it if it is not in code, as it assumed that it has been removed. 0x01 is the correct status to use. Maybe that's what was "breaking" it? Because I had that effect immediately when removing the cache clear at the top.
Edit: Reworded the 4 "And, "'s that was weird ;)
Comment #26
mradcliffeI think an update test case would help now even though I already created that other issue for it. :-)
I added a basic one that uses drupal7.bare.standard and a few various values (just for the userpoints tables, but need to also insert into vocabulary, terms, etc...).
I'm attaching another patch, but it contains no differences from the last one except the basic update path test case and wimpy userpoints.filled.database.php. Going to set this right back to needs work after it kicks off some tests.
Comment #27
mradcliffeBack to needs work.
Comment #28
berdirOh, that's actually quite a nice way to do it. Nice work.
Yes, having basic coverage here already is great. We can always extend it with more data as we need it to add coverage for bugs as we discover them.
Comment #29
mradcliffeI thought it was quite clever until I realized that entity isn't enabled. I think I need to insert entity info cache.
Comment #30
berdirLooks like the filename doesn't match.
Also, this should be moved into a tests subfolder.
Comment #31
mradcliffeYeah, oops, I added the wrong file into git.
I figured out what was going on thanks to some code from update.botcha.test. The registry is getting munged and needs to be rebuilt in the test.
I created two test case classes. One that is using a full db dump, and then the first approach I used in #26. So there are two database dumps added in this patch making it quite large. The interdiff would look pretty crazy so I'm dropping that.
Comment #32
berdiryeah, and that unfortunately results in having those large dumps in the release people download. It can be gzipped, though, to make it smaller.
Comment #34
mradcliffe#31: 1258026-implement-userpoints-bundles-11.patch queued for re-testing.
Comment #35
berdirInstead of default, we could also use initial here, which does not set the schema definition default to that but only sets the value of all existing records to that.
The default shouldn't be hardcoded I think, that's what the variable is for.
The upgrade path looks great now otherwise, clean and no more black magic cache clears :)
Can you re-roll for initial and with a gzipped version of the all dump? Did a quick test and that gets the size down from 530kb to only 50kb. You can use the --binary option for git diff to make a patch with that.
No need to do that for the other dump as we want to be able to make manual changes there and get a useful diff.
Comment #36
mradcliffeOh, cool. I learned something new today about initial. :-)
New patch. I think we can decide what database dump to use in #1922788: Implement UpdatePathTestCase for userpoints 7.x-2.x changes (bundles, fields, etc...). The current mini dump is going to need work when testing taxonomy and users, but that's work for a bit later.
Comment #37
mradcliffeThat's not going to work if I don't change the test, duh.
Comment #39
mradcliffeFix that silly mistake.
Comment #40
berdirGetting the following notices on the transaction type add form, fixed it by defining the properties on the entity class.
UserpointsTransactionType::$label in userpoints_transaction_type_form() (line 961 of sites/all/modules/userpoints/userpoints.admin.inc).
Notice: Undefined property: UserpointsTransactionType::$name in userpoints_transaction_type_form() (line 972 of sites/all/modules/userpoints/userpoints.admin.inc).
Commited to 7.x-2.x, thanks for working on this!
Comment #41
mradcliffeWhat's a good heirarchy / child page to add to for starting documentation on 7.x-2.x?
Comment #42
berdirDeveloper or user documentation?
User documentation can just be added somewhere below here: http://drupal.org/documentation/modules/userpoints
I prefer to have API/developer documentation in code, then I can parse it with api.module and display on http://api.worldempire.ch/api/userpoints