EPrints Technical Mailing List Archive

Message: #08976


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

Re: [EP-tech] Bug in Subject.pm?


Hi Chris,

I think this bug is the same as one I listed on the EPrints 3.4.3 release page:

https://wiki.eprints.org/w/index.php?title=EPrints_3.4.3#Non-multiple_Subject_field_causes_an_internal_server_error

There is a patch to fix this issue:

https://github.com/eprints/eprints3.4/commit/41f6f199d7abb753a3d180aabde6a0c482825ff8

The history behind this was to try to solve the problem with fields set as undepositable disappearing unexpectedly from old items, if they happened to be edited to change something else in the same stage.  The code change for 3.4.3 was intended to fix this but inadvertently broke non-multiple subject fields like yours.  Here is the GitHub issue that relates to this original problem and then the later resolution to this unintended side effect:

https://github.com/eprints/eprints3.4/issues/144

As this bug was fixed back in September 2021, it is also fixed in EPrints 3.4.4, which is to be released soon.

Regards

David Newman


On 14/06/2022 15:31, Christopher Gutteridge via Eprints-tech wrote:

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.


*** 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/