Menu

'Facts to always show on Quick Update' Error

2009-01-24
2013-05-30
  • George Saxton

    George Saxton - 2009-01-24

    Using:
    PHP Version 5.2.4-2ubuntu5.4, 
    MySQL version 5.0.51a-3ubuntu5.4,
    phpGedView version 4.2, revision 4862.

    I think I have found another bug:  First I add 'NAME' to the 'Facts to always show on Quick Update' entry under 'Edit Options' of the GEDCOM configuration.  I also select 'Prefer fact sources'.  Then I add an individual (for example, by selecting 'Add a brother or sister' under 'Family with Parents' on the 'Close Relatives' Tab).  While the pop-up window is open, I click 'Add a new Source Citation' and fill in the Source information, leaving the checkboxes for 'Name', 'Birth' and 'Death' checked.  Even though I have filled in 'Given Names' (and 'Surname' is already filled in) at the top of the edit_interface() pop-up page, the resulting gedcom has a 1 NAME line whose the value is blank.  This displays as "(unknown)‎ ‎(unknown)‎".  All other lines in the gedcom, including 2 GIVN and 2 SURN, appear to be correct.  But there is no 2 SOUR under 1 NAME, even though I had left that box checked.  The 2 SOUR links appear under 1 BIRT and 1 DEAT as expected.

    Having stated the essence, let me explain more.  Last year, while we were running version 4.1.3, my daughter asked me if there wasn't some way to get a 'Name' checkbox (along with 'Individual', 'Birth' and 'Death') on the 'Add a new Source Citation' "pop-in" form of the new-individual popup from edit_interface().  She was always having to go back and add the 2 SOUR info under 1 NAME after completing the entry of an individual.  Well, I looked at the code and lo-and-behold, it wasn't very difficult to do what she wanted.  Mostly, I just copied  a few lines of code from one place to another in edit_interface.php and functions_edit.php.  Then she wanted me to remove the checked status of 'Individual', leaving all the checkboxes unchecked.  This, too, proved pretty easy.  Now, when she enters a new individual, she can expand 'Add a new Source Citation' and just check off the boxes, including 'Name', for the facts that the Source supports.  When we upgraded to versions 4.1.4 and 4.1.5, I was able to make the same changes to the new versions. 

    But when I looked at 4.1.6, I found the code substantially changed.  With the anticipated release of 4.2 just a few weeks away, I decided to work with the svn code instead.  You can imagine my delight when I found a configuration option, 'Facts to always show on Quick Update', that adds the checkboxes I want.  And another configuration option, 'Prefer fact sources', controls whether 'Individual' or the other checkboxes are initially checked.

    So when I tried it out, and got the results described above, I was a little disappointed.  The reason I think this is a bug is that the behaviour (empty value in 1 NAME line) seems incorrect even if you folks believe that it is improper usage to include NAME among the facts in 'Facts to always show on Quick Update'. 

    I managed to fix this problem on my own site with the following changes to functions_edit.php:

    In function print_indi_form(), under "if ($nextaction!='update')", at line 726 of the original code,

        change

                foreach ($matches[1] as $match) {
                    if (!in_array($match, explode('|', PGV_EVENTS_DEAT))) {
                        addSimpleTags($match);
                    }

                }
        to

                foreach ($matches[1] as $match) {
                    if (!in_array($match, explode('|', PGV_EVENTS_DEAT))) {
                        if ($match<>'NAME') {
                        addSimpleTags($match);
                        }
                    }
                }

      This prevents print_indi_form() from adding a second Name entry field.

    In function addNewName(), at line 1673 of the original code,

        change

        global $ADVANCED_NAME_FACTS;

        to

        global $tagSOUR, $ADVANCED_NAME_FACTS;

    and at the end of this function, at line 1688 of the original code,

        change

        return $gedrec;

        to

        $SOUR=safe_POST_bool("SOUR_NAME");
        if ($SOUR && count($tagSOUR)>0) {
            $gedrec=updateSOUR($gedrec, 2);
        }
        return $gedrec;

      This adds the 2 SOUR entry under the 1 NAME tag.

    Finally, in function addNewFact(), at line 1703 of the original code,

        change

        $FACT=safe_POST($fact,          PGV_REGEX_UNSAFE);

        to

        $FACT=safe_POST($fact,          PGV_REGEX_UNSAFE);
        if ($FACT=='NAME') return '';

      This prevents edit_interface.php from trying to add a 2 NAME tag.

    As I say, these changes fix the problem for me, but they may not be enough for released code.  Should the entries in 'Facts to always show on Quick Update' be limited to those tags that are allowed at level 1 in the GEDCOM?  Should SEX be handled similarly to what I have done for NAME (because it is separately processed by print_indi_form() )?  You can probably think of many other considerations. 

    You probably noticed that I haven't mentioned any changes that I made to have all the checkboxes on the 'Add a new Source Citation' form be unchecked.  Please look for a Feature Request, with suggested code, coming soon.

    I have posted this in the Open Discussion Forum in case others want to weigh in.  Please let me know if you want this posted as a Bug Report (or maybe a Feature Request?).  Thank you.

      - George

     
    • George Saxton

      George Saxton - 2009-01-24

      Oops.  That last change should have been:

      Finally, in function addNewFact(), at line 1703 of the original code, 

      change 

      $FACT=safe_POST($fact, PGV_REGEX_UNSAFE);

      to 

      $FACT=safe_POST($fact, PGV_REGEX_UNSAFE);
      if ($fact=='NAME') return '';

      This prevents edit_interface.php from adding a 1 NAME Y tag.

       
    • Greg Roach

      Greg Roach - 2009-01-24

      <<1 NAME line whose the value is blank. This displays as "(unknown)‎ ‎(unknown)‎". All other lines in the gedcom, including 2 GIVN and 2 SURN, appear to be correct.>>

      If I understand you correctly, you are getting this in your gedcom:

      1 NAME
      2 GIVN John
      2 SURN DOE

      The NAME field is populated by javascript in the browser.  Have you introduced any changes that could affect JS execution?  Have you looked at your javascript error log?

      <<As I say, these changes fix the problem for me, but they may not be enough for released code.>>

      This is the advantage of open source code.  You are free to modify it, and we're very happy that you are.

      A couple of comments on your changes:

      1) You haven't mentioned the quick-update form.  I guess it will end up getting an extra name field.

      2) You are adding extra functionality to the 'Facts to always show on Quick Update' configuration option.  Most of your changes are to prevent this option from working as designed.  You might be better off simply adding a new configuration option that does exactly what you want, such as "Add level 2 sources to name/sex on add-new-person from".

       
    • George Saxton

      George Saxton - 2009-01-24

      <<The NAME field is populated by javascript in the browser. Have you introduced any changes that could affect JS execution? Have you looked at your javascript error log? >>

      I'm learning as I go here, and I really appreciate your hints, Greg.  Sorry, I haven't been using the javascript error log.  My experience with javascript is pretty limited.  Just to be sure I understand what you're saying, when using Firefox, the javascript error log would be what I get when I select Tools > Error Console; is that right? 

      When I'm using the add-new-person form (the one produced by print_indi_form() ), the 'Name' field *is* filled in by javascript as I type into the other name fields ('Prefix', 'Given Names', 'Surname Prefix', 'Surname' and 'Suffix'), both with and without the changes I described. 

      But without the changes, the javascript-populated NAME information disappears after I click the 'Save' button.  I think it is because of the second 'Name' field that is added to the form.  This one is not populated by javascript, so it remains empty, and when it is processed by edit_interface.php, it overwrites the correct information from the first 'Name' field.  It seems strange to me that this would be "working as designed", but I can understand that you did not intend that NAME would be one of the tags added to 'Facts to always show on Quick Update'. 

      <<You haven't mentioned the quick-update form. I guess it will end up getting an extra name field. >>

      I missed that one.  You are right.  We haven't been using quick-update, mostly because it doesn't include any provision for citing source information.  I guess if I carry on as I have been, I should also modify the quick-update code to prevent these unwanted side effects.

      <<You might be better off simply adding a new configuration option that does exactly what you want, such as "Add level 2 sources to name/sex on add-new-person from". >>

      Yes, this would at least avoid messing up quick-update.  But I would still have to make the same kinds of changes to function_edit.php to prevent NAME (and SEX) from misbehaving.  If I take this approach (as I probably will--it is a good idea) then I will probably remove the extra functionality that you introduced when you made 'Facts to always show on Quick Update' also affect the checkboxes in 'Add a new Source Citation'.  In other words, I will make a new configuration variable to hold my list of tags, and replace $QUICK_REQUIRED_FACTS in print_indi_form() and add_simple_tag() with the new variable. 

      Thank you again for your feedback, Greg.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.