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

Fix list field saving as well as all varieties of custom fields #1372

Merged
merged 3 commits into from
Apr 1, 2022

Conversation

rmunn
Copy link
Collaborator

@rmunn rmunn commented Apr 1, 2022

Description

Fix saving list fields and custom fields.

Fixes #1248.

Type of Change

Only keep lines below that describe this change, then delete the rest.

  • Bug fix (non-breaking change which fixes an issue)

Screenshots

Please provide screenshots / animations for any change that involves the UI. Please provide animations to demonstrate user interaction / behavior changes

Testing on your branch

  • Create a new non-send/receive project (for speed)
  • Load the TestLangProj.7z data into it (from the test/common directory)
  • Add data to all the custom fields (except CustMultiPara because multi-paragraph fields are disabled in LF right now) of the first entry
  • Also change the part of speech
  • Click to another entry
  • Click back to the first entry
  • Verify that the data you added is still there
  • Do a browser refresh (F5)
  • Verify that the data you entered is still there
    • If this step fails, then the data made it into localStorage but did not actually make it into Mongo

Checklist

  • I have performed a self-review of my own code
  • I have reviewed the title/description of this PR which will be used as the squashed PR commit message
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works

Tests will come in a later PR, since writing them is non-trivial.

qa.languageforge.org testing

Reviewers: add/replace your name below and check the box to sign-off/attest the feature works as expected on qa.languageforge.org

  • Reviewer1 (YYYY-MM-DD HH:MM)
  • Reviewer2 (YYYY-MM-DD HH:MM)

It was a little tricky to ensure that custom list fields could save data
while not messing up the ability to save data into multitext fields.
There is a quite extensive comment included in the code about how we
needed to distinguish between the two. I may remove or trim down that
comment in the next commit.
The lengthy comment in the previous commit has been trimmed down a
little, and is hopefully still explanatory enough.
@github-actions
Copy link

github-actions bot commented Apr 1, 2022

Unit Test Results

    1 files      1 suites   9s ⏱️
373 tests 373 ✔️ 0 💤 0

Results for commit cbb4579.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@megahirt megahirt left a comment

Choose a reason for hiding this comment

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

Here's to hoping! I will help you test. Looks like the PHP tests are failing with two different errors.

@megahirt
Copy link
Collaborator

megahirt commented Apr 1, 2022

Unit test failures:

There were 5 errors:

1) LexEntryCommandsTest::testDeepDiff_oneExampleFieldChanged
Exception: Type Exception: Expected 'integer' given 'string' :: value

/var/www/html/vendor/sillsdev/web-php-utilities/src/CodeGuard.php:126
/var/www/html/vendor/sillsdev/web-php-utilities/src/CodeGuard.php:25
/var/www/html/Api/Model/Shared/Mapper/ArrayOf.php:45
/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:153
/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:126
/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:60
/var/www/html/Api/Model/Languageforge/Lexicon/Command/LexEntryCommands.php:135
/var/www/test/php/model/languageforge/lexicon/command/LexEntryCommandsTest.php:1770
/var/www/test/php/model/languageforge/lexicon/command/LexEntryCommandsTest.php:1841
phpvfscomposer:///var/www/html/vendor/phpunit/phpunit/phpunit:60

2) LexEntryCommandsTest::testDeepDiff_twoExampleFieldsChanged
Exception: Type Exception: Expected 'integer' given 'string' :: value

/var/www/html/vendor/sillsdev/web-php-utilities/src/CodeGuard.php:126
/var/www/html/vendor/sillsdev/web-php-utilities/src/CodeGuard.php:25
/var/www/html/Api/Model/Shared/Mapper/ArrayOf.php:45
/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:153
/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:126
/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:60
/var/www/html/Api/Model/Languageforge/Lexicon/Command/LexEntryCommands.php:135
/var/www/test/php/model/languageforge/lexicon/command/LexEntryCommandsTest.php:1770
/var/www/test/php/model/languageforge/lexicon/command/LexEntryCommandsTest.php:1851
phpvfscomposer:///var/www/html/vendor/phpunit/phpunit/phpunit:60

3) LexEntryCommandsTest::testDeepDiff_fieldsChangedAtEveryLevel
Exception: Type Exception: Expected 'integer' given 'string' :: value

/var/www/html/vendor/sillsdev/web-php-utilities/src/CodeGuard.php:126
/var/www/html/vendor/sillsdev/web-php-utilities/src/CodeGuard.php:25
/var/www/html/Api/Model/Shared/Mapper/ArrayOf.php:45
/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:153
/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:126
/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:60
/var/www/html/Api/Model/Languageforge/Lexicon/Command/LexEntryCommands.php:135
/var/www/test/php/model/languageforge/lexicon/command/LexEntryCommandsTest.php:1770
/var/www/test/php/model/languageforge/lexicon/command/LexEntryCommandsTest.php:1867
phpvfscomposer:///var/www/html/vendor/phpunit/phpunit/phpunit:60

4) LexEntryCommandsTest::testDeepDiff_swappedSenses
Trying to get property 'guid' of non-object

/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:155
/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:126
/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:60
/var/www/html/Api/Model/Languageforge/Lexicon/Command/LexEntryCommands.php:135
/var/www/test/php/model/languageforge/lexicon/command/LexEntryCommandsTest.php:1770
/var/www/test/php/model/languageforge/lexicon/command/LexEntryCommandsTest.php:1899
phpvfscomposer:///var/www/html/vendor/phpunit/phpunit/phpunit:60

5) LexEntryCommandsTest::testDeepDiff_swappedSensesAndOneSenseFieldChanged
Trying to get property 'guid' of non-object

/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:155
/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:126
/var/www/html/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php:60
/var/www/html/Api/Model/Languageforge/Lexicon/Command/LexEntryCommands.php:135
/var/www/test/php/model/languageforge/lexicon/command/LexEntryCommandsTest.php:1770
/var/www/test/php/model/languageforge/lexicon/command/LexEntryCommandsTest.php:1921
phpvfscomposer:///var/www/html/vendor/phpunit/phpunit/phpunit:60

Hey PHP, comparing 0 to `customFields` should NOT return true by
default! The `strict` parameter should default to true, and if you
actually want to compare ints to strings you should have to ask for it.
@rmunn rmunn merged commit 803ce18 into develop Apr 1, 2022
@rmunn rmunn deleted the bugfix/fix-custom-list-field-saving branch April 1, 2022 05:03
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.

bug: inconsistent save behavior
2 participants