<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Arial;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Corbel;
        panose-1:2 11 5 3 2 2 4 2 2 4;}
@font-face
        {font-family:"MS Gothic";
        panose-1:2 11 6 9 7 2 5 8 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:Calibri;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:Calibri;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:Calibri;
        color:windowtext;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:Calibri;
        color:#1F497D;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:Calibri;
        color:windowtext;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:Calibri;
        color:windowtext;}
span.msoIns
        {mso-style-type:export-only;
        mso-style-name:"";
        text-decoration:underline;
        color:teal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:297878341;
        mso-list-type:hybrid;
        mso-list-template-ids:1762185720 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style>
</head><body bgcolor="white" lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">OK, I think the code is confusingly written. Here’s my take:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">if ($value =~ /^[+-]?\d+$/ ) – if $value is an integer number of some (possibly with a + or – at the beginning<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">if (scalar @{$session->get_database->search_sql_ldap($value)}){ If whatever array the function returns has at least one element<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">my @check = @{$session->get_database->search_sql_ldap($value)}; Call the function again (!) to get the array<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">if(defined($check[0][0]) && defined($check[0][1])) If the first element of the array is an array that has two elements<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">my $string_build = $check[0][0] . ", " . $check[0][1]; //concatenate the two element<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">return $session->make_text( $string_build ); // turn it into a DOM element<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Aside from calling a function that almost certainly does a database query twice (rewrite is probably advisable), there’s nothing in this code that would cause an issue. My guess is that search_sql_ldap is throwing an exception. You can
go about this two ways:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="mso-list:Ignore">1)<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]>Quick and easy:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">my @check;<o:p></o:p></p>
<p class="MsoNormal">eval<o:p></o:p></p>
<p class="MsoNormal">{<o:p></o:p></p>
<p class="MsoNormal"> @check = @{$session->get_database->search_sql_ldap($value)};<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal">if (<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt">$@ //an error occured<o:p></o:p></p>
<p class="MsoNormal"> || ! (scalar @check) //empty array returned<o:p></o:p></p>
<p class="MsoNormal"> || ! $check[0][0] // no given name<o:p></o:p></p>
<p class="MsoNormal"> || ! $check[0][1] // no family name<o:p></o:p></p>
<p class="MsoNormal">)<o:p></o:p></p>
<p class="MsoNormal">{<o:p></o:p></p>
<p class="MsoNormal"> return $session->make_text($value);<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal">my $string_build = $check[0][0] . ", " . $check[0][1];<o:p></o:p></p>
<p class="MsoNormal">return $session->make_text( $string_build );<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoListParagraph" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="mso-list:Ignore">2)<span style="font:7.0pt "Times New Roman"">
</span></span><![endif]>The correct approach<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The problem with (1) approach is that it doesn’t address the underlying issue – search_sql_ldap is throwing an exception. The correct approach is to figure out why. Do you have any error output or lines in the error log associated with
this failure?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-family:"Times New Roman";color:black"> <o:p></o:p></span></p>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" style="border:none;border-top:solid #2C3841 1.0pt;padding:0cm 0cm 3.0pt 0cm">
<p class="MsoNormal"><a href="http://www.jisc.ac.uk/"><span style="font-size:12.0pt;font-family:"Times New Roman";color:blue;text-decoration:none"><img border="0" width="60" height="35" id="_x0000_i1025" src="cid:image001.png@01D23FFD.E89880B0"></span></a><o:p></o:p></p>
</td>
</tr>
<tr>
<td valign="top" style="padding:7.5pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:12.0pt;font-family:Corbel;color:#2C3841">Adam Field</span></b><span style="font-size:12.0pt;font-family:"Times New Roman""><br>
</span><span style="font-size:12.0pt;font-family:Corbel;color:#2C3841">SHERPA services analyst developer</span><o:p></o:p></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:36.0pt"><b><span style="color:black">From:
</span></b><span style="color:black"><eprints-tech-bounces@ecs.soton.ac.uk> on behalf of Andrew Beeken <anbeeken@lincoln.ac.uk><br>
<b>Reply-To: </b>"eprints-tech@ecs.soton.ac.uk" <eprints-tech@ecs.soton.ac.uk><br>
<b>Date: </b>Wednesday, 16 November 2016 10:59<br>
<b>To: </b>"eprints-tech@ecs.soton.ac.uk" <eprints-tech@ecs.soton.ac.uk><br>
<b>Subject: </b>Re: [EP-tech] Debug Creator browse view generation</span><span style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Times New Roman""><o:p> </o:p></span></p>
</div>
<p class="MsoNormal" style="margin-left:36.0pt">Thanks both!<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">It looks like the issue here is a data issue. A function in Authorid.pm has had some code added to it which checks against a database table for users which are no longer at the institution, however it doesn’t
seem to be able to cope with a user that isn’t present in that table. The function is:<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">sub get_value_label<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">{<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> my( $self, $session, $value ) = @_;<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> my $user = EPrints::DataObj::User->new( $session, $value );<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> #Checks the normal process and returns the user if found.<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> if( defined $user )<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> {<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> return $session->make_text( EPrints::Utils::make_name_string( $self->_get_name( $session, $user ) ) );<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> }<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> #If not returned with normal user checks value is a valid number and trys to pull the user from the ldap_user table instead<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> if ($value =~ /^[+-]?\d+$/ )<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> { <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> if (scalar @{$session->get_database->search_sql_ldap($value)}){ << THIS IS THE LINE THAT’S GIVING ME GRIEF!<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> my @check = @{$session->get_database->search_sql_ldap($value)};
<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> if(defined($check[0][0]) && defined($check[0][1]))<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> {<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> my $string_build = $check[0][0] . ", " . $check[0][1];<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> return $session->make_text( $string_build );<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> }<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> }<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> } <o:p>
</o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> #Otherwise just simply output the value<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> return $session->make_text( $value );<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> #return $session->make_text( "me" );<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">}<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">…and I’ve marked the problematic line of code. When it encounters an empty string instead of a scalar, the view generator goes…<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:Helvetica;color:black">¯\_(</span><span style="font-family:"MS Gothic";color:black">ツ</span><span style="font-family:Helvetica;color:black">)_/¯</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">…and falls over. Giving us no generated views. And a 500 error. Which is nice.<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">So, I think the answer is to handle that empty string and let the function carry on to the fallback of returning the value, however my knowledge of perl is less than functional at best and I really don’t want
to do any more irrevocable damage. Any thoughts would be welcome!<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">Andrew<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:36.0pt"><b><span style="mso-fareast-language:EN-GB">From:</span></b><span style="mso-fareast-language:EN-GB"> eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk]
<b>On Behalf Of </b>John Salter<br>
<b>Sent:</b> 15 November 2016 14:43<br>
<b>To:</b> eprints-tech@ecs.soton.ac.uk<br>
<b>Subject:</b> Re: [EP-tech] Debug Creator browse view generation</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="color:#1F497D">> bin/generate_views ARCHIVEID --view viewid --verbose</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="color:#1F497D">(You can do ‘--verbose --verbose’ if you really need to!).</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="color:#1F497D">Depending on where your issue lies, you might want to use one of these options too:</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="color:#1F497D">--generate menus</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="color:#1F497D">--generate lists</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="color:#1F497D">Which will be a bit quicker than a full run.</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="color:#1F497D">Cheers,</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="color:#1F497D">John</span><o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="color:#1F497D"> </span><o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:36.0pt"><b><span style="mso-fareast-language:EN-GB">From:</span></b><span style="mso-fareast-language:EN-GB">
<a href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">eprints-tech-bounces@ecs.soton.ac.uk</a> [<a href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">mailto:eprints-tech-bounces@ecs.soton.ac.uk</a>]
<b>On Behalf Of </b>Andrew Beeken<br>
<b>Sent:</b> 15 November 2016 14:26<br>
<b>To:</b> <a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a><br>
<b>Subject:</b> [EP-tech] Debug Creator browse view generation</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">Hello all!<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">So, back to that old chestnut of errors throwing in our EPrints installation (yay!) I’ve had to do some tweaks to make it read our LDAP table. Now I’m getting errors on the creator browse generation! I think I’ve
figured out where the problems are occurring however I don’t know if it’s a code issue or a data issue. Is there a way of running the view generator from the command line with –verbose so that I can see what it’s trying to do and figure out where the error
is occurring?<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">Andrew<o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.0pt;font-family:"Times New Roman";mso-fareast-language:EN-GB"><br>
<b>The University of Lincoln, located in the heart of the city of Lincoln, has established an international reputation based on high student satisfaction, excellent graduate employment and world-class research.</b></span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:7.5pt;font-family:Arial;mso-fareast-language:EN-GB"><br>
The information in this e-mail and any attachments may be confidential. If you have received this email in error please notify the sender immediately and remove it from your system. Do not disclose the contents to another person or take copies.<br>
<br>
Email is not secure and may contain viruses. The University of Lincoln makes every effort to ensure email is sent without viruses, but cannot guarantee this and recommends recipients take appropriate precautions.<br>
<br>
The University may monitor email traffic data and content in accordance with its policies and English law. Further information can be found at:
<a href="http://www.lincoln.ac.uk/legal">http://www.lincoln.ac.uk/legal</a>.</span><o:p></o:p></p>
</div>
</div>
<font size="1"> <font face="Corbel"> <br />
Jisc is a registered charity (number 1149740) and a company limited by guarantee which is registered in England under Company No. 5747339, VAT No. GB 197 0632 86. Jisc’s registered office is: One Castlepark, Tower Hill, Bristol, BS2 0JA. T 0203 697 5800.<br /><br />
Jisc Services Limited is a wholly owned Jisc subsidiary and a company limited by guarantee which is registered in England under company number 2881024, VAT number GB 197 0632 86. The registered office is: One Castle Park, Tower Hill, Bristol BS2 0JA. T 0203 697 5800.
</font></font></body></html>