Commit 7e531c38 authored by KR Moorhouse's avatar KR Moorhouse

Updated get_option references to the cache with our own helper method to check...

Updated get_option references to the cache with our own helper method to check the upgrade table first.
parent 9c98c094
......@@ -66,7 +66,7 @@ class NF_AJAX_Controllers_Submission extends NF_Abstracts_Controller
$this->_respond();
}
} else {
$this->_form_cache = get_option( 'nf_form_' . $this->_form_id );
$this->_form_cache = WPN_Helper::get_nf_cache( $this->_form_id );
}
// TODO: Update Conditional Logic to preserve field ID => [ Settings, ID ] structure.
......
......@@ -255,7 +255,7 @@ class NF_Abstracts_Model
}
if( ! $this->_settings ) {
$form_cache = get_option('nf_form_' . $this->_parent_id);
$form_cache = WPN_Helper::get_nf_cache( $this->_parent_id );
if ($form_cache) {
if ('field' == $this->_type) {
......
......@@ -67,7 +67,7 @@ class NF_Abstracts_ModelFactory
$this->_object = $this->_form = new NF_Database_Models_Form( $this->_db, $id );
$form_cache = get_option( 'nf_form_' . $id, false );
$form_cache = WPN_Helper::get_nf_cache( $id );
if( $form_cache && isset ( $form_cache[ 'settings' ] ) ){
$this->_object->update_settings( $form_cache[ 'settings' ] );
......@@ -230,7 +230,7 @@ class NF_Abstracts_ModelFactory
if( $where || $fresh || ! $this->_fields ){
$form_cache = get_option( 'nf_form_' . $form_id, false );
$form_cache = WPN_Helper::get_nf_cache( $form_id );
if( ! $form_cache ) {
$model_shell = new NF_Database_Models_Field($this->_db, 0);
......
......@@ -160,7 +160,7 @@ class NF_Admin_CPT_Submission
'id' => __( '#', 'ninja-forms' ),
);
$form_cache = get_option( 'nf_form_' . $form_id );
$form_cache = WPN_Helper::get_nf_cache( $form_id );
$form_fields = Ninja_Forms()->form( $form_id )->get_fields();
......
......@@ -265,7 +265,7 @@ final class NF_Admin_Menus_Forms extends NF_Abstracts_Menu
if( ! $form->get_tmp_id() ) {
if( $form_cache = get_option( 'nf_form_' . $form_id, false ) ) {
if( $form_cache = WPN_Helper::get_nf_cache( $form_id ) ) {
$fields = $form_cache[ 'fields' ];
} else {
$fields = ($form_id) ? Ninja_Forms()->form($form_id)->get_fields() : array();
......
......@@ -260,6 +260,21 @@ final class WPN_Helper
}
return $original;
}
/**
* Function to fetch our cache from the upgrades table (if it exists there).
*/
public static function get_nf_cache( $id ) {
global $wpdb;
$sql = "SELECT cache FROM `{$wpdb->prefix}nf3_upgrades` WHERE id = " . intval( $id );
$result = $wpdb->get_results( $sql, 'ARRAY_A' );
if ( ! empty( $result ) ) {
return $result[ 0 ][ 'cache' ];
}
else {
return get_option( 'nf_form_' . $id );
}
}
private static function parse_utf8_serialized( $matches )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment