[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[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 at 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://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ucu.org.uk%2Farticle%2F11896%2FWhy-were-taking-action&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cd19b0b601b5448a2f12808da4e129494%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637908138948264704%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Mj3Ilpl43%2FL1en21RgKEisjmd9giXK%2B9tEzfrrkqU%2FU%3D&reserved=0
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20220614/557a7a37/attachment.html