Nao

  • Dadman with a boy
  • Posts: 16,079
Re: Class-DB changes?
« Reply #15, on September 25th, 2016, 08:02 PM »
All these years wasted trying to debug things when I could have added that command in index.php... ^^

Okay, I may have forgotten to add "self::" in front of all handle_utf8mb4 calls! Can you check?

CerealGuy

  • Posts: 343
Re: Class-DB changes?
« Reply #16, on September 27th, 2016, 12:51 PM »Last edited on September 27th, 2016, 01:00 PM
Just applied latest commit to my test install ::)
Code: [Select]
Parse error: syntax error, unexpected 'handle_utf8mb4' (T_STRING), expecting variable (T_VARIABLE) in /usr/share/nginx/www/wedge/gz/app/Class-DB.php on line 621

EDIT: Going to fix it step by step:
Line 567:
Code: [Select]
return sprintf('\'%1$s\'', handle_utf8mb4(mysqli_real_escape_string($connection, $replacement)));
should be
Code: [Select]
return sprintf('\'%1$s\'', self::handle_utf8mb4(mysqli_real_escape_string($connection, $replacement)));
Line 621:
Code: [Select]
public static handle_utf8mb4($str)
should be
Code: [Select]
public static function handle_utf8mb4($str)

PR: https://github.com/Wedge/wedge/pull/38

Nao

  • Dadman with a boy
  • Posts: 16,079
Re: Class-DB changes?
« Reply #17, on September 27th, 2016, 01:32 PM »
Yeah, I should have split the three different changes to that file into three commits (variable renaming, function renaming and adding a placeholder for it)... sorry about that.

I'll commit it.

Btw what's that css edit in your pull request..?

CerealGuy

  • Posts: 343
Re: Class-DB changes?
« Reply #18, on September 27th, 2016, 01:57 PM »
Firefox fix for Overflow bug:
http://wedge.org/pub/bugs/8819/overflow-bug/msg297352/#msg297352

Don't ask me why this got committed too, normally I seperate all changes in different branches and let the master branch untouched. Maybe i committed this stuff once to the master branch, i don't know. Can reset my master, create a new branch and do a new pull request if you want, or you just change those two things on your own :D
Re: Class-DB changes?
« Reply #19, on September 27th, 2016, 02:40 PM »
Quote
Fixed untested utf8mb4 placeholder code. Note, this still doesn't support 4-byte UTF8... I still don't know exactly what I should do with those. (Class-DB.php)
@Nao, Can you explain what's the problem with 4-byte UTF8?

Jurien

  • All i want is a couple days off
  • Posts: 132
Re: Class-DB changes?
« Reply #20, on September 27th, 2016, 09:22 PM »
Quote from Nao on September 27th, 2016, 01:32 PM
Yeah, I should have split the three different changes to that file into three commits (variable renaming, function renaming and adding a placeholder for it)... sorry about that.

I'll commit it.
Took me some time to get things right,but it seems to be oké now,suppose you have not incorporated the final addition of :at: Cereal Guy ?,because i had to add this lines manually into the newest revs of Class-DB.PHP.

B.t.w Thanks Cereal Guy for your efforts :cool:

Nao

  • Dadman with a boy
  • Posts: 16,079
Re: Class-DB changes?
« Reply #21, on September 28th, 2016, 12:39 AM »
Quote from Freñiçh on September 27th, 2016, 09:22 PM
Took me some time to get things right,but it seems to be oké now,suppose you have not incorporated the final addition of :at: Cereal Guy ?,because i had to add this lines manually into the newest revs of Class-DB.PHP.
No, I fixed the files but didn't use his code. The fix is similar, though!

https://github.com/Wedge/wedge/commit/9f59d4284378079b4840623185a3c87b763a21c6
Re: Class-DB changes?
« Reply #22, on September 28th, 2016, 12:43 AM »
Quote from CerealGuy on September 27th, 2016, 02:40 PM
@Nao, Can you explain what's the problem with 4-byte UTF8?
Well, MySQL added support for 4-byte UTF8, which is used mostly by new smileys. If you try to insert such a character into a regular UTF8 database, it'll be inserted as a ? (question mark). Which isn't great. Of course, it's only for those smileys.
There are two ways to fix that:
- Either catch all utf8mb4 characters at MySQL insert time, and turn them into HTML entities (which is what Elk does, so that's emanuelle's recommended solution),
- Or ensure that the database uses utf8mb4 from the start, if supported. That way, the character will only take 4 bytes in the database, rather than the length of an entity... Which, okay, is barely twice that number.

I'm not a big fan of parsing all messages for character recognition. I don't know if the array_split followed with an ord() call on all array items would be really fast. (Probably faster than a regexp, but still...)
Re: Class-DB changes?
« Reply #23, on September 28th, 2016, 12:46 AM »
Quote from CerealGuy on September 27th, 2016, 01:57 PM
Firefox fix for Overflow bug:
http://wedge.org/pub/bugs/8819/overflow-bug/msg297352/#msg297352

