Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Uni Osnabrück
Stud.IP
Commits
19dff131
Commit
19dff131
authored
2 years ago
by
Jan-Hendrik Willms
Browse files
Options
Downloads
Patches
Plain Diff
reorder code to ensure a correct order of callback execution, re #1990
Merge request
studip/studip!1313
parent
1dfcb8b4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/models/SimpleORMap.class.php
+14
-17
14 additions, 17 deletions
lib/models/SimpleORMap.class.php
with
14 additions
and
17 deletions
lib/models/SimpleORMap.class.php
+
14
−
17
View file @
19dff131
...
...
@@ -1880,20 +1880,15 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
}
$ret
=
0
;
$i18ncontent
=
[];
if
(
!
$this
->
isDeleted
()
&&
(
$this
->
isDirty
()
||
$this
->
isNew
()))
{
if
(
$this
->
isNew
())
{
if
(
$this
->
applyCallbacks
(
'before_create'
)
===
false
)
{
return
false
;
}
}
else
{
if
(
$this
->
applyCallbacks
(
'before_update'
)
===
false
)
{
return
false
;
}
$callback
=
$this
->
isNew
()
?
'before_create'
:
'before_update'
;
if
(
$this
->
applyCallbacks
(
$callback
)
===
false
)
{
return
false
;
}
// Collect i18n contents
$i18ncontent
=
[];
foreach
(
array_keys
(
$this
->
i18n_fields
())
as
$field
)
{
if
(
$this
->
content
[
$field
]
instanceof
I18NString
)
{
$i18ncontent
[
$field
]
=
$this
->
content
[
$field
];
...
...
@@ -1902,6 +1897,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
}
}
// Create sql data assignment chunks
foreach
(
$this
->
db_fields
()
as
$field
=>
$meta
)
{
$value
=
$this
->
content
[
$field
];
if
(
$field
==
'chdate'
&&
!
$this
->
isFieldDirty
(
$field
)
&&
$this
->
isDirty
())
{
...
...
@@ -1925,6 +1921,8 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
$this
->
content
[
$field
]
=
$value
;
$query_part
[]
=
"`
$field
` = "
.
DBManager
::
get
()
->
quote
(
$value
)
.
" "
;
}
// Create store query
if
(
!
$this
->
isNew
())
{
$where_query
=
$this
->
getWhereQuery
();
$query
=
"UPDATE `
{
$this
->
db_table
()
}
` SET "
...
...
@@ -1936,20 +1934,15 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
}
$ret
=
DBManager
::
get
()
->
exec
(
$query
);
// Retrieve generated id from database if pk is an auto increment
// column
if
(
$this
->
isNew
())
{
if
(
$this
->
hasAutoIncrementColumn
()
&&
!
$this
->
getId
())
{
$this
->
setId
(
DBManager
::
get
()
->
lastInsertId
());
}
$this
->
applyCallbacks
(
'after_create'
);
}
else
{
$this
->
applyCallbacks
(
'after_update'
);
}
}
$rel_ret
=
$this
->
storeRelations
();
// Store i18n contents
if
(
count
(
$i18ncontent
)
>
0
)
{
// Store i18n contents
foreach
(
$i18ncontent
as
$field
=>
$one
)
{
$meta
=
[
'object_id'
=>
$this
->
getId
(),
...
...
@@ -1963,7 +1956,11 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
$this
->
content_db
[
$field
]
=
clone
$one
;
}
}
// Apply callbacks
$this
->
applyCallbacks
(
$this
->
isNew
()
?
'after_create'
:
'after_update'
);
}
$rel_ret
=
$this
->
storeRelations
();
$this
->
applyCallbacks
(
'after_store'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment