Skip Navigation

[Resuelto] Problems with the unicorn assistant plugin and Toolset

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem: I'm shown a notice in the PHP logs:
-------------------------------
Trying to get property of non-object
Type: PHP Notice Line: 116
File: /path/to/wp-content/plugins/unicorn-assistant/unicorn-assistant.php
-------------------------------

I have spoken with the support people of the unicorn assistant plugin and they have told me that it is a 'Toolset' problem:
"One can hide the notice, but it will only hide it and not deal with the problem with posts and post-type property, which is most likely coming from Toolsets. "

Solution: I'm not clear why the Unicorn Assistant team thinks this is a Toolset problem. After doing some additional investigation, it appears this has nothing to do with Toolset. When Toolset plugins are all disabled and no Toolset API PHP code is executed, this notice still appears when you add the following product to your shopping cart: /producto/jfcontrols-developer/

This support ticket is created hace 6 años, 11 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Etiquetado: 

Este tema contiene 9 respuestas, tiene 2 mensajes.

Última actualización por Francisco Ramón Molina Busquiel hace 6 años, 11 meses.

Asistido por: Christian Cox.

Autor
Mensajes
#599316
2017-12-15_15-52-16.jpg

In the wordpress log it is shown a notice indicating the following:
-------------------------------
Trying to get property of non-object
Type: PHP Notice Line: 116
File: /var/www/vhosts/sendasoft.com/httpdocs/es/wp-content/plugins/unicorn-assistant/unicorn-assistant.php
-------------------------------

I have spoken with the support people of the unicorn assistant plugin and they have told me that it is a 'Toolset' problem:
"One can hide the notice, but it will only hide it and not deal with the problem with posts and post-type property, which is most likely coming from Toolsets. "

Thanks for your help.

Best regards,
Francisco R.

#599611

From Beda:

I remember having seen this error on your site, I actually reported it to you: https://toolset.com/forums/topic/problems-with-the-rendering-of-views-in-footer-woocommerce-products/page/2/#post-598623

But, even on the same site which I still have deployed, I cannot see the error anymore (but that is after the steps of that ticket there, and then re-eanbling the unicorn plugin).

I also tried to replicate it on a fresh install at no avail.

We need the exact steps to replicate this issue to analyze it.

The code that is offended, is failing on a comparison of post type:

$post->post_type == 'post'

The global $post is correctly declared and hence $post should be an object. Why it is not, is not clear to me as I cannot replicate the issue.

I see that the code wants to return values for an AVATAR on Blog Modules, and I tried to use the blog module of DIVI but could not see any output for the related code of Unicorn.

How do we replicate the problem?

BTW, if you can test on a development environment, I suggest to change the filter's priority in Unicorn code (currently 10) to see if that changes the issue. The code is in the plugin "Unicorn Assistant" in the file unicorn-assistant.php line 135.

I suggest to either decrease or increase priority to see if this affects the error output.

It is very strange that $post here is not an object.

But then, I must honestly say, this code needs a refactor. You can never (!) assume the properties of a variable in PHP.

It may fail for whatever reason. Yes, - it could be that another plugin is breaking the global. But still the code should be written in a way that IF this happens, the own code does not break.

We do that. I report such issue to our developers versa often and even if reluctantly (as it seems pointless) the changes get implemented, because this ensures safe and validated code.

For example the Plugin's specific function here should check if $post is an object, before trying to access it's properties:

function load_unicorn_avatars($title) {
     
        global $post;
      // echo $post->post_title .' '.$post->post_type.'';
        if (is_object($post) && ($post->post_type == 'post')) {
           //print_r($post);
            if($post->post_author) {
                $authorId = $post->post_author;
               $dataAvatar = '';
                return $title.$dataAvatar;
            }
            else return 'asshole';
        } else return 'asshole';
}
 
if (!is_admin()){ add_filter('the_title', 'load_unicorn_avatars', 10, 2); }

This would ensure not to throw a notice if there is no object.

I am not ping pong-ing this issue back to the other Developer, but I point out that the issue should also be addressed there for the safety of code.

Once I have steps how to replicate this - we will check why it fails and if this needs an update in Toolset.

Thank you for understanding and providing the additional informations

#599632

It's funny, I'm trying to reproduce the problem, but now it's not possible for me.
I'll have it under observation to see if it shows up again in the wordpress log.
I will tell you something.
Thanks for your help Christiaan.

#599991
2017-12-18_18-29-14.jpg

Have you connected the PHP stack trace to my site?
The error of unicorn assistant has reoccurred.
Look at the screenshot to see if it offers you some details to find out the problem.
If I'm not mistaken it has occurred after simulating the completion of an order through my site.

Thanks for your help Christiaan.

#600023

I am able to see this issue but after further investigation I can tell it is not related to Toolset. To confirm, you can follow these steps:

- Disable all plugins except WooCommerce and Unicorn Assistant.
- In wp-config.php comment out your debugging settings and enable basic logs with this code:

define('WP_DEBUG', true);
ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

- In your theme functions.php comment out line 198 where you add the raw-ct shortcode. Then in the front-end of the site go to /producto/jfcontrols-developer/ and add the product to your empty shopping cart. The notice will be logged to the PHP log in error_log.txt:

[18-Dec-2017 20:40:07 UTC] PHP Notice:  Trying to get property of non-object in /path/to/wp-content/plugins/unicorn-assistant/unicorn-assistant.php on line 116

This has nothing to do with Toolset, because all the Toolset code has been disabled and it still occurs. It is a problem the Unicorn Assistant developers should address.

#600161
2017-12-19_11-02-51.jpg

I do not have the lines that you indicate of 'init_set'.
You know why is the stack trace showing me?
How can I disconnect it?

#600296

I'm not really the best source of information about another plugin, but it's clear this stack trace is appearing because of the notice generated by the Unicorn Assistant plugin. PHP dumps the stack trace, so you can see where the notice is being triggered for debugging purposes. I guess this log plugin interprets each line of the stack trace as a different message, so you see it displayed one line at a time in the log.

#600298

But before this did not happen, that kind of messages were not shown, I do not know who has connected this type of messages, this is not the unicorn plugin.

#600306

But before this did not happen, that kind of messages were not shown
What about these settings in your wp-config.php file?

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
//define('ET_DEBUG', true);

//error_reporting(E_ALL);
//ini_set('display_error',1);

I see comments, which typically indicate changes have been made. Those changes could modify the logs in your log plugin. Again, I am not the best source of information about another plugin.

#600800

Thanks Christiaan.