bookmarks icon indicating copy to clipboard operation
bookmarks copied to clipboard

bookmark import failing

Open mmehnert opened this issue 13 years ago • 33 comments

OC 5 fails to import my bookmark html-file that I exported from firefox. Anyone else having problems?

When it happens, I only get

SQLSTATE[22001]: String data, right truncated: 7 ERROR:  value too long for type character varying(140) at [...]/lib/db.php#1031

in the log

From the bookmark app code I guess that's a problem with the bookmark title. Any particular reason the title does not have a maximum size of 4k, too?

mmehnert avatar Jul 13 '13 16:07 mmehnert

bump, for great justice.

having same problem importing bookmarks file from firefox (and del.icio.us)

OC 5.0.9 Apache 2.2.22 PostgreSQL 9.1ish debian jesse/wheezy

owncloud.log: ==> /srv/owncloud/data/owncloud.log <== {"app":"PHP","message":"SQLSTATE[22001]: String data, right truncated: 7 ERROR: value too long for type character varying(140) at /var/www/owncloud/lib/db.php#1031","level":4,"time":1375140105}

ghost avatar Jul 29 '13 23:07 ghost

In effect as @mmehnert guessed, titles length are limited to 140 chars long. I don't think there is a particular reason for that and moreover it should be an easy fix.

desyncr avatar Aug 29 '13 11:08 desyncr

+1

giovanisp avatar Oct 06 '13 09:10 giovanisp

this same error still occurs on oc 6.0.3

Doctrine\DBAL\DBALException: An exception occurred while executing ' INSERT INTO "oc_bookmarks" ("url", "title", "user_id", "public", "added", "lastmodified", "description") VALUES (?, ?, ?, ?, date_part('epoch',now())::integer, date_part('epoch',now())::integer, ?) ': SQLSTATE[22001]: String data, right truncated: 7 FEHLER: Wert zu lang fĂĽr Typ character varying(140)

is it save to manually edit the table to allow the tuple to be bigger?

cabbage avatar May 02 '14 10:05 cabbage

the problem still persists while trying to import bookmarks from a html file - doesn't matter if ff or chrome export . OC 7.0.2 postgresql 9.3 ubuntu 12.04 php 5.4. are there no plans to fix this in a future release or patch?

Fatal index Doctrine\DBAL\DBALException: An exception occurred while executing ' INSERT INTO "oc_bookmarks" ("url", "title", "user_id", "public", "added", "lastmodified", "description") VALUES (?, ?, ?, ?, date_part('epoch',now())::integer, date_part('epoch',now())::integer, ?) ': SQLSTATE[22001]: String data, right truncated: 7 FEHLER: Wert zu lang fĂĽr Typ character varying(140)

cwm77 avatar Oct 20 '14 13:10 cwm77

Well, as for now, the 140 character limit is still here https://github.com/owncloud/bookmarks/blob/master/appinfo/database.xml#L30

I see 2 possibilities :

  1. increase that value (but to how much ? A title can be veeeeery long…) but the error can still persist.
  2. trim the title to 140 here : https://github.com/owncloud/bookmarks/blob/master/controller/lib/bookmarks.php#L524 $title = substr($link->nodeValue, 0, 140);

Actually, you can mix them :laughing: but I'm new here, who takes that kind of decision?

Chouchen avatar Mar 09 '15 22:03 Chouchen

@Chouchen Or we can completely remove this limit ? :) We are talking about bookmark imports, that is to say already-existing bookmarks. Those already existing bookmarks have been saved in a certain way. Thus, their titles might had already been changed/set by the user according to his will... So... Shouldn't we just remove this title limit ?

TtuxX avatar Mar 11 '15 01:03 TtuxX

@TtuxX I'm no database expert but I think they already have limits for text type which are differents depending on the choosen database type. I think we need to control that limit.

And I'm pretty new to owncloud dev but maybe the database.xml needs a length node.

Chouchen avatar Mar 11 '15 08:03 Chouchen

Error persists in OC 8.0.2 (ubuntu 14.04.2, postgresql 9.3). Pages with title longer than 140 characters can not be saved. I resolved this changing tytle in oc_bookmarks table from character varying(140) to character varying(4096) Page can be saved now.

Scorry avatar Apr 02 '15 07:04 Scorry

Until title is more than 4096 characters. Why that limit and not another? If you got sources, I'm interested. Even more, if those sources say title can't be more than 4096 characters, you could do a PR changing the database.xml file :)

Chouchen avatar Apr 02 '15 08:04 Chouchen

