Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Ivlev
bugzilla
Commits
6b4e9eda
Commit
6b4e9eda
authored
Feb 10, 2010
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 545551: Hook: object_update_columns
r=mkanat, a=mkanat (module owner)
parent
aca53c54
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
2 deletions
+46
-2
Hook.pm
Bugzilla/Hook.pm
+29
-0
Object.pm
Bugzilla/Object.pm
+8
-2
Extension.pm
extensions/Example/Extension.pm
+9
-0
No files found.
Bugzilla/Hook.pm
View file @
6b4e9eda
...
...
@@ -715,6 +715,35 @@ L<Bugzilla::Object/update> returns.
=back
=head2 object_update_columns
If you've added fields to bugs via L</object_columns>, then this
hook allows you to say which of those columns should be updated in the
database when L<Bugzilla::Object/update> is called on the object.
If you don't use this hook, then your custom columns won't be modified in
the database by Bugzilla.
Params:
=over
=item C<object>
The object that is about to be updated. You should check this
like C<< if ($object->isa('Some::Class')) >> in your code, to modify
the "update columns" only for certain classes.
=item C<columns>
An arrayref. Add the string names of columns to this array to allow
that column to be updated when C<update()> is called on the object.
This arrayref does not contain the standard column names--you cannot stop
standard columns from being updated by using this hook.
=back
=head2 object_validators
Allows you to add new items to L<Bugzilla::Object/VALIDATORS> for
...
...
Bugzilla/Object.pm
View file @
6b4e9eda
...
...
@@ -322,11 +322,17 @@ sub update {
$dbh
->
bz_start_transaction
();
my
$old_self
=
$self
->
new
(
$self
->
id
);
my
@all_columns
=
$self
->
UPDATE_COLUMNS
;
my
@hook_columns
;
Bugzilla::Hook::
process
(
'object_update_columns'
,
{
object
=>
$self
,
columns
=>
\
@hook_columns
});
push
(
@all_columns
,
@hook_columns
);
my
%
numeric
=
map
{
$_
=>
1
}
$self
->
NUMERIC_COLUMNS
;
my
%
date
=
map
{
$_
=>
1
}
$self
->
DATE_COLUMNS
;
my
(
@update_columns
,
@values
,
%
changes
);
foreach
my
$column
(
$self
->
UPDATE_COLUMNS
)
{
foreach
my
$column
(
@all_columns
)
{
my
(
$old
,
$new
)
=
(
$old_self
->
{
$column
},
$self
->
{
$column
});
# This has to be written this way in order to allow us to set a field
# from undef or to undef, and avoid warnings about comparing an undef
...
...
extensions/Example/Extension.pm
View file @
6b4e9eda
...
...
@@ -386,6 +386,15 @@ sub object_end_of_update {
}
}
sub
object_update_columns
{
my
(
$self
,
$args
)
=
@_
;
my
(
$object
,
$columns
)
=
@$args
{
qw(object columns)
};
if
(
$object
->
isa
(
'Bugzilla::ExampleObject'
))
{
push
(
@$columns
,
'example'
);
}
}
sub
object_validators
{
my
(
$self
,
$args
)
=
@_
;
my
(
$class
,
$validators
)
=
@$args
{
qw(class validators)
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment