Skip to content

Commit

Permalink
Item877: Debian lib-perl-sqlite package bug, made a workarround
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/DBConnectorPlugin@2203 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
EugenMayer authored and EugenMayer committed Jan 28, 2009
1 parent 3353cf7 commit a4acd57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion data/System/DBConnectorPlugin.txt
Expand Up @@ -137,8 +137,9 @@ __Note:__ You do not need to install anything on the browser to use this plugin.
| Plugin Author: | Foswiki:Main.EugenMayer |
| Copyright: | © Impressive.media |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Plugin Version: | 18 Dez 2008 (V0.6) |
| Plugin Version: | 28 Jan 2009 (V0.7) |
| Change History: | <!-- versions below in reverse order --> |
| 28 Jan 2009: | Made a workarround for the bug in the debian(etch stable) lib-perl-sqlite package, which yet fails on named binding due this bug |
| 22 Dez 2008: | Fixed editing with the WYSIWYG Editor, content is now saved with TML syntax like topics are |
| 17 Dez 2008: | * Fixed some bugs. Also disabled the locking, because if something is locked, and "i try anyway" the redirect is wrong%BR% * generalized createDB to be able to use other topics for creation of tables%BR% * added form on the plugin-topic to be easy able to create tables for webs|
| 17 Dez 2008: | * added access checks, so users can`t change data for a topic in the database, if they have CHANGE rights on the topic inf foswiki%BR% * Added default Field-Editor User Interface to edit fields of a topic with the WYSIWYG out of the box, respectfully added handler for that. This UI is build to be reused and is customizeable%BR% * Added locking/unlockin topics when fields are edited%BR% * Added Macro to show Edit-Button and to display Field-Values in topics%BR% * createDB is now more secure, only allowed to admins anymore|
Expand Down
22 changes: 12 additions & 10 deletions lib/Foswiki/Plugins/DBConnectorPlugin.pm
Expand Up @@ -37,7 +37,7 @@ $VERSION = '$Rev: 12445$';
# This is a free-form string you can use to "name" your own plugin version.
# It is *not* used by the build automation tools, but is reported as part
# of the version number in PLUGINDESCRIPTIONS.
$RELEASE = '0.6';
$RELEASE = '0.7';

# Short description of this plugin
# One line description, is shown in the %FoswikiWEB%.TextFormattingRules topic:
Expand Down Expand Up @@ -129,7 +129,7 @@ sub getValues {
_warn("could not send query, maybe table missing?");
return undef;
}
$qryobj->execute()
eval { $qryobj->execute(); }
or _warn( "could not send query: $qry, error:" . $qryobj->err );
my $result = $qryobj->fetchrow_hashref();

Expand Down Expand Up @@ -164,9 +164,9 @@ updateValues("System",'WebHome',\%pairs);
sub updateValues {
my $web = shift;
my $topic = shift;
my $fiedValuePairs = shift;
my $fieldValuePairs = shift;
my $checkAccess = shift || 1;
_debug( "Updating values inserted", keys %{$fiedValuePairs} );
_debug( "Values to update", keys %{$fieldValuePairs} );

#checking acces if i have to. Also checking if the table exists
if ( $checkAccess && !_hasAccess("CHANGE") ) {
Expand All @@ -176,23 +176,25 @@ sub updateValues {
}
_createEntryForTopicIfNotExitent( $web, $topic );

# craete a field list with placeholder(?), while each field is surrounded by `
my $values = "`" . join( "`=?,`", keys %{$fiedValuePairs} ) . "`=?";
# craete a field list with placeholder(?), while each field is surrounded by `
my $values = join ( ',',
map( { "`$_`='$fieldValuePairs->{$_}'" } keys %{$fieldValuePairs} )
);
my $qry = qq(UPDATE $web SET $values WHERE `$TableKeyField`='$topic' );

_debug("Query: $qry");
my $qryobj = eval { $DBC_con->prepare($qry) };
unless ($qryobj) {
_warn( "could not prepare qry, table missing? \nerror:"
. $DBC_con->errstr );
return;
return ();
}

# now insert the values for the placeholders into the query
eval { $qryobj->execute( values %{$fiedValuePairs} ) }
eval { $qryobj->execute(); }
or _warn(
"could not insert values for $web.$topic \nerror:" . $DBC_con->errstr,
values %{$fiedValuePairs} );
values %{$fieldValuePairs} );
$qryobj->finish();
_debug("Values upated");
}
Expand Down Expand Up @@ -484,7 +486,7 @@ sub _updateLinksInString {
}

sub _debug {
return if !$Foswiki::cfg{Plugins}{DBConnectorPlugin}{Debug};
# return if !$Foswiki::cfg{Plugins}{DBConnectorPlugin}{Debug};
my ( $message, @param ) = @_;

Foswiki::Func::writeDebug( "[DBConnectorPlugin]:" . $message );
Expand Down

0 comments on commit a4acd57

Please sign in to comment.