• Welcome to the all-new Kolakube support, the official place to get help for Marketers Delight, XFtoWP, CryptoWP, and other WordPress products! Please login with your account details to access members-only support forums.

Third party PHP message: PHP Fatal error: Allowed memory size of 536870912 bytes exhausted...

Igor

Member
XFtoWP
Messages
17
Reaction score
2
WordPress 6.1.1, PHP 8.0.26
Issue: articles that have connected threads cannot be opened
How to reproduce:
1. Create article
2. Create connected thread
3. Try to open it in browser
4. Error:
CSS:
2023/02/14 21:19:18 [error] 1314#1314: *64256 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in /home/benchmark/public_html/wp-content/plugins/XFWP/lib/strings.php on line 11PHP message: PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 32768 bytes) in /home/benchmark/public_html/wp-includes/functions.php on line 5279PHP message: PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 32768 bytes) in Unknown on line 0" while reading upstream, client: 89.216.27.147, server: bns.benchmark.rs, request: "GET /vesti/uredaji/motorola-moto-buds-600-anc-su-besplatne-uz-edge-30-fusion-viva-magenta/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "bns.benchmark.rs"

If I disconnect the thread from the article, it is possible to access it.

This is an urgent issue - what could cause such behaviour?
 

Igor

Member
XFtoWP
Messages
17
Reaction score
2
To answer myself (but still do not understand why) - override of XFWP in my theme caused this issue (comments-list.php)

I copied that file from the plugin and just added the following:
CSS:
<?php

    echo view('partials.comments', [
        "thread_total" => $thread_total,
        "postId" => get_the_ID()
    ])->render();

This caused the error above, but I do not know why. Maybe there is some kind of incompatibility with the latest Sage theme framework?
 
Comment

Alex

MD developer
Staff member
Md
XFtoWP
Messages
6,819
Reaction score
1,926
It's tough to say and I can't offer much support for a third party template language. I suspect this is some kind of filesystem error from trying to read templates. I have seen "phantom" errors like this before when the name of a file in the theme interferes with a similarly named file at a higher level, but none of this has shown up in my testing of overriding the XFtoWP plugin files.

This error only happens when the Sage code is present? What about when you make the initial file overwrite?
 
Comment

Igor

Member
XFtoWP
Messages
17
Reaction score
2
Yeah, it does happen only when the Sage code is present. With initial overwrite, everything is fine.

Would it be possible to add another option of showing the comments - Show WP Comments only? Because I am syncing comments from XF using your methods and I do not want to display XFWP comments. In that case, I wouldn't have to overwrite anything :)

P.S. I'll share WP CLI code once I am done with this website.
 
Comment

Igor

Member
XFtoWP
Messages
17
Reaction score
2
Additional question - why no one except Administrator can see XenForo in Side panels in Editor? That is weird.
 
Comment

Alex

MD developer
Staff member
Md
XFtoWP
Messages
6,819
Reaction score
1,926
Would it be possible to add another option of showing the comments - Show WP Comments only? Because I am syncing comments from XF using your methods and I do not want to display XFWP comments. In that case, I wouldn't have to overwrite anything :)
Interesting, I haven't considered this option before but I think it's reasonable to add. For your purposes, you may just want to unhook the template for the time being.

Additional question - why no one except Administrator can see XenForo in Side panels in Editor? That is weird.
Most people don't want to give Subscribers or other usergroups permissions to create/connect threads. You can grant permissions to other WP user roles from WP admin > XF > Thread Connect > Permissions and also add custom user roles to the interface with a filter:


P.S. I'll share WP CLI code once I am done with this website.
Can't wait to see more. :love:
 
Comment

Igor

Member
XFtoWP
Messages
17
Reaction score
2
OK, I can unhook the template and/or edit the plugin but if that does not become part of the next update, it will break my website :) So the question is - are you willing to consider adding that option as standard part of the plugin?
 
Comment

Alex

MD developer
Staff member
Md
XFtoWP
Messages
6,819
Reaction score
1,926
OK, I can unhook the template and/or edit the plugin but if that does not become part of the next update, it will break my website :) So the question is - are you willing to consider adding that option as standard part of the plugin?
Yes, I think it is a reasonable setting to have and I will add it as an option to the dropdown template setting.

There you go: https://gist.github.com/igorhrcek/b90e3749ec6dd83781ca10ecb80b86f3

It works like a charm :)

I can write additional code that will allow you to sync users, threads... whatever you want.
Very nice work! So this is essentially a command you will run whenever you want to sync a new thread, or multiple threads at a time? I'd be curious to see how simple it would be to run a bulk action such as "import XF users to WP" from here, as that seems to be the most helpful use case.
 
Comment

Igor

Member
XFtoWP
Messages
17
Reaction score
2
Yes, I think it is a reasonable setting to have and I will add it as an option to the dropdown template setting.


Very nice work! So this is essentially a command you will run whenever you want to sync a new thread, or multiple threads at a time? I'd be curious to see how simple it would be to run a bulk action such as "import XF users to WP" from here, as that seems to be the most helpful use case.
What this command does is it fetches all articles in the past `get_option("close_comments_days_old")` days or whatever you pass as `--published-since` parameter. Then it will check if each post has a `thread_id` set and sync comments.

If there are no comments in WP database, it will add everything from thread minus first post.
If there are comments, it will add only what is missing while respecting `trashed` status in WordPress (if you remove comment in WP database, it will not bring it back).
Finally, if there were updated thread comments (someone did an edit), it will also update the content of the comment in WordPress database.

After each thread API call, it sleeps for 1s or `--sleep` seconds time to prevent XF overload. Of course, you can disable this behaviour by passing `--sleep=0`.

A simple cron on server or WPCron that execute WP CLI without issues. With this implementation, you could easily sync tens of thousands of accounts, threads and comments while not being dependent on max_memory_limit or max_execution_time in PHP.
 
Comment
Top