Bugzilla – Attachment 28113 Details for
Bug 9048
Quote editor does not work under Plack
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9048 - fix quote editor under Plack
Bug-9048---fix-quote-editor-under-Plack.patch (text/plain), 3.00 KB, created by
Jonathan Druart
on 2014-05-08 15:55:15 UTC
(
hide
)
Description:
Bug 9048 - fix quote editor under Plack
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-05-08 15:55:15 UTC
Size:
3.00 KB
patch
obsolete
>From 4244bace5d6dbf02be56f30e69b02390dd8c9049 Mon Sep 17 00:00:00 2001 >From: Robin Sheat <robin@catalyst.net.nz> >Date: Wed, 30 Apr 2014 15:33:44 +1200 >Subject: [PATCH] Bug 9048 - fix quote editor under Plack > >The ajax responder for the quote editor was using the wrong error codes. >These have been fixed. Also, a small fixup to get rid of some annoying >warnings. > >To test: >* Under plack, >* Add/edit/delete a quote. >* Make sure that things don't crash. > >Signed-off-by: Galen Charlton <gmc@esilibrary.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >--- > tools/quotes/quotes_ajax.pl | 21 +++++++++++---------- > 1 file changed, 11 insertions(+), 10 deletions(-) > >diff --git a/tools/quotes/quotes_ajax.pl b/tools/quotes/quotes_ajax.pl >index da5dc01..5f44a7e 100755 >--- a/tools/quotes/quotes_ajax.pl >+++ b/tools/quotes/quotes_ajax.pl >@@ -48,43 +48,44 @@ my $params = $cgi->Vars; # NOTE: Multivalue parameters NOT allowed!! > > print $cgi->header('application/json; charset=utf-8'); > >-if ($params->{'action'} eq 'add') { >+my $action = $params->{'action'} || 'get'; >+if ($action eq 'add') { > my $sth = $dbh->prepare('INSERT INTO quotes (source, text) VALUES (?, ?);'); > $sth->execute($params->{'source'}, $params->{'text'}); > if ($sth->err) { > warn sprintf('Database returned the following error: %s', $sth->errstr); >- exit 0; >+ exit 1; > } > my $new_quote_id = $dbh->{q{mysql_insertid}}; # ALERT: mysqlism here > $sth = $dbh->prepare('SELECT * FROM quotes WHERE id = ?;'); > $sth->execute($new_quote_id); > print to_json($sth->fetchall_arrayref, {utf8 =>1}); >- exit 1; >+ exit 0; > } >-elsif ($params->{'action'} eq 'edit') { >+elsif ($action eq 'edit') { > my $aaData = []; > my $editable_columns = [qw(source text)]; # pay attention to element order; these columns match the quotes table columns > my $sth = $dbh->prepare("UPDATE quotes SET $editable_columns->[$params->{'column'}-1] = ? WHERE id = ?;"); > $sth->execute($params->{'value'}, $params->{'id'}); > if ($sth->err) { > warn sprintf('Database returned the following error: %s', $sth->errstr); >- exit 0; >+ exit 1; > } > $sth = $dbh->prepare("SELECT $editable_columns->[$params->{'column'}-1] FROM quotes WHERE id = ?;"); > $sth->execute($params->{'id'}); > $aaData = $sth->fetchrow_array(); > print Encode::encode('utf8', $aaData); > >- exit 1; >+ exit 0; > } >-elsif ($params->{'action'} eq 'delete') { >+elsif ($action eq 'delete') { > my $sth = $dbh->prepare("DELETE FROM quotes WHERE id = ?;"); > $sth->execute($params->{'id'}); > if ($sth->err) { > warn sprintf('Database returned the following error: %s', $sth->errstr); >- exit 0; >+ exit 1; > } >- exit 1; >+ exit 0; > } > else { > my $aaData = []; >@@ -97,7 +98,7 @@ else { > $sth->execute(); > if ($sth->err) { > warn sprintf('Database returned the following error: %s', $sth->errstr); >- exit 0; >+ exit 1; > } > > $aaData = $sth->fetchall_arrayref; >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9048
:
27791
|
27987
| 28113