EPrints Technical Mailing List Archive

Message: #04814


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

[EP-tech] Re: Possible bug in title_duplicates script?


Ah,

And of course the obvious solution would be to change the location of the first AND statement, so a patch similar to this:

    $sql .= " $Q_eprint_status=" .  $db->quote_value( "archive" ) . " AND ";

--- ./cgi/users/lookup/title_duplicates    2015-04-17 19:07:54.000000000 +0300
+++ /tmp/title_duplicates    2015-09-30 10:45:40.510270944 +0300
@@ -71,9 +71,9 @@
     " FROM $Q_table" .
     " WHERE ";
 if ($dataset_name eq "eprint") {
-    $sql .= " $Q_eprint_status=" .  $db->quote_value( "archive" );
+    $sql .= " $Q_eprint_status=" .  $db->quote_value( "archive" ) . " AND ";
 }
-$sql .=    " AND $Q_id!=$id" .
+$sql .=    "$Q_id!=$id" .
     " AND $Q_field_name IS NOT NULL" .
     " AND $Q_field_name " .
     $db->sql_LIKE() .


Before opening a bug report in EPrints' github, please someone do confirm that what I'm suggesting is not breaking things instead of fixing them.

Cheers,

George.

On 29/09/2015 04:23 μμ, George Mamalakis wrote:
Hello everyone,

I'm trying to see if the autocompletion feature works OK with my multilang fields (like title), and by inspecting script's code, I saw this in lines 70-80:

my $sql = "SELECT $Q_id" .
    " FROM $Q_table" .
    " WHERE ";
if ($dataset_name eq "eprint") {
    $sql .= " $Q_eprint_status=" .  $db->quote_value( "archive" );
}
$sql .= " AND $Q_id!=$id" .
    " AND $Q_field_name IS NOT NULL" .
    " AND $Q_field_name " .
    $db->sql_LIKE() .
    $db->quote_value( EPrints::Database::prep_like_value( $q ) . '%' );


As we can see, and if I'm not terribly mistaken, if $dataset_name neq "eprint", then the SQL WHERE statement is immediately followed by an AND statement, which would cause SQL to fail.

Am I missing something here or is it really a potential bug on non records not belonging to the "eprint" dataset (not sure how it would be triggered though)?

-- 
George Mamalakis

IT and Security Officer, 
Electrical and Computer Engineer (Aristotle Univ. of Thessaloniki),
PhD (Aristotle Univ. of Thessaloniki),
MSc (Imperial College of London)

School of Electrical and Computer Engineering
Aristotle University of Thessaloniki

phone number : +30 (2310) 994379




*** 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/
*** EPrints developers Forum: http://forum.eprints.org/


-- 
George Mamalakis

IT and Security Officer, 
Electrical and Computer Engineer (Aristotle Univ. of Thessaloniki),
PhD (Aristotle Univ. of Thessaloniki),
MSc (Imperial College of London)

School of Electrical and Computer Engineering
Aristotle University of Thessaloniki

phone number : +30 (2310) 994379