I am using Bugzilla 3.6.3. I would like to reset the vote count for a bug back to zero if the status is changed to UNCONFIRMED. What perl file and method do I do this in and how would I do this?
There are a couple of different ways to do this, both involving hooks:
http://www.bugzilla.org/docs/3.6/en/html/api/Bugzilla/Extension.html
There are examples of how to use the hooks in extensions/Example/Extension.pm.
The way I would do this would be to use the bug_end_of_update hook.
There's code in extensions/Example/Extension.pm that is almost exactly what you want. If one of the changes is to bug_status and the new value is UNCONFIRMED, then directly manipulate the database to reset the number of votes to 0, i.e. DELETE FROM bugs WHERE bug_id = ?
The other way to do this would be to use object_end_of_update, which is basically the same as bug_end_of_update, but you'd have to check that the object is a Bugzilla::Bug.
Related
I know this question has been asked time and time again but I seem to be running into the same issue as others. I am attempting to add/remove textareas, but when using splice, I seem only to be removing the last element added regardless of what I try to delete.
EDIT: Solution was to ensure the entire state is controlled. This means textareas should have values in the state that are updated when text is entered/deleted.
I've tried your example and it works although I agree with the other answers that this is not a correct way of working.
The problem though is, I assume, in a part of your code that you did not include. The part where you use addText. I think that is called after delete again.
Suggestions:
consider other namings. addText as a function AND a state is confusing
take the array from the state, splice it and put it back in the state
UPDATED MY CODE so it does not mutate original state
removeText(index) {
console.log(index);
const addTextArray = [...this.state.addText];
addTextArray.splice(index, 1);
this.setState({...this.state, addText: [...addTextArray]});
}
Using CakePHP 3.7.
I have added, at the bottom of config/bootstrap.php:
Inflector::rules('irregular', ['thesis' => 'theses']);
and actually, I've tried
Inflector::rules('irregular', ['theses' => 'thesis']);
just in case I had it backwards.
And in a cell I am trying to use:
use Cake\Utility\Inflector;
$singular_and_plural = [Inflector::singularize($base_name), $base_name];
The result for singularizing the word "thesis" is "thesiss".
Can anyone point out what's wrong, here?
The first form is the correct one, the key is the singular value, and the value the plural value.
That being said, what you're showing here is incorrect/problematic usage of Inflector::singularize(), as you're passing a value to it that already is singular, doing that often gives you unexpected/wrong results. You could open an issue ticket in such cases, sometimes this can be fixed in the core, but often times it's simply not possible as it would conflict with existing, required rules.
It should also be noted that CakePHP can handle thesis/theses out of the box already, it has singular/plural rules that match that. Make sure that you are passing in the expected values, and that you don't have additional custom rules that may interfer with what you're trying to inflect.
I have an array with a few items in it. Every x seconds, I receive a new array with the latest data. I check if the data has changed, and if it has, I replace the old one with the new one:
if (currentList != responseFromHttpCall) {
currentList = responseFromHttpCall;
}
This messes up the classes provided by ng-animate, as it acts like I replaced all of the items -- well, I do actually, but I don't know how to not.
These changes can occur in the list:
There's one (or more) new item(s) in the list - not necessaryly at the end of the list though.
One (or more) items in the list might be gone (deleted).
One (or more) items might be changed.
Two (or more) items might have been swapped.
Can anyone help me in getting ng-animate to understand what classes to show? I made a small "illustation" of my problem, found here: http://plnkr.co/edit/TS401ra58dgJS18ydsG1?p=preview
Thanks a lot!
To achieve what you want, you will need to modify existing list on controller (vm.list) on every action. I have one solution that may work for your particular example.
you would need to compare 2 lists (loop through first) similar to:
vm.list.forEach((val, index)=>{
// some code to check against array that's coming from ajax call
});
in case of adding you would need to loop against other list (in your case newList):
newList.forEach((val, index)=>{
// some code to check array on controller
});
I'm not saying this is the best solution but it works and will work in your case. Keep in mind - to properly test you will need to click reset after each action since you are looking at same global original list which will persist same data throughout the app cycle since we don't change it - if you want to change it just add before end of each function:
original = angular.copy(vm.list);
You could also make this more generic and put everything on one function, but for example, here's plnkr:
http://plnkr.co/edit/sr5CHji6DbiiknlgFdNm?p=preview
Hope it helps.
I finally managed to get my events out of the google calendar, but a executive decission was made and it was to switch the list of events around so that the last event is first on-screen. I think that the easiest way would be to change the optParams 'orderBy' to something other than startTime. So that it arrieves in descending order instead. But I have no idea how to alter this, so thats why I am here. If anyone have a way to flip the gianorums array around, then that is fine too.
It might be a bit too little to work with, but if you have done this before, you might know what I mean. Otherwise, please just leave it.
Possible late, but my coarse of action with objects and displaying results is to have an array in between. In this case I would use
$eventList = $service->events->listEvents($calendar->getId() , $optParams);
then I would use this:
foreach($eventList->getItems() as $event) {
$eventArray[]=$event->getSummary();
}
And then this:
$reverseEventArray = array_reverse($eventArray, false);
I'm have a List<Ref<Entity>>. I add new entries to the list like this:
entities.add(Ref.create(new_entry));
modified.add(new_entry);
When I store the entity that contains the list, I store the list itself and all the entities that are in the modified list. This works fine.
The problem is, that I have to work with the entities-list, while I add new entries to it. This requires iterating the list multiple times. The problem here is, that the refs in the list point to old entries (which are already in the datastore) and new entries (which are not yet in the datastore).
This causes the Ref.get()-method to return null for all the yet unstored entries in the list (the ones that are still in the modified-list).
I worked around this by doing this when inserting:
Ref<T> ref = new DeadRef<>(
Key.create(data),
data
);
this.entities.add(ref);
this.modified.add(data);
This way, I can mix stored and unstored entries in one list and Ref.get() always returns a value.
This works, but I have noticed that the refs in the entities-list stay DeadRefs when I store them to the datastore and load them in again.
Will this be a problem? Is there maybe even a better way to accomplish this?
This seems like a bad idea, although I don't know what specific problems you will run into.
The "right answer" is to save your entities first.
Edit: Also look at the documentation for ofy().defer().save(), which can prevent you from issuing a lot of unnecessary save operations.