Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-10-07 13:44:13

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,633

4.7.3 - any changes required for MySQL 8.0 compatibility?

Is anyone running Textpattern 4.7.3 on MySQL 8.0 successfully? If so, were any changes required to get it working properly?

I’ve got an auto-installed Textpattern 4.7.3 on a Percona (MySQL) 8.0 + PHP 7.3 server. I can access the login page, and I know the credentials are correct, but I get a generic “Internal error” after I submit the form. There’s an HTTP 401 error thrown in the access log, but nothing beyond that.

I’m running 4.8.0-dev on the same server, same user and password, logs in with no issues.

Any advice very warmly received. Thank you!

Offline

#2 2019-10-07 14:24:55

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,836
Website

Re: 4.7.3 - any changes required for MySQL 8.0 compatibility?

I haven’t tried it but suspect there may be issues. If you flick the production_status pref to debug in the database, do you get any more detailed info in the error message?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2019-10-07 14:27:51

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,633

Re: 4.7.3 - any changes required for MySQL 8.0 compatibility?

Bloke wrote #319570:

I haven’t tried it but suspect there may be issues. If you flick the production_status pref to debug in the database, do you get any more detailed info in the error message?

Actually, I didn’t try that – good thinking. I’ll report back.

Edit: thanks for the suggestion, Stef. The only change on the login page with debug status is the ‘Internal error’ appears twice now, rather than once. Nothing extra in the logs.

Last edited by gaekwad (2019-10-07 14:33:00)

Offline

#4 2019-10-07 15:36:33

etc
Developer
Registered: 2010-11-11
Posts: 3,418
Website

Re: 4.7.3 - any changes required for MySQL 8.0 compatibility?

4.7.3 is still using PASSWORD() if other methods fail, so you’d have to generate MySQL hashes in PHP to avoid calling it. Hopefully, every txp user has logged in at least once since txp 4.4 (?) era, so the issue must be very marginal.

Offline

#5 2019-10-07 16:11:32

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,836
Website

Re: 4.7.3 - any changes required for MySQL 8.0 compatibility?

Okay. My guess, as Oleg suggests, is that it’s hitting the PASSWORD() call and falling over.

It should check more recent style passwords first and only fall back on trying ones using PASSWORD() if that fails. So the only way it would be hitting that would be if the passwords themselves (on the demo server, for example) were generated in that manner by the batch script.

Altering the creation mechanism to generating them from PHP would solve it.

But as a general rule, yes, Oleg’s right, there shouldn’t be many people hitting this issue in the real world besides those that haven’t logged in since 4.3ish.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#6 2019-10-07 19:55:40

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,633

Re: 4.7.3 - any changes required for MySQL 8.0 compatibility?

Thank you, gentlemen – very much appreciated.

Offline

#7 2019-10-10 14:35:55

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,633

Re: 4.7.3 - any changes required for MySQL 8.0 compatibility?

Bloke wrote #319577:

Altering the creation mechanism to generating them from PHP would solve it.

But as a general rule, yes, Oleg’s right, there shouldn’t be many people hitting this issue in the real world besides those that haven’t logged in since 4.3ish.

Hi Stef – thanks for the code chunk you sent me. I think I’m almost there with the PHP method, but I’d appreciate some clarification if you’re able to shed some light.

The site in question — beta-demo.textpattern.co running 4.7.3-rc.1 — is a proving ground for 4.7.3-era code. I have a file in the root that I’m calling via command line:

<?php
define('txpinterface', 'css');

require __DIR__ . '/index.php';

$lines = file('/var/www/vhosts/textpattern.co/beta-demo/staging/users_1.txt');
$counter = 1;

foreach ($lines as $row) {
    $parts = do_list($row, '|');
    $name = $parts[0];
    $pass = \Txp::get('\Textpattern\Password\Hash')->hash($parts[1]);

    create_user($name, "{$name}@example.com", $pass, "Managing Editor #{$counter}", 2);
    $counter++;
}
?>

That loops through the named .txt file with username|password credentials…:

managing-editor1|managing-editor1
managing-editor2|managing-editor2
managing-editor3|managing-editor3
managing-editor4|managing-editor4
managing-editor5|managing-editor5
[…]

