Ignore:
Timestamp:
2018-11-09T19:01:04+13:00 (5 years ago)
Author:
ak19
Message:
  1. gssql destructor DESTROY doesn't really do anything now, as DBI's destructor will ensure disconnection if not already disconnected. So we don't disconnect in gssql DESTROY, which we used to do but which would only happen on Cancel specifically as other gssql code would already disconnect on natural termination. 2. gssql no longer sets connection parameter fallbacks for those that have fallbacks, since the defaults for these parameters are set by the GS SQL Plugs' configuration options. 3. No need to (html) escape meta/full text when storing in DB or unescape when reading it out of DB, since DB is like a regular text file: can just put text in there. It's only html/xml files where text needs to be stored escaped. 4. Having committed doc.pm::add_utf8_textREF() method in previous commit, GreenstoneSQLPlugin can now pass the fulltxt by reference using this method when constructing the doc_obj from what's read in from the DB.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugouts/GreenstoneSQLPlugout.pm

    r32589 r32591  
    4141# + TODO: SIGTERM rollback and disconnect?
    4242# + TODO Q: what about verbosity for debugging, instead of current situation of printing out upon debug set at the expense of writing to db
    43 #X TODO Q: introduced site param to plugins and plugouts. Did I do it right? And should they have hiddengli = "yes". No longer a param
    44 # Did I do the pass by ref in docprint's escape and unescape textref functions correctly, and how they're called here?
     43#+ TODO Q: introduced site param to plugins and plugouts. Did I do it right? And should they have hiddengli = "yes". No longer a param
     44# !!!! Did I do the pass by ref in docprint's escape and unescape textref functions correctly, and how they're called here?
    4545#   Any more optimisation I can do around this?
    4646
     
    8888      'type' => "enum",
    8989      'list' => $rollback_on_cancel_list,
    90       'deft' => "false", # TODO Q: what's the better default? If "true", any memory concerns?
     90      'deft' => "false", # better default than true
    9191      'reqd' => "no",
    9292      'hiddengli' => "no"},
     
    105105      'type' => "string",
    106106      'deft' => "",
    107       'reqd' => "no"}, # pwd required? NO.
     107      'reqd' => "no"}, # pwd not required: can create mysql accounts without pwd
    108108    { 'name' => "db_host",
    109109      'desc' => "{GreenstoneSQLPlug.db_host}",
    110110      'type' => "string",
    111       'deft' => "127.0.0.1",
     111      'deft' => "127.0.0.1", # localhost doesn't work for us, but 127.0.0.1 works. See gsmysql.pm
    112112      'reqd' => "yes"},
    113113    { 'name' => "db_port",
     
    347347        # TODO: does it need to be stored escaped, as it requires unescaping when read back in
    348348        # from db (unlike for reading back in from doc.xml)
    349         my $escaped_meta_value = &docprint::escape_text($data->[1]);
     349
     350        # Treat db like a text file instead of an html/xml file: don't need to escape text
     351        # going into it
     352        #my $escaped_meta_value = &docprint::escape_text($data->[1]);
     353        my $meta_value = $data->[1];
    350354       
    351355        # Write out the current section's meta to collection db's METADATA table       
     
    356360        # OR if debugging, then it will print the SQL insert statement but not execute it
    357361       
    358         $gs_sql->insert_row_into_metadata_table($doc_oid, $section_name, $meta_name, $escaped_meta_value, $self->{'debug'});
     362        $gs_sql->insert_row_into_metadata_table($doc_oid, $section_name, $meta_name, $meta_value, $self->{'debug'});
    359363    }
    360364    }
     
    362366   
    363367    if($proc_mode eq "all" || $proc_mode eq "text_only" ) {
    364    
    365     my $section_textref = &docprint::escape_textref(\$section_ptr->{'text'});
     368
     369    # See above, no need to html-escape for db
     370    my $section_text = $section_ptr->{'text'}; #&docprint::escape_textref(\$section_ptr->{'text'});
    366371   
    367372    # fulltxt column can be SQL NULL. undef value gets written out as NULL:
     
    369374    # The following will do the SQL insertion
    370375    # or if debug, the following will print the SQL insert stmt without executing it
    371     $gs_sql->insert_row_into_fulltxt_table($doc_oid, $section_name, $section_textref, $self->{'debug'});
     376    $gs_sql->insert_row_into_fulltxt_table($doc_oid, $section_name, \$section_text, $self->{'debug'});
    372377   
    373378    }
Note: See TracChangeset for help on using the changeset viewer.