1

Topic: Importer form problems

I am using Instant Indicia to set up a recording website for the University of York's campuses. I've got a test Instant Indicia website up and running and I am using the test BRC warehouse at the moment.

I have enabled the importer form so that users can upload csv files of records to our website.

When I try to upload a csv file I get the following error message:

warning: array_key_exists() expects parameter 2 to be array, null given in /var/www/opal2/sites/all/libraries/iform/client_helpers/helper_base.php on line 825

The page still loads though and I can specify import settings and on the next page I can map the attributes. When I then click upload I just get a blank page.

Does anyone know what the problem might be?

I also want to specify some standard settings for all uploads:
Survey = Casual Records
Species List = UK Master List
Record Status = Data entry complete/unverified

I've successfully specified "sample:entered_sref_system=OSGB" in the form settings but can't seem to get the syntax correct for these other options.

Can anyone advise as to how to specify these properly?

Many thanks

Rachel

2

Re: Importer form problems

Hi Rachel

Would you be able to attach the first few lines of your csv file?

Jim Bacon

3

Re: Importer form problems

Hello Jim
Given the response to my previous question, I have modified the csv file I was using to include a species name that I know is in the UK Master List on the test BRC warehouse. I still get the same error message after the first step when I select the file to upload. Using this new csv, however, I have been able to upload the file after specifying the import settings and mapped the columns to attributes. However, it then states that problems were detected during the import. When I download the csv file of records that did not import (all of them) the "problem" column says "please".
I've attached the test csv file I have been using.
Many thanks
Rachel

Post's attachments

test_upload2.csv 130 b, 9 downloads since 2013-02-04 

You don't have the permssions to download the attachments of this post.

4

Re: Importer form problems

Hi Rachel

Nothing, if not polite, is it? I saw the same when I opened the error file in Excel but then I expanded the problem column width a bit since Excel doesn't open csv files very cleverly. It says "Please specify a value for the Email". You have this sample attribute enabled and it is mandatory so you have to include it in your csv file for the upload to work.

However, I see you are storing CMS Username and CMS ID too which is the old way of keeping track of who records have been submitted by. I'd encourage you to use the EasyLogin module instead, which creates users on the Warehouse and a Warehouse ID instead. You could then probably do without the email sample attribute.

You should use EasyLogin if you want your website to interoperate fully with iRecord and that is highly desirable.

Jim Bacon.

5

Re: Importer form problems

Hi Rachel
Presuming that you are working on the test warehouse still, you could try these settings for the settings:

sample:entered_sref_system=OSGB
survey_id=98
fkFilter:taxa_taxon_list:taxon_list_id=34
occurrence:record_status=C

Plus, if you enable Easy Login as Jim suggests, add:

user_id={profile_indicia_user_id}

Best wishes
John

John van Breda
Biodiverse IT

6

Re: Importer form problems

Hi Jim and John
Sorry, only just seen your responses.
I've changed those settings and all seems to be working fine now, thank you!
I do still, however, get the same error message (x5) when I initially upload the file:

warning: array_key_exists() expects parameter 2 to be array, null given in /var/www/opal2/sites/all/libraries/iform/client_helpers/helper_base.php on line 825

Do you know what that could be about?

Many thanks for your help.

Rachel

7

Re: Importer form problems

Hi Rachel

Do you have a text editor, such as Notepad++ that allows you to open the file and easily locate line 825? If you could paste the offending line here that would avoid the situation of me looking in a version of the file that is different from your version.

Jim

8

Re: Importer form problems

Oh, yes, you might want to go to the profile > settings item in the forum and ensure "Subscribe to topics by default when posting" is checked so that you get an email when there is a reply to one of your posts.

Jim

9

Re: Importer form problems

Hi Jim
I do now! Here is line 825...
        if (!array_key_exists($key, $options['extraParams']))
Is that sufficient to help?
Thanks
Rachel

10

Re: Importer form problems

Hi Rachel

