@@ -278,12 +278,14 @@ function addAction($data, $form) {
278278 // remove missing
279279 foreach ($ speaker ->AreasOfExpertise () as $ exp ){
280280 if (!in_array ($ exp ->Expertise , $ expertise )) {
281+ if (!$ exp ->exists ()) continue ;
281282 $ exp ->delete ();
282283 }
283284 }
284285 } else {
285286 // remove all
286287 foreach ($ speaker ->AreasOfExpertise () as $ exp ){
288+ if (!$ exp ->exists ()) continue ;
287289 $ exp ->delete ();
288290 }
289291 }
@@ -310,6 +312,7 @@ function addAction($data, $form) {
310312 // remove missing
311313 foreach ($ speaker ->OtherPresentationLinks () as $ pl ){
312314 if (!in_array ($ pl ->LinkUrl , $ data ['PresentationLink ' ])) {
315+ if (!$ pl ->exists ()) continue ;
313316 $ pl ->delete ();
314317 }
315318 }
@@ -332,12 +335,14 @@ function addAction($data, $form) {
332335 // remove missing
333336 foreach ($ speaker ->TravelPreferences () as $ tp ){
334337 if (!in_array ($ tp ->Country , $ countries )) {
338+ if (!$ tp ->exists ()) continue ;
335339 $ tp ->delete ();
336340 }
337341 }
338342 } else {
339343 // remove all
340344 foreach ($ speaker ->TravelPreferences () as $ tp ){
345+ if (!$ tp ->exists ()) continue ;
341346 $ tp ->delete ();
342347 }
343348 }
@@ -351,8 +356,6 @@ function addAction($data, $form) {
351356 return $ this ->controller ()->redirectBack ();
352357
353358 }
354- else {
355- return Security::PermissionFailure ($ this ->controller , 'You must be <a href="/join">registered</a> and logged in to edit your profile: ' );
356- }
359+ return Security::PermissionFailure ($ this ->controller , 'You must be <a href="/join">registered</a> and logged in to edit your profile: ' );
357360 }
358361}
0 commit comments