Skip to content

Commit

Permalink
#2766 load tables for new job queue correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Pollock committed Nov 19, 2018
1 parent 6859891 commit 3365fff
Show file tree
Hide file tree
Showing 1,785 changed files with 1,482 additions and 302,708 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Probably don't use these directly. They will change. Must be prefaced with `dock

#### Steps
* Build release file
- `npm package`
- `npm run package`
* Push Tag to WordPress.org
- `cd bin`
- `bash deploy-wp-org-tag.sh 12345 christiechirinos`
Expand All @@ -149,13 +149,8 @@ Probably don't use these directly. They will change. Must be prefaced with `dock
* The first argument is password, which is required. The second argument is username, which defaults to `Shelob9`, which is Josh's username.

## Contributing/ Using This Repo, Etc.
* The default branch is "master" that should be the same as WordPress.org.
* Development happens on the "develop" branch. [There may be an exception, see: https://github.com/CalderaWP/Caldera-Forms/blob/master/CONTRIBUTING.md#current-git-workflow--php-compatibility](https://github.com/CalderaWP/Caldera-Forms/blob/master/CONTRIBUTING.md#current-git-workflow--php-compatibility)
* If you find a bug, or would like to make a feature request, [please open an issue](https://github.com/CalderaWP/Caldera-Forms/issues/).
* If you fixed a bug, or made a new feature, please submit a pull request against the develop branch.
[Contributing Guide](https://github.com/CalderaWP/Caldera-Forms/blob/master/CONTRIBUTING.md)


## Contributing/ Using This Repo, Etc.
* The default branch is "master" that should be the same as WordPress.org.
* Development happens on the "develop" branch.
* If you find a bug, or would like to make a feature request, [please open an issue](https://github.com/CalderaWP/Caldera-Forms/issues/).
Expand Down
2 changes: 1 addition & 1 deletion assets/build/css/caldera-forms-front.min.css

Large diffs are not rendered by default.

31 changes: 2 additions & 29 deletions assets/css/caldera-forms-front.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/caldera-forms-front.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! GENERATED SOURCE FILE caldera-forms - v1.7.4 - 2018-11-19 *//**
/*! GENERATED SOURCE FILE caldera-forms - v1.8.0-alpha.1 - 2018-11-19 *//**
* Simple event bindings for form state
*
* In general, access through CFState.events() not directly.
Expand Down
2 changes: 1 addition & 1 deletion assets/js/entry-viewer-2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! GENERATED SOURCE FILE caldera-forms - v1.7.4 - 2018-11-19 *//**
/*! GENERATED SOURCE FILE caldera-forms - v1.8.0-alpha.1 - 2018-11-19 *//**
* API Client for Caldera Forms API for a single form
*
* @since 1.5.0
Expand Down
2 changes: 1 addition & 1 deletion assets/js/parsley.min.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! GENERATED SOURCE FILE caldera-forms - v1.7.4 - 2018-11-19 *//*!
/*! GENERATED SOURCE FILE caldera-forms - v1.8.0-alpha.1 - 2018-11-19 *//*!
* Parsley.js
* Version 2.8.1 - built Sat, Feb 3rd 2018, 2:27 pm
* http://parsleyjs.org
Expand Down
2 changes: 1 addition & 1 deletion assets/js/vue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! GENERATED SOURCE FILE caldera-forms - v1.7.4 - 2018-11-19 *//*!
/*! GENERATED SOURCE FILE caldera-forms - v1.8.0-alpha.1 - 2018-11-19 *//*!
* Vue.js v2.1.6
* (c) 2014-2016 Evan You
* Released under the MIT License.
Expand Down
256 changes: 128 additions & 128 deletions caldera-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,129 +12,131 @@


// If this file is called directly, abort.
if (!defined('WPINC')) {
die;
if ( !defined('WPINC') ) {
die;
}


global $wp_version;
if (!version_compare(PHP_VERSION, '5.6.0', '>=')) {
function caldera_forms_php_version_nag()
{
?>
if ( !version_compare(PHP_VERSION, '5.6.0', '>=') ) {
function caldera_forms_php_version_nag()
{
?>
<div class="notice notice-error">
<p>
<?php _e('Your version of PHP is incompatible with Caldera Forms and can not be used.', 'caldera-forms'); ?>
<?php printf(' <a href="https://calderaforms.com/php?utm_source=wp-admin&utm_campaign=php_deprecated&utm_source=admin-nag" target="__blank">%s</a>',
esc_html__('Learn More', 'caldera-forms')
) ?></p>
<?php _e('Your version of PHP is incompatible with Caldera Forms and can not be used.',
'caldera-forms'); ?>
<?php printf(' <a href="https://calderaforms.com/php?utm_source=wp-admin&utm_campaign=php_deprecated&utm_source=admin-nag" target="__blank">%s</a>',
esc_html__('Learn More', 'caldera-forms')
) ?></p>
</div>
<?php
}

add_shortcode('caldera_form', 'caldera_forms_fallback_shortcode');
add_shortcode('caldera_form_modal', 'caldera_forms_fallback_shortcode');
add_action('admin_notices', 'caldera_forms_php_version_nag');
} elseif (!version_compare($wp_version, '4.7.0', '>=')) {
function caldera_forms_wp_version_nag()
{
?>
<?php
}

add_shortcode('caldera_form', 'caldera_forms_fallback_shortcode');
add_shortcode('caldera_form_modal', 'caldera_forms_fallback_shortcode');
add_action('admin_notices', 'caldera_forms_php_version_nag');
} elseif ( !version_compare($wp_version, '4.7.0', '>=') ) {
function caldera_forms_wp_version_nag()
{
?>
<div class="notice notice-error">
<p>
<?php _e('Your version of WordPress is incompatible with Caldera Forms and can not be used.', 'caldera-forms'); ?>
<?php _e('Your version of WordPress is incompatible with Caldera Forms and can not be used.',
'caldera-forms'); ?>
</p>
</div>
<?php
}
<?php
}

add_shortcode('caldera_form', 'caldera_forms_fallback_shortcode');
add_shortcode('caldera_form_modal', 'caldera_forms_fallback_shortcode');
add_action('admin_notices', 'caldera_forms_wp_version_nag');
add_shortcode('caldera_form', 'caldera_forms_fallback_shortcode');
add_shortcode('caldera_form_modal', 'caldera_forms_fallback_shortcode');
add_action('admin_notices', 'caldera_forms_wp_version_nag');
} else {

define('CFCORE_PATH', plugin_dir_path(__FILE__));
define('CFCORE_URL', plugin_dir_url(__FILE__));
define( 'CFCORE_VER', '1.8.0-alpha.1' );
define('CFCORE_EXTEND_URL', 'https://api.calderaforms.com/1.0/');
define('CFCORE_BASENAME', plugin_basename(__FILE__));

/**
* Caldera Forms DB version
*
* @since 1.3.4
*
* PLEASE keep this an integer
*/
define('CF_DB', 7);

// init internals of CF
include_once CFCORE_PATH . 'classes/core.php';

add_action('init', array('Caldera_Forms', 'init_cf_internal'));
// table builder
register_activation_hook(__FILE__, array('Caldera_Forms', 'activate_caldera_forms'));


// load system
add_action('plugins_loaded', 'caldera_forms_load', 0);
function caldera_forms_load()
{
include_once CFCORE_PATH . 'classes/autoloader.php';
include_once CFCORE_PATH . 'classes/widget.php';
Caldera_Forms_Autoloader::add_root('Caldera_Forms_DB', CFCORE_PATH . 'classes/db');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Entry', CFCORE_PATH . 'classes/entry');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Email', CFCORE_PATH . 'classes/email');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Admin', CFCORE_PATH . 'classes/admin');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Render', CFCORE_PATH . 'classes/render');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Sync', CFCORE_PATH . 'classes/sync');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_CSV', CFCORE_PATH . 'classes/csv');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Processor_Interface', CFCORE_PATH . 'processors/classes/interfaces');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_API', CFCORE_PATH . 'classes/api');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Field', CFCORE_PATH . 'classes/field');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Magic', CFCORE_PATH . 'classes/magic');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Processor', CFCORE_PATH . 'processors/classes');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Shortcode', CFCORE_PATH . 'classes/shortcode');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_CDN', CFCORE_PATH . 'classes/cdn');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Settings', CFCORE_PATH . 'classes/settings');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Import', CFCORE_PATH . 'classes/import');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Query', CFCORE_PATH . 'classes/query');
Caldera_Forms_Autoloader::add_root('Caldera_Forms', CFCORE_PATH . 'classes');
Caldera_Forms_Autoloader::register();


// includes
include_once CFCORE_PATH . 'includes/ajax.php';
include_once CFCORE_PATH . 'includes/field_processors.php';
include_once CFCORE_PATH . 'includes/custom_field_class.php';
include_once CFCORE_PATH . 'includes/filter_addon_plugins.php';
include_once CFCORE_PATH . 'includes/compat.php';
include_once CFCORE_PATH . 'processors/functions.php';
include_once CFCORE_PATH . 'includes/functions.php';
include_once CFCORE_PATH . 'ui/blocks/init.php';
include_once CFCORE_PATH . 'vendor/autoload.php';
include_once CFCORE_PATH . 'includes/cf-pro-client/cf-pro-init.php';

/**
* Runs after all of the includes and autoload setup is done in Caldera Forms core
*
* @since 1.3.5.3
*/
do_action('caldera_forms_includes_complete');
define('CFCORE_PATH', plugin_dir_path(__FILE__));
define('CFCORE_URL', plugin_dir_url(__FILE__));
define('CFCORE_VER', '1.8.0-alpha.1');
define('CFCORE_EXTEND_URL', 'https://api.calderaforms.com/1.0/');
define('CFCORE_BASENAME', plugin_basename(__FILE__));

/**
* Caldera Forms DB version
*
* @since 1.3.4
*
* PLEASE keep this an integer
*/
define('CF_DB', 7);

