Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always hook initialize_latest_version() #468

Closed
wants to merge 1 commit into from
Closed

Conversation

rrennick
Copy link
Contributor

See #464

This PR is to address

You need to explicitly require AS main file, and do it BEFORE composer autoload, like this:

require_once __DIR__ . '/vendor/woocommerce/action-scheduler/action-scheduler.php';
require_once __DIR__ . '/vendor/autoload.php';

If a Composer autoloader is already active in the containing plugin then the class_exists( 'ActionScheduler_Versions' ) check returns true. Because that check returns true, initialize_latest_version does not get hooked. Before adding a hook, WP checks whether it has already been hooked so adding a hook multiple times will not cause it to be executed multiple times.

Testing Instructions

add_action( 'init', function() {
	$action_id = as_schedule_single_action( time() + 50, 'function_check' );
} );
  • load the dashboard should produce a fatal error
  • copy action-scheduler.php from this branch to the woocommerce-admin/external/action-scheduler folder
  • dashboard should load
  • activate AS in this branch
  • there should be no errors in the debug log

@rrennick rrennick requested a review from jeffstieler February 18, 2020 15:46
@rrennick rrennick added the status: in progress This is being worked on. label Feb 18, 2020
@rrennick
Copy link
Contributor Author

I want to do some more testing with this ti verify it doesn't create the problem I outlined in #464 (comment)

@rrennick
Copy link
Contributor Author

I used 3 plugins where two had composer autoloading and version bumps as follows

  • AS - this branch
  • as-test version 3.2.1
  • woocommerce-admin version 3.1.2

I added error_log( __FILE__ ) in both the as_schedule_single_action and ActionScheduler_ActionFactory with this test snippet:

add_action( 'init', function() {
	error_log( ActionScheduler_Versions::instance()->latest_version() );
	$action_id = as_schedule_single_action( time() + 50, 'which_one' );
} );

The result was

[18-Feb-2020 17:19:17 UTC] 3.2.1
[18-Feb-2020 17:19:17 UTC] /Users/ronrennick/Sites/ron/wp-content/plugins/as-test/vendor/woocommerce/action-scheduler/functions.php
[18-Feb-2020 17:19:17 UTC] /Users/ronrennick/Sites/ron/wp-content/plugins/woocommerce-admin/external/action-scheduler/classes/ActionScheduler_ActionFactory.php

So, I'll leave this on hold for now pending further investigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: in progress This is being worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant