I can’t reproduce this on my end. I always get an entry in the debug.log or error.log.
The question is, how is the class initiated? I have used the following minimal example with and without activated debugging:
class mytest {
function __construct() {
add_filter( 'upgrader_post_install', [ $this, 'check_update' ], 10, 3 );
}
public function check_update( $response, $hook_extra, $result ) {
error_log( 'called' );
}
}
new mytest();
@threadi Oh, really. Sorry for that.
I’ll investigate the condition for reproducing and write again.
Thank you!
After testing some cases, I have a question.
“upgrader_post_install” and “upgrader_process_complete” hook is fired on update only in case that the older version plugin has them?
When a plugin is to be updated and it needs some new options, I think the author will want to add a hook that will be fired on update to the newer version file.
In those cases, “upgrader_post_install” and “upgrader_process_complete” hook seems not active.
Is this interpretation right?
If so, what should we do in such cases?
If it’s appropriate to talk this in an other topic, I would do so.
Thanks.
Then in my situation, somehow what should work is simply not working.
In actual, both hooks behaved similar for several times as I wrote in the previous comment…
For this time, I managed to find a next best way to fill my necessity.
If I notice the reason I’ll write again.
Thank you very much!
I’ll close this topic since the title thing is understood as not be able to be reproduced.
Thanks!
Hi,
I am using WP 6.1.1 and potentially have the same or a similar issue to @trustring . I am running the following code in my plugin.php file:
add_action( 'upgrader_post_install', 'yd_upgrader_process_complete', 10, 3 );
function yd_upgrader_process_complete( $upgrader_object, $hook_extra, $result ) {
if ( $result['destination_name'] === 'yd' ) {
error_log('Yd was updated, rebuilding sitemap and merchant feed..2345');
$Yd = new Yd();
$Yd->yd_sitemap();
}
}
What is really strange is that this code executes using the previous version of the plugins code, which is I think the same issue that the original poster described.
For example if I were to change the numbers at the end of the error_log and then upload this file, the error log would show the previous set of numbers. If I uploaded the same file for a second time then it would show the updated [correct] set of numbers.
In the example that @threadi gave, there is a small chance that because he is calling the same error log, he may actually be calling the older version without realising..or not, but it would be very interesting to know;
1. @trustring did you manage to get this fixed?
2. @threadi are you able to double check my theory?
Spent around 5 hours on this now and it’s driving me insane 🙂
Thanks