// init internals of CF
include_once CFCORE_PATH . 'classes/core.php';

add_action('init', [ 'Caldera_Forms', 'init_cf_internal' ]);
// table builder
register_activation_hook(__FILE__, [ 'Caldera_Forms', 'activate_caldera_forms' ]);


// load system
add_action('plugins_loaded', 'caldera_forms_load', 0);
function caldera_forms_load()
{
include_once CFCORE_PATH . 'classes/autoloader.php';
include_once CFCORE_PATH . 'classes/widget.php';
Caldera_Forms_Autoloader::add_root('Caldera_Forms_DB', CFCORE_PATH . 'classes/db');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Entry', CFCORE_PATH . 'classes/entry');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Email', CFCORE_PATH . 'classes/email');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Admin', CFCORE_PATH . 'classes/admin');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Render', CFCORE_PATH . 'classes/render');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Sync', CFCORE_PATH . 'classes/sync');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_CSV', CFCORE_PATH . 'classes/csv');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Processor_Interface', CFCORE_PATH . 'processors/classes/interfaces');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_API', CFCORE_PATH . 'classes/api');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Field', CFCORE_PATH . 'classes/field');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Magic', CFCORE_PATH . 'classes/magic');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Processor', CFCORE_PATH . 'processors/classes');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Shortcode', CFCORE_PATH . 'classes/shortcode');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_CDN', CFCORE_PATH . 'classes/cdn');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Settings', CFCORE_PATH . 'classes/settings');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Import', CFCORE_PATH . 'classes/import');
Caldera_Forms_Autoloader::add_root('Caldera_Forms_Query', CFCORE_PATH . 'classes/query');
Caldera_Forms_Autoloader::add_root('Caldera_Forms', CFCORE_PATH . 'classes');
Caldera_Forms_Autoloader::register();


// includes
include_once CFCORE_PATH . 'includes/ajax.php';
include_once CFCORE_PATH . 'includes/field_processors.php';
include_once CFCORE_PATH . 'includes/custom_field_class.php';
include_once CFCORE_PATH . 'includes/filter_addon_plugins.php';
include_once CFCORE_PATH . 'includes/compat.php';
include_once CFCORE_PATH . 'processors/functions.php';
include_once CFCORE_PATH . 'includes/functions.php';
include_once CFCORE_PATH . 'ui/blocks/init.php';
include_once CFCORE_PATH . 'vendor/autoload.php';
include_once CFCORE_PATH . 'includes/cf-pro-client/cf-pro-init.php';

/**
* Runs after all of the includes and autoload setup is done in Caldera Forms core
*
* @since 1.3.5.3
*/
do_action('caldera_forms_includes_complete');

caldera_forms_get_v2_container();
}
}

add_action('plugins_loaded', array('Caldera_Forms', 'get_instance'));
add_action('plugins_loaded', [ 'Caldera_Forms', 'get_instance' ]);


add_filter( 'caldera_forms_render_assets_minify', '__return_false' );
add_filter('caldera_forms_render_assets_minify', '__return_false');

// Admin & Admin Ajax stuff.
if (is_admin() || defined('DOING_AJAX')) {
add_action('plugins_loaded', array('Caldera_Forms_Admin', 'get_instance'));
add_action('plugins_loaded', array('Caldera_Forms_Support', 'get_instance'));
include_once CFCORE_PATH . 'includes/plugin-page-banner.php';
}
// Admin & Admin Ajax stuff.
if ( is_admin() || defined('DOING_AJAX') ) {
add_action('plugins_loaded', [ 'Caldera_Forms_Admin', 'get_instance' ]);
add_action('plugins_loaded', [ 'Caldera_Forms_Support', 'get_instance' ]);
include_once CFCORE_PATH . 'includes/plugin-page-banner.php';
}


}
Expand All @@ -148,11 +150,11 @@ function caldera_forms_load()
*/
function caldera_forms_fallback_shortcode()
{
if (current_user_can('edit_posts')) {
return esc_html__('Your version of WordPress or PHP is incompatible with Caldera Forms.', 'caldera-forms');
}
if ( current_user_can('edit_posts') ) {
return esc_html__('Your version of WordPress or PHP is incompatible with Caldera Forms.', 'caldera-forms');
}

return esc_html__('Form could not be loaded. Contact the site administrator.', 'caldera-forms');
return esc_html__('Form could not be loaded. Contact the site administrator.', 'caldera-forms');

}

