[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[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://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.eprints.org%2Fw%2Findex.php%3Ftitle%3DEPrints_3.4.3%23Non-multiple_Subject_field_causes_an_internal_server_error&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cebfb20af0d2f48afe75c08da4e179567%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637908160434425021%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=kCOyIWWBvyOJylUIUtSV7Tpn6ycx3XO%2FEhAYcESRPD8%3D&reserved=0
There is a patch to fix this issue:
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprints%2Feprints3.4%2Fcommit%2F41f6f199d7abb753a3d180aabde6a0c482825ff8&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cebfb20af0d2f48afe75c08da4e179567%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637908160434425021%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=W0yPYGRhEEXcSQak0gmYbGhZwWC7%2BqPxXvLipuBRTMo%3D&reserved=0
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://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprints%2Feprints3.4%2Fissues%2F144&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cebfb20af0d2f48afe75c08da4e179567%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637908160434425021%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=gwLsqCDJDcxB1MDEGEKyoYEBEZtaH0B7eczHRxhGG1A%3D&reserved=0
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 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%7Cebfb20af0d2f48afe75c08da4e179567%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637908160434425021%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=4QkWtBgtKdNVXFGPSFocgWFHtJ5kCCZ8IteUdb2zmxQ%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.
>
>
> *** Options:http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive:https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cebfb20af0d2f48afe75c08da4e179567%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637908160434425021%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3PlScRaz6P8HPO5nlBzPB8cOy2fSaPCl%2FDXDzMcOdL0%3D&reserved=0
> *** EPrints community wiki:https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&data=05%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7Cebfb20af0d2f48afe75c08da4e179567%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637908160434425021%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=tDBuLOHwH05Ejz1bHgKUN2DbVaut4%2BvCVmpIouXJb4w%3D&reserved=0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20220614/11e4fc35/attachment-0001.html