Okay, after a bit of poking around that looks like the Instant Indicia 0.8.2 download. (Note for John, I couldn't identify a tagged version of the client_helpers in the repository that this corresponded to.)

Comparing this with the latest snapshot of the code I can see that this was a bug that has since been corrected (in revision 5243).

There is a half decent chance that you can fix the bug by changing that line to read

if (!isset($options['presetParams']) || !array_key_exists($key, $options['presetParams']))

You'd be advised to make a backup copy of the file before altering it.

Jim Bacon.

11

Re: Importer form problems

Brilliant. That seems to be working now.
Many thanks!
Rachel

12

Re: Importer form problems

Hi John
I've just noticed that records I've submitted to my test site via csv upload don't have a recorder name associated with them. I've got the user id setting that you suggested (see quote below) below in the preset settings that should be compatible with Easy Login.
I've also noticed that when I view my sample details on the BRC test warehouse they don't have a recorder name associated with them - should they do?
Many thanks
Rachel


johnvanbreda wrote:

Hi Rachel
Presuming that you are working on the test warehouse still, you could try these settings for the settings:

sample:entered_sref_system=OSGB
survey_id=98
fkFilter:taxa_taxon_list:taxon_list_id=34
occurrence:record_status=C

Plus, if you enable Easy Login as Jim suggests, add:

user_id={profile_indicia_user_id}

Best wishes
John

13

Re: Importer form problems

Hi Rachel

You have several outstanding questions which I haven't answered because you are treading ground that I haven't yet travelled. This one may fall in to that category too but I can shine a dim light on things.

You may be looking at your samples and seeing nothing in the Recorder Names field and thinking that is wrong. That is actually what I would expect. I would expect the user_id to infact be populating two fields - the created_by_id in both the sample and the occurrence. If you visit a sample or occurrence and click the Show/Hide Metadata button it shows who created the record. That is where I would expect to see the name of the person who uploaded the record.

I dipped in to a few of your records and only saw 'admin' which is not what I expected.

If, on your Drupal site, you go to User Management > Users > List and edit your entry you should see settings for Account, Name, Preferences and System. Click System and you should see an Indicia User ID. That ID should match what you see if you find yourself in the list of users on the warehouse website. Can you check to see if that is as I describe.

Jim Bacon.

14

Re: Importer form problems

Hi Jim

Thanks for your response.

I've had a look and the IDs don't match.
I've created a couple of users so I can see what happens with different levels of permission.
rachelpateman (which is my admin login) has Drupal user ID 91 and warehouse ID 95.
rachel_pateman (which is my authenticated use login) had Drupal user ID 97 and warehouse ID 99.

I've also had a look at the "created_by" fields under the metadata - thanks for pointing me to this! There are some which say they are created by "Pateman" which are the ones I've added when I've been logged in. I think the ones which say "admin" are either ones added by an "anonymous" user or those I've uploaded in a csv. As I mentioned before, the ones I've uploaded from a csv also don't have the "recorder" field populated on the dynamic reporter form.

15

Re: Importer form problems

Hi Rachel,

Just a thought, are you logged in to Drupal when doing the csv upload? If not then you are anonymous so, naturally, there is no recorder name to attach to the records.

I haven't been able to test this myself as I am encountering some other problem with my test system which I need to isolate and fix.

Jim Bacon.

16

Re: Importer form problems

Hi Rachel

Okay. I overcame my problems to test out the upload and, even when logged in to my drupal site, I experience the same problem that you were having, namely that thet user_id={profile_indicia_user_id} setting is being ignored.

The reason for this, I have found, is a mismatch between what the client is sending and the warehouse is expecting. The client is sending the user_id setting inside an array of settings. At the warehouse this ends up as the variable $metadata['settings']['user_id']. However, the warehouse  looks for it as $metadata['user_id'] and so doesn't find it.

My problem is that I don't know if the bug is with the client or the warehouse. If I 'fix' the warehouse I might break something else. We could use John's advice.

Jim Bacon.

17

Re: Importer form problems

Hi Rachel and Jim
I'm assuming that you are using the files as downloaded for 0.8.2 of Instant Indicia? If so, then I note from the Subversion log that a bug was fixed in import_helper.php in revision 5245, which inserts the warehouse user ID into the uploaded data correctly. So, the answer is to copy over the latest copy of import_helper.php. I've tested this and it works fine on my development setup.

Best wishes

John van Breda
Biodiverse IT

18

Re: Importer form problems

Hi John

Thanks. I am using Instant Indicia 0.8.2. This revision fixed the problem.

I'm not sure, Rachel, if you are adept at downloading files from the repository. An alternative is to edit import_helper.php (probably in sites/all/libraries/iform/client_helpers) and copy in the change highlighted in green in r5245 around line 417. Make sure you backup your original file first if doing this.

With this fix, you do not need to add user_id={profile_indicia_user_id} to your form settings.

Jim Bacon.

19

Re: Importer form problems

Hi Jim and John
Many apologies for the slow reply to this, I've been totally distracted by other things.
I've made the revision for user id as above. Hopefully that has worked but now my records are being rejected because I've made the email field a required field. Is there also a way to automatically add the email address of the logged in user?
Many thanks
Rachel

20

Re: Importer form problems

Hi

You are using sample attribute 9 for your email field so adding to the list of settings

smpAttr:9={email}

is my first guess. Better try that hadn't I.

Yes, despite the fact that the Preset Settings available are described as "those which are available for input on the first page of the import wizard" and there are only 4 of those, as listed by John above, it seems to work.

Jim Bacon.