Don't ask me why this got committed too, normally I seperate all changes in different branches and let the master branch untouched. Maybe i committed this stuff once to the master branch, i don't know. Can reset my master, create a new branch and do a new pull request if you want, or you just change those two things on your own :D
Yeah, it's not the first time you're having problems with commits, but honestly I probably wouldn't fare better with pull requests myself.
I'd simply recommend posting a diff file, it's probably gonna be cleaner & faster for everybody. (Except I can't do a full merge from the github website, of course.)

Regarding Firefox, I'm on the fence. You're using hardcoded values (min-width: 49em, another one like that, and a final 'padding: 0 15px' that wasn't in the original css), it's usually bad practice for future browser versions & screen resolutions.
I'd need to test and see if I can find something better, but I'm having so many problems with Firefox in general, I'm not in a hurry.

CerealGuy

  • Posts: 343
Re: Class-DB changes?
« Reply #24, on September 28th, 2016, 09:22 AM »
Quote from Nao on September 28th, 2016, 12:43 AM
Well, MySQL added support for 4-byte UTF8, which is used mostly by new smileys. If you try to insert such a character into a regular UTF8 database, it'll be inserted as a ? (question mark). Which isn't great. Of course, it's only for those smileys.
There are two ways to fix that:
- Either catch all utf8mb4 characters at MySQL insert time, and turn them into HTML entities (which is what Elk does, so that's emanuelle's recommended solution),
- Or ensure that the database uses utf8mb4 from the start, if supported. That way, the character will only take 4 bytes in the database, rather than the length of an entity... Which, okay, is barely twice that number.

I'm not a big fan of parsing all messages for character recognition. I don't know if the array_split followed with an ord() call on all array items would be really fast. (Probably faster than a regexp, but still...)
Thanks for clarification, got it. How about deciding once if the sql server supports (and is using uft8mb8 as charset on the important tables) and if so use the faster first approach, if not second?
On the other hand, utf8mb4 was introduced in 2010, so legacy support is not really needed.
Anyone who still uses a pre ut8mb4 mysql version should have other problems as character encoding.
Quote from Nao on September 28th, 2016, 12:46 AM
Regarding Firefox, I'm on the fence. You're using hardcoded values (min-width: 49em, another one like that, and a final 'padding: 0 15px' that wasn't in the original css), it's usually bad practice for future browser versions & screen resolutions.
I'd need to test and see if I can find something better, but I'm having so many problems with Firefox in general, I'm not in a hurry.
I'm totally fine with this. It's not a fix, it's more of a hack. Don't use firefox (except for tor browser) on my own, but people on our forum do and they reported this issue. So I tried, and fixed it, even if it's not the proper way. So totally fine with not merging it. People who have this problem can wait for a good fix or use this hack. I have nearly no idea of CSS, it's always playing around with browsers dev tools :whistle:.

Jurien

  • All i want is a couple days off
  • Posts: 132
Re: Class-DB changes?
« Reply #25, on September 29th, 2016, 09:22 AM »
Warning (level 2): mysqli_real_escape_string() expects exactly 2 parameters, 1 given Class-DB.php Line 775

 Class-DB.php line 775.png - 14.32 kB, 791x135, viewed 170 times.


CerealGuy

  • Posts: 343
Re: Class-DB changes?
« Reply #26, on September 29th, 2016, 02:20 PM »
Didn't try it yet, but something like this should work.
Code: [Select]
public static function escape_string_replacement($str, $connection = null)
{
                $connection = $connection === null ? self::$_db_con : $connection;
return mysqli_real_escape_string($connection, $str);
}

Jurien

  • All i want is a couple days off
  • Posts: 132
Re: Class-DB changes?
« Reply #27, on September 30th, 2016, 08:58 AM »
Quote from CerealGuy on September 29th, 2016, 02:20 PM
Didn't try it yet, but something like this should work.
Adding that line's gives me another warning on Line 776.(Happens when Run Tasks Forum Maintenance<=>Routine<=>Optimize all tables.

Looks like a snowball effect remains a struggle with Class-DB.php,

 Class-DB.php.png - 10.84 kB, 782x82, viewed 171 times.


Nao

  • Dadman with a boy
  • Posts: 16,079
Re: Class-DB changes?
« Reply #28, on October 1st, 2016, 10:38 AM »
Sorry. Only need to add the connection variable before the str variable in the new function definition.

And yes I'm not using that code on my current websites sorry.

Jurien

  • All i want is a couple days off
  • Posts: 132
Re: Class-DB changes?
« Reply #29, on October 1st, 2016, 12:06 PM »
Well i'm done with it,deleted the last revs and get back to a working forum before the new revs.....even media gallery give's me all kind of errors and troubles.

I'm sorry but I can not afford to have a malfunctioning forum.