Expand All @@ -163,13 +165,12 @@ function caldera_forms_fallback_shortcode()
*
* @TODO move this somewhere smarter
*/
add_filter('caldera_forms_render_get_field', function($field, $form){
if( 'advanced_file' === Caldera_Forms_Field_Util::get_type($field,$form) ){
$field['type'] = \calderawp\calderaforms\cf2\Fields\FieldTypes\FileFieldType::getCf1Identifier();
add_filter('caldera_forms_render_get_field', function ($field, $form) {
if ( 'advanced_file' === Caldera_Forms_Field_Util::get_type($field, $form) ) {
$field[ 'type' ] = \calderawp\calderaforms\cf2\Fields\FieldTypes\FileFieldType::getCf1Identifier();
}
return $field;
},1,2);

}, 1, 2);


/**
Expand All @@ -179,29 +180,28 @@ function caldera_forms_fallback_shortcode()
*
* @TODO move this somewhere smarter
*/
add_action( 'caldera_forms_v2_init', function(\calderawp\calderaforms\cf2\CalderaFormsV2Contract $container){

$container
//Set paths
->setCoreDir(CFCORE_PATH)
->setCoreUrl(CFCORE_URL )
add_action('caldera_forms_v2_init', function (\calderawp\calderaforms\cf2\CalderaFormsV2Contract $container) {

//Setup field types
->getFieldTypeFactory()
->add( new \calderawp\calderaforms\cf2\Fields\FieldTypes\FileFieldType() );

//Add hooks
$container
//Set paths
->setCoreDir(CFCORE_PATH)
->setCoreUrl(CFCORE_URL)
//Setup field types
->getFieldTypeFactory()
->add(new \calderawp\calderaforms\cf2\Fields\FieldTypes\FileFieldType());

//Add hooks
$container->getHooks()->subscribe();

//Register other services
$container
->registerService(new \calderawp\calderaforms\cf2\Services\QueueService(),true )
->registerService(new \calderawp\calderaforms\cf2\Services\QueueSchedulerService(),true );
->registerService(new \calderawp\calderaforms\cf2\Services\QueueService(), true)
->registerService(new \calderawp\calderaforms\cf2\Services\QueueSchedulerService(), true);

//Run the scheduler with CRON
/** @var \calderawp\calderaforms\cf2\Jobs\Scheduler $scheduler */
$scheduler = $container->getService(\calderawp\calderaforms\cf2\Services\QueueSchedulerService::class);
$running = $scheduler->runWithCron();
/** @var \calderawp\calderaforms\cf2\Jobs\Scheduler $scheduler */
$scheduler = $container->getService(\calderawp\calderaforms\cf2\Services\QueueSchedulerService::class);
$running = $scheduler->runWithCron();

});

Expand Down
7 changes: 7 additions & 0 deletions classes/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,12 @@ public static function init_cf_internal()
*/
public static function activate_caldera_forms($force = false)
{

//if running on activation hook, load order is wrong.
if( ! did_action( 'caldera_forms_includes_complete' ) ){
caldera_forms_load();
}

include_once CFCORE_PATH . 'includes/updater.php';
$version = caldera_forms_get_last_update_version();

Expand All @@ -496,6 +502,7 @@ public static function activate_caldera_forms($force = false)
foreach ($columns as $column) {
$fields[] = $column['Field'];
}

if (!in_array('field_id', $fields)) {
$wpdb->query("ALTER TABLE `" . $wpdb->prefix . "cf_form_entry_values` ADD `field_id` varchar(20) NOT NULL AFTER `entry_id`;");
$wpdb->query("CREATE INDEX `field_id` ON `" . $wpdb->prefix . "cf_form_entry_values` (`field_id`); ");
Expand Down
2 changes: 1 addition & 1 deletion classes/db/tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ public function get_missing_tables(){
protected function find_missing_tables(){
$tables = $this->wpdb->get_results( "SHOW TABLES", ARRAY_A );
$alltables = array();

foreach ( $tables as $table ) {
$alltables[] = implode( $table );
}


$missing_tables = array();
foreach ( $this->get_tables_list() as $cf_table ){
if( ! in_array( $cf_table, $alltables ) ){
Expand Down
Loading

0 comments on commit 3365fff

Please sign in to comment.