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 errors 'Can't use an undefined value as an ARRAY reference' while running sympa.pl --modify_list #741

Conversation

salaun-urennes1
Copy link
Collaborator

I get this error while running

$ sympa.pl -d --modify_list testfamily  --input_file /usr/local/sympa/list_data/testlist1/instance.xml
Can't use an undefined value as an ARRAY reference at /usr/local/sympa/bin/sympa.pl line 931.

I fixed sympa.pl to ensure $result->{'string_info'} and $result->{'string_info'} are defined before trying go through a ARRAYREF.

… running sympa.pl --modify_list. Check if and before trying to print their content
@ikedas ikedas added the bug label Sep 3, 2019
@ikedas ikedas added this to the 6.2.46 milestone Sep 3, 2019
@racke
Copy link
Contributor

racke commented Sep 4, 2019

I would rather fix the place in the code which misses to put the information into string_error variable.

@salaun-urennes1
Copy link
Collaborator Author

I think both make sense.
The best way to strengthen the code would be to encapsulate all the informations about function execution (ok, string_info and string_error) in a dedicated object. The object could have a print() or as_string() method that would take care of undefined cases.

@racke
Copy link
Contributor

racke commented Sep 4, 2019

Yeah indeed. I agree with you. What was the problem in your case?

@ikedas
Copy link
Member

ikedas commented Sep 4, 2019

@salaun-urennes1's changes will prevent crash by treating undefined value as arrayref.

FY, I'm planning to refactor --- or rewrite Sympa::Family so that it may not contain inconsistent error handling using hash elements.

@salaun-urennes1
Copy link
Collaborator Author

The problem I'm facing: sympa.pl crashes.
Hopefully in the situation it's not too serious, because the job has been done by sympa.pl before it crashes. But it's confusing for the user and also prevents proper exit status handling in third-party scripts.

@racke
Copy link
Contributor

racke commented Sep 4, 2019

Can you share your XML file?

@salaun-urennes1
Copy link
Collaborator Author

Here are the config files for the family initial instantiation :

subject [% subject %]

[% FOREACH o = owner -%]
owner
email [% o.email %]
profile privileged

[% END -%]
 <family> 
   <list>
    <listname>testlist1</listname>
    <subject>This is my list</subject>
    <owner multiple="1">
      <email>[email protected]</email>
    </owner>
    <owner multiple="1">
      <email>[email protected]</email>
    </owner>
   </list>
</family>

Instantiation with sympa.pl --instantiate_family test_bundle_of_lists --close_unknown --input_file initial_definition.xml

And here is /usr/local/sympa/list_data/testlist1/instance.xml:

   <list>
    <listname>testlist1</listname>
    <subject>New list subject</subject>
    <owner multiple="1">
      <email>[email protected]</email>
    </owner>
    <owner multiple="1">
      <email>[email protected]</email>
    </owner>
    <owner multiple="1">
      <email>[email protected]</email>
    </owner>
   </list>

@ikedas ikedas merged commit 4893ee4 into sympa-community:master Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants