Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing properties and fields without paths from cfe #195

Merged
merged 6 commits into from
Feb 5, 2019
Merged

Conversation

boznik
Copy link
Contributor

@boznik boznik commented Feb 4, 2019

READY FOR REVIEW

Summary

  • Empty paths throw exception. Happens when a path is added then removed when saving mapper.

Needed By (Date)

  • ASAP

Urgency

  • high

Steps to Test

  1. check out this branch
  2. add a path to a property or node field and save form.
  3. edit form deleting a path in a property or node.
  4. test import for errors.

Affected Projects or Products

  • Wherever capx is used

Associated Issues and/or People

stanford_capx.forms.inc Outdated Show resolved Hide resolved
stanford_capx.forms.inc Show resolved Hide resolved
@@ -997,12 +997,22 @@ function stanford_capx_mapper_form_submit($form, $form_state) {
// If there are properties...
$properties = @$values['field-mapping'][$entity . "-properties"];
if (!empty($properties)) {
foreach ($properties as $key => $value) {
if (empty($value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (empty($value)) {
if (empty(array_filter($value))) {

@sherakama
Copy link
Member

So the form was not removing the property mapping on save but rather, was introducing an empty string?

So if I have this right, what happened was:

  1. A mapping was created for a property and the CFE was saved
  2. Later a user removed the property mapping by deleting it in the mapping form.
  3. That caused an empty string to replace the previous mapping value and the fetcher still tried to fetch

Is that right?

It was the action of trying to remove the mapping that caused the error?

@boznik
Copy link
Contributor Author

boznik commented Feb 4, 2019

@sherakama yes, you have the scenario correct.

Copy link
Member

@sherakama sherakama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this seems reasonable to me. @pookmish any objections?

@pookmish
Copy link
Contributor

pookmish commented Feb 4, 2019

The logic is a little messy. lately ive starting to become a fan of array_filter callbacks to clean up arrays. it removes a lot of if ... unset code like this. but logically it works.

@boznik
Copy link
Contributor Author

boznik commented Feb 5, 2019

ok, the properties and fields array are a bit different but this latest version is working

Copy link
Contributor

@pookmish pookmish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@sherakama sherakama merged commit 85c62ad into 7.x-3.x Feb 5, 2019
@sherakama sherakama deleted the WOODS-96 branch February 5, 2019 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants