#1 2023-12-21 16:11:28

OpenPicture
Member
2023-12-19
57

Emoji icons used in comments result in the comment being lost

Hello,

As I don't think I was in the topic of the title anymore ( https://piwigo.org/forum/viewtopic.php? … 92#p188592 ), I will use this topic to report a bug in the commenting section of Piwigo.

Emoji symbols used in comments result in the comment not being displayed at all, not even on the Piwigo admin page.
Users often complain that they made a comment with Apple icons or other emojis in vain because they lost what they wrote.

That is what happens in Piwigo 14.0 with PHP 7.4. In Piwigo 14.0 with PHP 8.1 I get even a blank page when I use an Apple Emoji and I have to remove it in order to have it accepted.

Last edited by OpenPicture (2023-12-21 16:20:15)

Offline

 

#2 2023-12-22 00:45:40

executive
Member
2017-08-16
1236

Re: Emoji icons used in comments result in the comment being lost

emojis are 4 byte symbols.

Your piwigo database might not support 4-byte characters, so you would need to turn on the feature in your SQL software and convert the database.
But I'm not sure if piwigo software is built to handle that.

Offline

 

#3 2023-12-22 00:54:43

OpenPicture
Member
2023-12-19
57

Re: Emoji icons used in comments result in the comment being lost

Hello executive,

Thank you for taking the time to read this.

This is exactly what I wanted to know in the other topic :
https://piwigo.org/forum/viewtopic.php? … 92#p188592

Maybe that Pierrick Le Gall (plg) could help us find the answer?

Offline

 

#4 2023-12-22 02:51:00

executive
Member
2017-08-16
1236

Re: Emoji icons used in comments result in the comment being lost

The devs read the forum. I'm sure if you're patient you'll get a response.

Offline

 

#5 2023-12-22 11:03:18

OHappyDay
Member
2023-02-08
194

Re: Emoji icons used in comments result in the comment being lost

Piwigo is able to handle utf8mb4 databases.

The MySQL database for my piwigo installation is configured with utf8mb4 (which is the version that handles 4 byte characters) and it is running without problems (although I do not use comments that could contain emojis).

Klaus

Offline

 

#6 2023-12-22 15:03:31

OpenPicture
Member
2023-12-19
57

Re: Emoji icons used in comments result in the comment being lost

Hi Klaus,

Thanks a lot for confirming that You run Piwigo with utf8mb4.

Could You tell me which Type (MyISAM,InnoDB) and which Collation (utf8mb4_general_ci?) you have?

You may be right that it depends on the hoster whether it has been setup with utf8mb4 or utf8mb3, because I installed Piwigo in 2016 on another server.

Could You also look if in functions_mysqli.inc.php  You have:
$db_charset = 'utf8'; :
"* Set charset for database connection. */
function pwg_db_check_charset()
{
  global $mysqli;
  $db_charset = 'utf8';
  if (defined('DB_CHARSET') and DB_CHARSET != '')
  {
    $db_charset = DB_CHARSET;
  }
  $mysqli->set_charset($db_charset);
}"

Many thanks,
Patrick.

Offline

 

#7 2023-12-22 21:33:36

OpenPicture
Member
2023-12-19
57

Re: Emoji icons used in comments result in the comment being lost

Hi Klaus,

I have just reinstalled Piwigo in one of my subdomains to test its compatibility with utf8mb4.
The Piwigo installation installs with a database with utf8mb3_general_ci, which I converted globally to utf8mb4_general_ci.

Database server
    •    Server: Localhost via UNIX socket
    •    Server type: MySQL
    •    Server connection: SSL is not being used
    •    Server version: 8.0.35-cll-lve - MySQL Community Server - GPL
    •    Protocol version: 10
    •    User: xxxxxxxxxx@localhost
    •    Server charset: UTF-8 Unicode (utf8mb4)

Web server
    •    cpsrvd 11.114.0.15
    •    Database client version: libmysql - mysqlnd 8.1.25
    •    PHP extension: mysqli  curl  mbstring
    •    PHP version: 8.1.25

At first it looked as if Piwigo was running normally, but then the first attempt to comment with an Apple emoji resulted in an error message:

Fatal error: Uncaught mysqli_sql_exception: Incorrect string value: '\xF0\x9F\x91\x8D' for column 'content' at row 1 in /piwigo/include/dblayer/functions_mysqli.inc.php:132
Stack trace: #0 /piwigo/include/dblayer/functions_mysqli.inc.php(132): mysqli->query('\nINSERT INTO pi...')
#1 /piwigo/include/functions_comment.inc.php(229): pwg_query('\nINSERT INTO pi...')
#2 /piwigo/include/picture_comment.inc.php(43): insert_user_comment(Array, '1703273083.8:3:...', Array)
#3 /piwigo/picture.php(1010): include('/home/patricks/...')
#4 {main} thrown in /piwigo/include/dblayer/functions_mysqli.inc.php on line 132

In addition, the following error messages appeared immediately after the new installation:

Deprecated: Using php-function "trim" as a modifier is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier. in /piwigo/include/smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php on line 114

Deprecated: Using php-function "strtolower" as a modifier is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier. in /piwigo/include/smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php on line 114

Deprecated: Using php-function "md5" as a modifier is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier. in /piwigo/include/smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php on line 114

And after I installed some plugins, all of which also install subsequently with utf8mb3_general_ci:

