EPrints Technical Mailing List Archive

Message: #08975


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

[EP-tech] Bug in Subject.pm?


I've just upgraded an old EPrints site to 3.4.3.

I'm now getting an error from the EPrints::MetaField::Subject function render_set_input

It gets the value of the field from the dataobj and immediately dereferences it as an array without checking. In this particular case my field is not multiple so no results returns as NULL not [] and so it dies with an error

The field configuration is just:

        { name=>"country", type=>"subject", top=>"un_geoscheme", browse_link => "country" },

Wrapping the offending code  in an if(..) {..} to test if it's not null worked OK but is a horrid hack.

From looking at DataObj->get_value, it returns a [] only if the field is multiple.

However if the Subject field is not multiple then $dataobj->get_value( "country")  will return "string" or NULL (not [] or ["string"] as the code assumes).


I could easily write a fix to make it check the value was set and if the field was non-multiple, turn it into a loist

Is there a known work around for this? I don't like working with patched code unless there's no other choice.


My hotfix is to check the block at Subject.pm line 129 to

        my $field_values = $obj->get_value( $self->{name} );
        if( defined $field_values ) {
                $field_values = [$field_values] unless( $self->get_property( "multiple" ) );
                foreach my $value ( @{$field_values} )
                {
                        foreach my $pair ( @{$allpairs} )
                        {
                                if ( $pair->[0] eq $value )
                                {
                                        unshift @{$pairs}, $pair;
                                        last;
                                }       
                        }       
                }       
        }       


(the scary part is this might be code I wrote in ages past and I can't actually remember!)


--

Christopher Gutteridge <totl@soton.ac.uk>
You should read our team blog at http://blog.soton.ac.uk/webteam/

Industrial Action

Sadly my trade union is currently in dispute over pay, pensions and casualisation. You can read more at https://www.ucu.org.uk/article/11896/Why-were-taking-action

The Southampton branch is currently working on "Action Short Of a Strike" (ASOS). This means only doing work we are contracted to do, so no working on any additional voluntary tasks. It's frustating, but so are below inflation pay rises.

As a result, so far I've had to turn down or stop working on:

  • Coordinating the iSolutions Communities of Practice program
  • Coordinating the System Documentation Community of Pracice
  • Helping with a workshop on data visualisation
  • Providing a Minecraft activity for the Archaeology family day
  • Helping another team recruit someone for a post
  • Not helped a colleague debug something in a service I'm an expert on but is no longer my responsibility

I look forward to getting back into these kinds of activity as soon as the industrial action permits.

Please do not cover for people taking ASOS. If it causes problems, it is helpful to make management aware. The most unhelpful thing is for people to mitigate the impacts of industrial action or hide it from management. The best thing to help is to join the union and the action and/or donate to the strike fund.