Skip Navigation

[Closed] Split: Sum data stored in custom fields – toolset_get_related_posts() broke the site without showing any error

This support ticket is created 4 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 11 replies, has 3 voices.

Last updated by Minesh 4 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#1729177

I'm referring to an argument in the code. I.e. i had misread toolset_get_related_posts and was only passing 2 arguments instead of the three I needed. This code however would pass in the test in the settings, but cause the whole toolset application to crash without outputting any errors.

I'd expect to see some errors logged via the default wordpress error reporting.

#1729179

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share how exactly you are using toolset_get_related_posts() function that broke your site.

Also, have you enabled the WP_DEBUG as well as WP_DEBUG_LOG?

#1729525
brokensite.gif

This is what is in the wp-config.php:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', '/wp-content/debug.log' );
 

The toolset_get_related_posts() function is called in a shortcode in the Custom code snippets section in settings.

If I change the function to look like this:

$related_posts = toolset_get_related_posts($id);
 

which is WRONG as it needs more arguments and click save and test, I get the message:

"Snippet "microcycle_distance_calc" has been updated.
The snippet has been re-run without errors."

If I then try and load the page with the shortcode in, it fails to load properly. See screenshot attached. You can see that the page content has cut off. No footers etc.

I would expect there to be some sort of errors captured in the WordPress debug log, but there is nothing reported at all. If I make a change to a WordPress plugin which causes it to crash, that will output into this file fine.

This makes debugging a bit harder!

#1734167

Minesh is on vacation and won't be available this week, I hope you won't see an inconvenient if I continue with you on this ticket.

To better handle this ticket and escalate it to our 2nd Tier, I would need a concrete example of an error that should have triggered errors in the debug file. For that reason, I have created a new installation on our platform and I wonder if you could reproduce a similar situation on it.
Please use the following link to log on in this installation using this link hidden link
Try to reproduce a similar situation by creating the custom post type, the custom code and the posts that may demonstrate the issue, I'll then analyze it and if needed, escalate it to our 2nd Tier for a deeper analysis before escalating it to our devs.

Please note that this test installation will remain live for only 7 days

Thank you for your collaboration.

#1734189

hidden link

I don't believe I can enable debug mode and see the error log here. I've created a shortcode with an error in. You can see it just crashes out. I'm expecting to see some debug to help diagnostics. On my install, I don't get anything in the error log.

#1734755

I activated the debugging on the test site and I got some errors logged in, check this screenshot hidden link

And check the debug file here hidden link

[11-Aug-2020 14:39:33 UTC] PHP Notice:  Undefined index: auto in /var/www/sites/dangerous-panda-znzin7t4/wp-content/mu-plugins/sandbox-cms.php on line 109
[11-Aug-2020 14:39:33 UTC] PHP Notice:  Trying to get property 'user' of non-object in /var/www/sites/dangerous-panda-znzin7t4/wp-content/mu-plugins/sandbox-cms.php on line 113
[11-Aug-2020 14:39:33 UTC] PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function toolset_get_related_posts(), 1 passed in /var/www/sites/dangerous-panda-znzin7t4/wp-content/toolset-customizations/microcycle_distance_calc.php on line 13 and at least 2 expected in /var/www/sites/dangerous-panda-znzin7t4/wp-content/plugins/types/vendor/toolset/toolset-common/inc/public_api/m2m.php:79
Stack trace:
#0 /var/www/sites/dangerous-panda-znzin7t4/wp-content/toolset-customizations/microcycle_distance_calc.php(13): toolset_get_related_posts(1)
#1 /var/www/sites/dangerous-panda-znzin7t4/wp-includes/shortcodes.php(343): microcycle_distance_calc_callback('', '', 'microcycle_dist...')
#2 [internal function]: do_shortcode_tag(Array)
#3 /var/www/sites/dangerous-panda-znzin7t4/wp-includes/shortcodes.php(218): preg_replace_callback('/\\[(\\[?)(microc...', 'do_shortcode_ta...', '\n<h2>Test page<...')
#4 /var/www/sites/dangerous-panda-znzin7t4/wp-includes/class-wp-hook.php(287): do_shortcode('\n<h2>Test page<...')
#5 /var/www/sites/dangerous-panda-znzin in /var/www/sites/dangerous-panda-znzin7t4/wp-content/plugins/types/vendor/toolset/toolset-common/inc/public_api/m2m.php on line 79

I hope that's what you were looking for. If this is not the case on your server, I'll suggest checking the debug.log with a simple line on your theme's functions.php file, and visiting a page on the site to trigger it:

error_log('this should be written to debug.log file');

If nothing is written, maybe that's an issue within your server, and your hosting provider should help you to fix it.

Please correct me if I did not understand the issue well.

#1734869

That error log message appears find in my log, but I don't get anything from Toolset. Is there a separate error logging level for Toolset?

#1734953

Please check the 3rd line from the logs I previously shared. It is a PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function toolset_get_related_posts().
I think that the error is clear and explains that some arguments of the functions are missing.

Maybe, I am missing something, and I did not understand your request very well. If that's the case, please elaborate more and let me know what should be done from Toolset part.

#1734967

Yeah, I'm aware what the error is. This is about how toolset doesn't seem to log errors from the custom code section on my install. I'm deliberately running broken code to simulate what happens when I'm trying to work on the site.

I don't get any useful output in the debug log and the site just crashes. If I'm using an "error_log()" call, that appears fine and if I break another plugin, we'll get errors in the log too.

#1735011

I can't tell what is causing that, maybe an error in the code or the server configuration. I might give it a try, but I'd like to note, that debugging custom code is out of the scope of the support forum. Check our support policy here https://toolset.com/toolset-support-policy/

Please try to use the same code as your shortcode on the test server and I'll give it a try.

#1737705

Hi, it doesn't matter what code is there. It just needs a toolset function call without the right number of arguments. The page crashes, as you'd expect, but I don't see any error logging from toolset. Apparently you see it on the test site though.

Are there any settings in toolset which determine if it error logs or not? Other plugins on my site report errors properly.

#1739079

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi Kelly,

Jamal is on vacation and I'll take care of this ticket.

As Jamal mentioned that he can not see the issue.

I would like to have access details of your site and problem URL where I can see the broken page or steps I need to follow to broke the page and let me see if I can find anything on your site.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

The topic ‘[Closed] Split: Sum data stored in custom fields – toolset_get_related_posts() broke the site without showing any error’ is closed to new replies.