EPrints Technical Mailing List Archive

Message: #05228


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Re: undefined value error


Is there some subtle $repository vs $session thing going on here?
I think I may have seen something similar at some point on 3.3.10...



-----Original Message-----
From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Field A.N.
Sent: 03 December 2015 11:57
To: eprints-tech@ecs.soton.ac.uk
Subject: [EP-tech] Re: undefined value error

Not seen this before.  Does this script work:


#!/usr/bin/perl -I/usr/share/eprints3/perl_lib

use strict;
use warnings;

use EPrints;

my $ep = EPrints->new();
my $repo = $ep->repository( "myrepository" );
my $eprint = $repo->eprint( 1 );
$eprint->set_value ("title", "a value");
$eprint->commit;

I test-ran it on a 3.3.12 repository, and it worked.  First run as above, and then change the set_value line to use the new field.


--
Adam Field
Business Relationship Manager and Community Lead
EPrints Services
+44 (0)23 8059 8814




On 3 Dec 2015, at 11:43, Alan.Stiles wrote:

> Has anyone seen / solved an issue like this?
>  
> I’m building a command-line routine (in 3.3.10) to update a new field on eprints. The field exists in the dataset, as seen in MySQL workbench.
> It works fine for most of the eprints I’m updating, but some of them cause the routine to fail with the following message:
>  
> Can't call method "current_repository" on an undefined value at /opt/eprints3/perl_lib/EPrints/BackCompatibility.pm line 443.
>  
>  
> My raft of debug statements have narrowed it down to a call to $eprint->commit;
>  
> …
> my $eprint = $repository->eprint($eprint_id);
> if (defined($eprint))
> {
> $eprint->set_value ("new_field_name", “a value");
> print STDERR "debug 4, ".$eprint->get_value("new_field_name").", ";
> $eprint->commit ;
> print STDERR "debug 5\n";
> }
> …
>  
> And the output on STDERR is
>  
> debug 4, a value, Can't call method "current_repository" on an undefined value at /opt/eprints3/perl_lib/EPrints/BackCompatibility.pm line 443.
>  
> Any clues?  This is on a dev server, so something might be missing from another table?  Everything looks the same in the eprints table as records that worked.
> -- The Open University is incorporated by Royal Charter (RC 000391), an exempt charity in England & Wales and a charity registered in Scotland (SC 038302). The Open University is authorised and regulated by the Financial Conduct Authority. *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive: http://www.eprints.org/tech.php/
> *** EPrints community wiki: http://wiki.eprints.org/
> *** EPrints developers Forum: http://forum.eprints.org/


*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/