[LinuxLudus] Aiuto risoluzione bug nextcloud bookmarks

Flavio Toffalini flavio87@gmail.com
Mer 16 Nov 2016 10:54:16 CET


Credo che qua

AND exists( SELECT `id` FROM `oc_bookmarks`


voglia un alias dopo  `oc_bookmarks`.

Tipo

AND exists( SELECT `id` FROM `oc_bookmarks` as 'pippo'
>

quindi usare pippo anche nel resto della query.

On 16 November 2016 at 17:32, Valerio Pachera <sirio81@gmail.com> wrote:

> Hola, ho individuato un bug nella app bookmarks di nextcloud.
> Il bug non sembra essere troppo difficile da risolvere.
> Si dovrebbe trattare di un banale errore di sintassi di sql che uno più
> pratico di me dovrebbe individuare facilmente.
> La query incriminata è questa:
>
> $query = $db->prepareQuery("
> DELETE FROM `*PREFIX*bookmarks_tags` as `tgs` WHERE `tgs`.`tag` = ?
> AND exists( SELECT `id` FROM `*PREFIX*bookmarks` WHERE `user_id` = ?
> AND `tgs`.`bookmark_id` = `id`)
> AND exists( SELECT `t`.`tag` FROM `*PREFIX*bookmarks_tags` `t` where
> `t`.`tag` = ?
> AND `tgs`.`bookmark_id` = `t`.`bookmark_id`)");
>
> Sinceramente non capisco dove salta fuori `t` nel quarto AND.
>
> Tabella bookmarks
>
> [image: Immagine incorporata 1]
>
> Tabella bookmarks_tags
> [image: Immagine incorporata 2]
>
> L'errore che restiruisce nextcloud è
>
>
> {"reqId":"Q3\/GEufci9bSqiuZc\/qc","remoteAddr":"192.168.2.
> 27","app":"index","message":"Exception:
>     {\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\
> SyntaxErrorException\",\"Message\":\"An exception occurred while
> executing
>
> '\\n\\t\\t\\tDELETE FROM `oc_bookmarks_tags` as `tgs` WHERE `tgs`.`tag` =
> ?\\n\\t\\t\\t
> AND exists( SELECT `id` FROM `oc_bookmarks`
> WHERE `user_id` = ?\\n\\t\\t\\tAND `tgs`.`bookmark_id` = `id`)\\n\\t\\t\\t
> AND exists
>     ( SELECT `t`.`tag`
>     FROM `oc_bookmarks_tags` `t` where `t`.`tag` = ?\\n\\t\\t\\t
>     AND `tgs`.`bookmark_id` = `t`.`bookmark_id`)'
>     with params [\\\"test1\\\", \\\"admin\\\", \\\"test1\\\"]:\\n\\n
>
> SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error
> in your SQL syntax; check the manual that corresponds to your MariaDB
> server version for the right syntax to use near
>
> 'as `tgs` WHERE `tgs`.`tag` = 'test1'\\n\\t\\t\\tAND exists( SELECT `id`
> FROM `oc_bookmar'
>



-- 
Flavio Toffalini
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.linux.it/pipermail/ll/attachments/20161116/c2f29fc4/attachment-0001.html>
-------------- parte successiva --------------
Un allegato non testuale è stato rimosso....
Nome:        image.png
Tipo:        image/png
Dimensione:  10882 bytes
Descrizione: non disponibile
URL:         <http://lists.linux.it/pipermail/ll/attachments/20161116/c2f29fc4/attachment-0002.png>
-------------- parte successiva --------------
Un allegato non testuale è stato rimosso....
Nome:        image.png
Tipo:        image/png
Dimensione:  5063 bytes
Descrizione: non disponibile
URL:         <http://lists.linux.it/pipermail/ll/attachments/20161116/c2f29fc4/attachment-0003.png>


Maggiori informazioni sulla lista ll