Hello! We have been using Toolset for over a year now, and at the moment, I do not have a developer (who originally set Toolset up). So when I see our PHP error log filled with errors within Toolset files - I'm unclear if this is based on our actual settings in views, templates, etc, or if there's another cause for it.
Here is an example of the most common ones - Just about every error I have seen are array-based, and the scalar value one is especially prevalent, firing many times per minute.
PHP Warning: Cannot use a scalar value as an array in /.../wp-content/plugins/types/application/models/field/type/date/view/frontend.php on line 52
PHP Warning: Cannot use a scalar value as an array in /.../wp-content/plugins/types/application/models/field/service.php on line 120
PHP Warning: array_walk() expects parameter 1 to be array, int given in /.../wp-content/plugins/types/application/models/field/type/view_frontend_abstract.php on line 187
There doesn't seem to be any affect on the front end, though I'm sure this also shouldn't happen! I've been dumping my error log file every few weeks just to keep the size in check (I just deleted a 3.6GB log file!). Any help or insight here would be appreciated!
Hello and thank you for contacting the Toolset support.
Can you please paste your Toolset Debug information in the Debug information field? This will let us know what version of PHP you are using. Toolset plugins are still not fully compatible with PHP8. If you are using it, please downgrade to PHP7
- https://toolset.com/faq/provide-debug-information-faster-support/
I might also need to access your website and check it closely. I may also need to take a copy of the website and analyze it locally. Let me know if that's fine with you. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
Thank you for the credentials. I logged in to the website and reviewed it a bit. I can't tell right now what's causing these php logs. I'll need to run some tests that involves using a default theme and deactivating non Toolset plugins, and that could affect your live users.
So, I suggest to take a copy of your website and work on it locally. I'll exclude the media files from the copy as I won't need them during my debugging, and that will reduce the size of the copy to less than 1Gb. I still need your approval to take it. Would you allow me to take the copy?
Yes, please download what you need, as long as it doesn't affect the live site! 1GB is much more manageable. Let me know what other questions I can help with.
I failed to take a Duplicator copy yesterday, but I managed to take a 6G copy using All In One Migration. It turns out that one of the views used by the theme was not correctly configured.
The view is "New and Upcoming Games", used in the theme's file upcoming.php. The view is configured to look for posts on the future, but the number of days was not set hidden link
/wp-admin/admin.php?page=views-editor&view_id=145451
I tested locally by setting the value 10, and the error logs were not reproduced anymore. I'll let you check from your side and if you are encountering more logs, let me know to check them too.
Thank you! I set this value, cleared my site cache, and deleted the log file to be sure, but the errors are still being generated. That particular view is one of the newest I created, and while I see I made an error leaving that field blank, these errors were happening before I created it. Do you think the cause is similar? Another view that should have a value in a field but it doesn't?
Well, setting the value for this view's query filter has definitely fixed this notice, which was generated when I visit the homepage. Definitely, because the homepage displays that view:
[30-Nov-2021 10:49:47 UTC] PHP 23. wpv_filter_parse_date() C:\sites\clone-2230941-2\wp-content\plugins\wp-views\embedded\inc\wpv-user-functions.php:500
[30-Nov-2021 10:55:32 UTC] PHP Warning: A non-numeric value encountered in C:\sites\clone-2230941-2\wp-content\plugins\types\vendor\toolset\toolset-common\inc\toolset.function.helpers.php on line 193
[30-Nov-2021 10:55:32 UTC] PHP Stack trace:
[30-Nov-2021 10:55:32 UTC] PHP 1. {main}() C:\sites\clone-2230941-2\index.php:0
[30-Nov-2021 10:55:32 UTC] PHP 2. require() C:\sites\clone-2230941-2\index.php:17
[30-Nov-2021 10:55:32 UTC] PHP 3. require_once() C:\sites\clone-2230941-2\wp-blog-header.php:19
[30-Nov-2021 10:55:32 UTC] PHP 4. include() C:\sites\clone-2230941-2\wp-includes\template-loader.php:106
[30-Nov-2021 10:55:32 UTC] PHP 5. get_template_part() C:\sites\clone-2230941-2\wp-content\themes\greendream\template-front.php:41
[30-Nov-2021 10:55:32 UTC] PHP 6. locate_template() C:\sites\clone-2230941-2\wp-includes\general-template.php:204
[30-Nov-2021 10:55:32 UTC] PHP 7. load_template() C:\sites\clone-2230941-2\wp-includes\template.php:676
[30-Nov-2021 10:55:32 UTC] PHP 8. require() C:\sites\clone-2230941-2\wp-includes\template.php:732
[30-Nov-2021 10:55:32 UTC] PHP 9. do_shortcode() C:\sites\clone-2230941-2\wp-content\themes\greendream\upcoming.php:2
[30-Nov-2021 10:55:32 UTC] PHP 10. preg_replace_callback() C:\sites\clone-2230941-2\wp-includes\shortcodes.php:218
[30-Nov-2021 10:55:32 UTC] PHP 11. do_shortcode_tag() C:\sites\clone-2230941-2\wp-includes\shortcodes.php:218
[30-Nov-2021 10:55:32 UTC] PHP 12. WP_Views_plugin->short_tag_wpv_view() C:\sites\clone-2230941-2\wp-includes\shortcodes.php:343
[30-Nov-2021 10:55:32 UTC] PHP 13. WP_Views_plugin->render_view_ex() C:\sites\clone-2230941-2\wp-content\plugins\wp-views\embedded\inc\wpv.class.php:639
[30-Nov-2021 10:55:32 UTC] PHP 14. WP_Views_plugin->render_view() C:\sites\clone-2230941-2\wp-content\plugins\wp-views\embedded\inc\wpv.class.php:2124
[30-Nov-2021 10:55:32 UTC] PHP 15. wpv_filter_get_posts() C:\sites\clone-2230941-2\wp-content\plugins\wp-views\embedded\inc\wpv.class.php:2497
[30-Nov-2021 10:55:32 UTC] PHP 16. apply_filters() C:\sites\clone-2230941-2\wp-content\plugins\wp-views\embedded\inc\wpv-filter-query.php:818
[30-Nov-2021 10:55:32 UTC] PHP 17. WP_Hook->apply_filters() C:\sites\clone-2230941-2\wp-includes\plugin.php:212
[30-Nov-2021 10:55:32 UTC] PHP 18. WPV_Meta_Frontend_Filter::filter_post_meta() C:\sites\clone-2230941-2\wp-includes\class-wp-hook.php:292
[30-Nov-2021 10:55:32 UTC] PHP 19. apply_filters() C:\sites\clone-2230941-2\wp-content\plugins\wp-views\embedded\inc\filters\wpv-filter-meta-field-embedded.php:159
[30-Nov-2021 10:55:32 UTC] PHP 20. WP_Hook->apply_filters() C:\sites\clone-2230941-2\wp-includes\plugin.php:212
[30-Nov-2021 10:55:32 UTC] PHP 21. wpv_filter_resolve_variable_date_timestamp() C:\sites\clone-2230941-2\wp-includes\class-wp-hook.php:292
[30-Nov-2021 10:55:32 UTC] PHP 22. wpv_apply_user_function_date_compare() C:\sites\clone-2230941-2\wp-content\plugins\wp-views\embedded\inc\wpv-user-functions.php:132
[30-Nov-2021 10:55:32 UTC] PHP 23. wpv_filter_parse_date() C:\sites\clone-2230941-2\wp-content\plugins\wp-views\embedded\inc\wpv-user-functions.php:500
I explored the lines of code that trigger these notices, but I coudn't guess what pages trigger them. I wanted to check on your website, maybe the traces could point to something usefull, but it seems that logging is disabled.
I assume that you activate the logging temporarily. The notices on your first reply must came from other pages. Can you enable debugging and check which pages trigger the errors? Can you also share a URL or the file of the logs? I'd like to check the traces.
Oh, I haven't been toggling logging on and off, I've just been checking the PHP error log in my /logs folder via FTP. Take a look there and let me know what you recommend.
This warning from the theme can be fixed by commenting line 432 of the theme's functions.php, or by uncommenting the existing function at lines 251-262
[01-Dec-2021 09:03:18 UTC] PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'GreenDream_pagination' not found or invalid function name in /home/rpgfan5/public_html/wp-includes/class-wp-hook.php on line 303
I fixed this issue to reduce the numbers of logs on the file and to have it more readable.
However, for these other warnings, there are no descriptive description or traces to follow it down and find what triggers them.
[01-Dec-2021 09:06:40 UTC] PHP Warning: Cannot use a scalar value as an array in /home/rpgfan5/public_html/wp-content/plugins/types/application/models/field/service.php on line 120
[01-Dec-2021 09:06:40 UTC] PHP Warning: array_walk() expects parameter 1 to be array, int given in /home/rpgfan5/public_html/wp-content/plugins/types/application/models/field/type/view_frontend_abstract.php on line 187
[01-Dec-2021 09:06:40 UTC] PHP Warning: Cannot use a scalar value as an array in /home/rpgfan5/public_html/wp-content/plugins/types/application/models/field/type/date/view/frontend.php on line 46
[01-Dec-2021 09:06:40 UTC] PHP Warning: Cannot use a scalar value as an array in /home/rpgfan5/public_html/wp-content/plugins/types/application/models/field/type/date/view/frontend.php on line 48
[01-Dec-2021 09:06:40 UTC] PHP Warning: Cannot use a scalar value as an array in /home/rpgfan5/public_html/wp-content/plugins/types/application/models/field/type/date/view/frontend.php on line 52
I am getting any of these warnings on my local copy. So, I assume that other pages are triggering them. Can you try from your side to detect which pages trigger these errors?
Otherwise, can you tell what are the most visited pages on your website and I'll check on my local copy if I can reproduce the same warnings.
Jamal,
Thank you for fixing the theme issue! I was going to look into that myself later, so I appreciate it.
As for testing, it's hard for me to test and know if anything I personally visit would trigger it, because we get enough general traffic and these errors show up in the log constantly.
Our main page is by far the highest in terms of traffic, and past that, we have our main Reviews page, and in a given week, any recent reviews are high traffic, such as these:
hidden link
hidden link
hidden link
This news column is also popular - we run it weekly, so right now, this week's is pulling the most hits:
hidden link
Let me know what you discover!
The review single page, and the blog posts are the pages that generate the warnings. The warning are caused by a wrong call to the Toolset Types API function types_render_field. It is called in several parts of the theme like:
types_render_field("field-slug", $post->ID, true);
Where it should be called like:
types_render_field("field-slug", array())
Check some examples here https://toolset.com/documentation/customizing-sites-using-php/functions/
This happens in several parts of the theme:
- single-review.php at line 9.
- scoreboard-main.php at lines 4, 14, 24, 34
- disclaimer.php at line 1
- info-news.php at line 6.
Go to all these lines an remove the second and third argument from types_render_field to keep just the first argument(field slug). For example in single-review.php line 9, change the line from:
if ( types_render_field( 'spoiler-warning', $post->ID, true )) {
To:
if ( types_render_field( 'spoiler-warning' )) {
I hope this helps. Let me know if you have any questions.
Thank you so much for this info! I have been really busy this week so I haven't had time to implement these yet, but I wanted to reply since I think sometimes tickets are automatically closed here? I will get into this in the next few days and let you know what I find.
I'll set the ticket as waiting for your reply. This should keep it open of two weeks. You will receive a first notification in one week and a couple of other notifications before it gets closed.
I'll be looking forward to know what you get.
Hello!
I'm making these edits tonight. Since we have several versions of these files (like "info") for different post types, I ran into some cases with two kinds of formatting on these lines. In "info-game.php," for instance, both of these exists:
<?php $genre = types_render_field( 'game-genre', $post->ID, true );
<?php $platforms = get_the_terms( $post->ID, 'platform', true );
Would I still get rid of the post->ID and 'true' despite the different order of the arguments?
Yes, you must get rid of post->ID and 'true' in types_render_field. Because the function accepts only two arguments, the first is the field slug, and the second is an array of options. Check more examples on this documentation https://toolset.com/documentation/customizing-sites-using-php/functions/