qtranslate / qtranslate-xt

qTranslate-XT (eXTended) - reviving qTranslate-X multilingual plugin for WordPress. A new community-driven plugin soon. Built-in modules for WooCommerce, ACF, slugs and others.
GNU General Public License v2.0
550 stars 103 forks source link

`unserialize` error with ACF wysiwyg fields #1274

Open MarkArgent opened 1 year ago

MarkArgent commented 1 year ago

Following on from #1261 --- I realise that has been closed, but I am still having a problem with wysiwyg fields in data types created with Advanced Custom Fields, having upgraded to QTranslateXT 3.13.0 which I thought included a solution to this.

The wysiwyh fields and the title (which is a simple text field), have a thick blue line to the left, indicating that they are translatable. But when I click in the flags to switch languages (between English and Welsh) the title changes between the two languages, but the contents of the wysiwyg fields don't change..

The only error messages I am seeing are what's below from the wordpress debug.log file (nothing is appearing in the apache or php error logs).

Somewhere I think I've seen a reference to doing something in functions.php to affect the initialisation of qTranslateXT with ACT wysiwyg fields, but googling this hasn't thrown anything up.

PHP 7.4.33 ACF Pro 6.0.6 ACF Extended 0.8.8.11 qTranslateXT 3.13.0 Wordpress 6.1.1

wordpress debug.log [05-Jan-2023 16:43:11 UTC] PHP Notice: unserialize(): Error at offset 188 of 627 bytes in /home/mark/angleseyartsforum.org/data/wp-content/plugins/qtranslate-xt-master/qtranslate_frontend.php on line 772 [05-Jan-2023 16:43:11 UTC] PHP Notice: unserialize(): Error at offset 233 of 590 bytes in /home/mark/angleseyartsforum.org/data/wp-content/plugins/qtranslate-xt-master/qtranslate_frontend.php on line 772 [05-Jan-2023 16:43:11 UTC] PHP Notice: unserialize(): Error at offset 171 of 586 bytes in /home/mark/angleseyartsforum.org/data/wp-content/plugins/qtranslate-xt-master/qtranslate_frontend.php on line 772 [05-Jan-2023 16:43:11 UTC] PHP Notice: unserialize(): Error at offset 233 of 590 bytes in /home/mark/angleseyartsforum.org/data/wp-content/plugins/qtranslate-xt-master/qtranslate_frontend.php on line 772 [05-Jan-2023 16:43:48 UTC] PHP Notice: unserialize(): Error at offset 188 of 627 bytes in /home/mark/angleseyartsforum.org/data/wp-content/plugins/qtranslate-xt-master/qtranslate_frontend.php on line 772 [05-Jan-2023 16:43:48 UTC] PHP Notice: unserialize(): Error at offset 233 of 590 bytes in /home/mark/angleseyartsforum.org/data/wp-content/plugins/qtranslate-xt-master/qtranslate_frontend.php on line 772 [05-Jan-2023 16:43:48 UTC] PHP Notice: unserialize(): Error at offset 171 of 586 bytes in /home/mark/angleseyartsforum.org/data/wp-content/plugins/qtranslate-xt-master/qtranslate_frontend.php on line 772 [05-Jan-2023 16:43:48 UTC] PHP Notice: unserialize(): Error at offset 233 of 590 bytes in /home/mark/angleseyartsforum.org/data/wp-content/plugins/qtranslate-xt-master/qtranslate_frontend.php on line 772

herrvigg commented 1 year ago

Mmm that serialization is about cache optimization of meta fields. It's the first time I even see it... It's legacy, I don't like those kind of optimizations much, they create complications and it's not said they are really more efficient than other caching systems at a lower level (PHP and DB).

ACF Extended 0.8.8.11

Could it be a conflict with ACF Extended? Try to disable it temporarily to see if this problem is still there without it.

still having a problem with wysiwyg fields in data types created with Advanced Custom Fields

I don't think it matters here, but do you use the standard ACF fields or the derived "Text (qTranslate-XT) / Wysiywyg (qTranslate-XT)" fields? From now on I recommend to use the standard types. I think we should deprecated the derived versions, they create unnecessary complications and they don't stick to the general case with the LSB.

herrvigg commented 1 year ago

Let me know if it works without ACF Extended. Otherwise we could think of disabling this cache functionality but I'd need to see better how.

MarkArgent commented 1 year ago

Apologies for my delay --- my unix machine developed a fault that I've just managed to fix.

Disabling ACF Extended didn't make a difference.

I checked the content type and it is "wysiwyg editor" under "content" rather than "wysiwyg editor (qtranslate-xt)" under "qtranslate-xt". I tried swapping to the latter and found that the fields switch correctly, but when I save the entry and view it on the web site the title switches languages when I click to switch language, but the content has the text for both languages.

Are there other things I can try?

herrvigg commented 1 year ago

Could you try to dump the values? We'd need to understand the content that is causing the failure. In this function: https://github.com/qtranslate/qtranslate-xt/blob/8d7fe32b63e7b7d9a2f09f921fee41ff3d8c4eae/qtranslate_frontend.php#L772 Can you replace

$v = unserialize( $v );

with

$unserialized = unserialize( $v );
if ( $unserialized === false)
{
   var_dump($v);
   continue;
}
$v = $unserialized;

and give a few examples of the values you get there?

herrvigg commented 1 year ago

@MarkArgent Please try again with last release 3.14.0. I will close this ticket if there's no activity.

MarkArgent commented 1 year ago

Apologies

I eventually worked around it by adding something to the JSON description, based on something I'd seen in the text for qtranslate-X. I'm tied up for the rest of today so will try your suggestion tomorrow

Best wishes

Mark

On 02/04/2023 10:48, Herr Vigg wrote:

@MarkArgent https://github.com/MarkArgent Please try again with last release 3.14.0. I will close this ticket if there's no activity.

— Reply to this email directly, view it on GitHub https://github.com/qtranslate/qtranslate-xt/issues/1274#issuecomment-1493282242, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4HMEJNUHRQKLWX3AT3MI7DW7FDPTANCNFSM6AAAAAATSOZCHU. You are receiving this because you were mentioned.Message ID: @.***>

herrvigg commented 1 year ago

The return codes on unserialize are not checked so it could be that something weird has been stored. Would be interesting to see if this can be reproduced.