It was not a reasonable choice. Just copied length from url parameter — say, just a big enough. For a references: W3C does not limit length of title of the page, but determine that "The title should ideally be less than 64 characters in length. ..." (The TITLE element in HTML) In my humble opinion the length of the stored title need to be checked and trimmed in excess, but I don't know how, sadly. I can edit db instead :) 140 characters may be quite enough for ASCII, but may be not enough for UTF. Well, may be long titles must be trimmed and full title must be copied in description field?.. User can decide how to deal with it.

Scorry avatar Apr 02 '15 08:04 Scorry

Mmmm I think you have a great idea.

  • Trim to 64 characters to comply to recommandations (or 140 to copy twitter and to stay backward compatible)
  • Put the full title in description (if empty)

We need to have feedback on this!

Chouchen avatar Apr 02 '15 10:04 Chouchen

Well, great decision. I'll vote for it if necessary. P.S. And your patch for tags.

Scorry avatar Apr 02 '15 13:04 Scorry

@Scorry @Chouchen Very nice ideas, I would agree on the 140 characters titles triming, however I think there would still be some issues... which are making me thinking that the very large 4096 characters title limit could be a yet imperfect (but simple) temporary "solution". How would you plan dealing with:

  • Import of bookmarks with long titles ? Should we import them, trim their title and automatically write their full titles as description if the description field is empty ? If description field is not empty, how should bookmarks app behaves ? If we do not modify description text, then finally nothing would apparently change from the current bookmarks app version behavior... :(
  • If title is longer than 140 characters, if description field is empty, and if in such case you automatically copy the full-lenght title to the description field, then the app "default" behavior result will make us end-up with exactly the same title and description beginnings... It might not looks very attractive and clean.. This will also mean that user will systematically have to check/delete/modify description field when adding a new bookmark...

What are your opinions/ideas regarding the possible ways to solve these problems ? :)

TtuxX avatar Apr 03 '15 00:04 TtuxX

@TtuxX :

Import of bookmarks with long titles ? Should we import them, trim their title and automatically write their full titles as description if the description field is empty ?

... and otherwise check if full title plus newline plus existing description fit in 4096 and write it, if not — silently trim title portion in description, may be separate from old description by some recognizable symbol — for example, asterisk or |.

Or, as you remark,

This will also mean that user will systematically have to check/delete/modify description field when adding a new bookmark...

It may be a matter of user's choice. May be some options in app settings “how to deal with long titles”.

Scorry avatar Apr 03 '15 08:04 Scorry

I have no use for such a long title field and since i do not care about storing the rest of it personally I just edited bookmarks.php line 462+ (OC 8.0.2)

$params = array(
                                $enc_url,
                                htmlspecialchars_decode($title),
                                $userid,
                                $public,
                                $description,
);

and changed it to this:

$params = array(
                                $enc_url,
                                substr(htmlspecialchars_decode($title), 0, 140),
                                $userid,
                                $public,
                                $description,
);

Probably should do something similar with the description too but well that seems to not be a problem.

would be easy enough to copy the rest to description if that is empty but imho titles that long are a pain anyway ^^

LordVan avatar Apr 09 '15 09:04 LordVan

yeah, there are a lot of places you can do a substr() to "solve" this. Anyway, we're trying to make a solution everyone could enjoy :-)

You should do a PR with that modification. That way, people in charge of this project could choose that solution in the end if that's what people wants.

Chouchen avatar Apr 09 '15 09:04 Chouchen

@Chouchen yeah i just thought i'd paste it in here in case someone wants to do that rather than mess with the db ^^.. if i can be bothered i might just add the part to copy the rest to the description field .. but my motivation is rather low for this haha

also it seems - correct me if i am wrong - that there is at least no active maintainer for this app :(

Personally i'd not just use substr. on the title if it was too long, but rather make sure it is split after a word then put some "..." there and put the rest of the title in the description

In fact it might even be better to deal with this on the javascript side. that way the user can just be asked.. also the function that deals with it in bookmarks.js seems to completely ignore the fact there could be an error ...

LordVan avatar Apr 09 '15 09:04 LordVan

Unfortunatly, you may be right about the lack of maintainer. Anyway, a clean PR with a commit message containing "fix #29" would appear here and be clearer IMHO.

Chouchen avatar Apr 09 '15 11:04 Chouchen

Well if I feel like (and have time) doing this properly instead of just one substr() then i guess i might as well do that .. just for one line i don't want to start reading git howtos/manuals again ^^

LordVan avatar Apr 09 '15 11:04 LordVan