Warning: Undefined array key "Whois" in /piwigo/_data/templates_c/p6jhns^cbb74f57550c0552ce81411583341d914d079f1e_0.file.default.tpl.php on line 25

Warning: Attempt to read property "value" on null in /piwigo/_data/templates_c/p6jhns^cbb74f57550c0552ce81411583341d914d079f1e_0.file.default.tpl.php on line 25

Warning: Trying to access array offset on value of type null in /piwigo/_data/templates_c/p6jhns^cbb74f57550c0552ce81411583341d914d079f1e_0.file.default.tpl.php on line 25

With so many error messages from a new installation that I have just made, I would rather wait for the devs to make Piwigo compatible with PHP 8.

So when it comes to using utf8mb4 and using emoji in comments, I'm going to test my patience even further. The emoji errors were there with my very first installation in 2016 and with every Piwigo update I hoped my patience would have been worth it ;).

Have a nice Weekend,
Patrick

Offline

 

#8 2023-12-29 16:22:51

OpenPicture
Member
2023-12-19
57

Re: Emoji icons used in comments result in the comment being lost

Adding an Apple Emoji in Piwigo 14.1.0 still gives the following error, a blank page and the loss of the written comment:

PHP Fatal error:  Uncaught mysqli_sql_exception: Incorrect string value: '\xF0\x9F\x91\x8D' for column 'content' at row 1 in /include/dblayer/functions_mysqli.inc.php:132
Stack trace:
#0 /include/dblayer/functions_mysqli.inc.php(132): mysqli->query('\nINSERT INTO ko...')
#1 /include/functions_comment.inc.php(229): pwg_query('\nINSERT INTO ko...')
#2 /include/picture_comment.inc.php(43): insert_user_comment(Array, '1703863036.3:3:...', Array)
#3 /picture.php(1010): include('/home/...')
#4 {main}
  thrown in /include/dblayer/functions_mysqli.inc.php on line 132

Environment
Piwigo 14.1.0 Check for upgrade
Installed on 26 November 2016, 7 years 1 month 3 days ago
Operating system: Linux
PHP: 8.1.26 (Show info) [2023-12-29 15:21:41]
MySQL: 8.0.35-cll-lve [2023-12-30 04:21:41]
Graphics Library: ImageMagick 6.9.12-93
Cache size 1734.46 Mo   calculated 48 minutes ago Refresh

Activated plugin list 31
Add < head > element
Additional Pages
Advanced Menu Manager
Change who added photo
Community
Crypto Captcha
Edit Filename
Embedded Videos
Extended Description
Grum Plugins Classes.3
GThumb+
Header Manager
Language Switch
LocalFiles Editor
Media Icon
Meta Open Graph
Most Commented
Permalink Generator
Perso Footer
Personal Favicon
Personal Plugin
Photo Update
Posted Date Changer
PWG Stuffs
Rotate Image
RV Thumb Scroller
SmartAlbums
Smilies Support
Stop Spammers
user delete photo
User Tags

Offline

 

#9 2024-06-02 14:10:11

lylian
Member
2024-06-02
1

Re: Emoji icons used in comments result in the comment being lost

Hi maybe this subject is old... I registered first to post my solution.

I finally got it to work after some days of research.

I don't know if Apple emojis work or not but the solution I used is different from yours.

I followed this page and your advertisement

1. https://stackoverflow.com/questions/371 … alue-error
2. Then I set "set_charset" as charset int "$db_charset" variable in "functions_mysqli.inc.php" file.

Lylian.

Offline

 

#10 2024-11-03 14:09:40

OpenPicture
Member
2023-12-19
57

Re: Emoji icons used in comments result in the comment being lost

Does Piwigo 15.0 support utf8mb4 ?

Because I converted my database connection (ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;), Table Collations (ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;) and Column Collations (ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;).

After that I changed in /local/config/database.inc.php the existing lines

(define('PHPWG_INSTALLED', true);
define('PWG_CHARSET', 'utf-8');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');)

into

(define('PHPWG_INSTALLED', true);
define('PWG_CHARSET', 'utf-8');
define('DB_CHARSET', 'utf8mb4');
define('DB_COLLATE', '');  // Optional: specify collation define('DB_COLLATE', 'utf8mb4_general_ci'); , or leave it as '').

After that emojis can be used in comments.

Last edited by OpenPicture (2024-11-04 15:05:12)

Offline

 

#11 2024-11-03 17:59:35

OHappyDay
Member
2023-02-08
194

Re: Emoji icons used in comments result in the comment being lost

Hi,

my database (MySQL) is set to

   utf8mb4

and working perfectly.

Offline

 

#12 2024-11-03 19:23:46

OpenPicture
Member
2023-12-19
57

Re: Emoji icons used in comments result in the comment being lost

Hi OHappyDay,

I am glad to see that for you it works fine and it confirms that Piwigo 15.0 works well with utf8mb4.

As for my database, I guess it is because when I installed Piwigo almost 8 years ago, the database only supported utf8mb3.

Until today, it has never been updated to utf8mb4.

By the way, you can try it here now, because I set the configuration to comments for everyone:

https://konscht.com/artists/

Last edited by OpenPicture (2024-11-03 19:28:58)

Offline

 

Board footer

Powered by FluxBB

github linkedin newsletter Piwigo.org © 2002-2026 · Contact