…and appears to generate the password hashes for said users. Here’s an excerpt from the database export after I run that .php script above:

INSERT INTO `txp_users` (`user_id`, `name`, `pass`, `RealName`, `email`, `privs`, `last_access`, `nonce`) VALUES
(7998,	'managing-editor998',	'$P$Bcgqgtzp2cOZiqlgmckPy3mfwLGQIS/',	'Managing Editor #998',	'managing-editor998@example.com',	2,	NULL,	'275af75df3de649436c9484804bd9cf5'),
(7999,	'managing-editor999',	'$P$B7Zp021G5cTdKbWpb17j.XkFl00IPg.',	'Managing Editor #999',	'managing-editor999@example.com',	2,	NULL,	'81dde1525016087c31df635ec6f7d4a7'),
(7997,	'managing-editor997',	'$P$B/xEX2Ys7Jl790rhIGOjCpr0HzHMyt/',	'Managing Editor #997',	'managing-editor997@example.com',	2,	NULL,	'98498c193afd2428ec89cb7c8b27a23c'),
(7996,	'managing-editor996',	'$P$B/M2pbesUXW9T3RrHelLG6DBEcb7yT/',	'Managing Editor #996',	'managing-editor996@example.com',	2,	NULL,	'7c925deb22353fec3d921345d4d09164'),
(7994,	'managing-editor994',	'$P$BXzQXko5RZwZY4eP9qwfXca29u/yZs1',	'Managing Editor #994',	'managing-editor994@example.com',	2,	NULL,	'3e828e8cd822037c0b5b70ab7742db44'),
(7995,	'managing-editor995',	'$P$BSHiXThVgdhS52JF2AS13pUxhYM6HZ.',	'Managing Editor #995',	'managing-editor995@example.com',	2,	NULL,	'a203e94f47b6d76b5890ece14c1f96dc'),
(7993,	'managing-editor993',	'$P$B1ItlIfAsSreMaWXC7dXEr/9N3e8wE0',	'Managing Editor #993',	'managing-editor993@example.com',	2,	NULL,	'cb4027a8f5da85cef1dbccf5b209f1ee'),
(7992,	'managing-editor992',	'$P$BINT.q6KBkgRd.WON4DXKVmvInYshz.',	'Managing Editor #992',	'managing-editor992@example.com',	2,	NULL,	'eb28c49c0618c1a18eeb63a6b85e87d8'),
[…]

When I try to log in with a username + password combo from the above, I get “Internal error”, and nothing of note in the access or error logs.

I get the feeling I’m 99% of the way there (thanks to your invaluable help), and I’m missing something. Any ideas or pointers, please? Thank you in advance.

Last edited by gaekwad (2019-10-10 15:57:21)

Offline

#8 2019-10-10 15:51:56

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,836
Website

Re: 4.7.3 - any changes required for MySQL 8.0 compatibility?

D’oh! Sorry, the create_user() function takes the plain password and then hashes it for you internally, so there’s no need to hash it outside manually and pass it in.

Thus…

foreach ($lines as $row) {
    $parts = do_list($row, '|');
    $name = $parts[0];
    $pass = $parts[1];

    create_user($name, "{$name}@example.com", $pass, "Managing Editor #{$counter}", 2);
    $counter++;
}

EDIT: and since your passwords are the same as your logins, you don’t really need to put them twice in the file with the pipes. You can just use single values and use the value twice. Even better, you don’t even need to use a separate file. You could programmatically generate the names in a loop, just like Jukka did. Even if you want to use a different pass to the login, you can do that programmatically too.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#9 2019-10-10 16:06:52

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,633

Re: 4.7.3 - any changes required for MySQL 8.0 compatibility?

Thanks, Stef – I was getting nowhere with Jukka’s code after some hours, but the penny just dropped — and now it works. Users are now being created correctly and cleanly.

The code was sound, but the driver was lost!

Offline

#10 2019-10-10 16:36:40

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,836
Website

Re: 4.7.3 - any changes required for MySQL 8.0 compatibility?

Sweet!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB