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

Abstract Block class not updating ACF fields #200

Open
Fcog opened this issue Jun 23, 2020 · 5 comments
Open

Abstract Block class not updating ACF fields #200

Fcog opened this issue Jun 23, 2020 · 5 comments
Assignees
Labels

Comments

@Fcog
Copy link
Contributor

Fcog commented Jun 23, 2020

I've found, since the implementation of the Abstract block class, very difficult to see the changes when the get_fields() function is changed.
For some reason this implementation doesn't let see the changes immediately.
For example, if I update the ACF fields for a block, and then update the function get_fields() from the block file, the changes don't appear.
Sometimes I have to wait hours to see the change reflected.

@Fcog Fcog added the bug label Jun 23, 2020
@adamf321
Copy link
Member

Hi Fran, can you please explain this with a code sample? Does this only happen on local or on the server too? It also sounds like a cache issue, so can you check that object caching, etc is deactivated.

@Fcog
Copy link
Contributor Author

Fcog commented Jun 24, 2020

`class Accordion extends AbstractBlock {

/**
 * Register the block.
 *
 * @return array
 */
public function register() : array {
	return $this->do_registration(
		[
			'description'       => 'Adds an accordion to your page.',
			'icon'              => 'sort',
			'category'          => 'common-blocks',
			'template_type'     => 'molecule',
			'template_name'     => 'accordion/accordion',
			'wrapper_elem'      => 'div',
			'alignment_options' => true,
		]
	);
}

/**
 * Re-format the fields to the format required by the UI component.
 *
 * @param array   $block The block settings and attributes.
 * @param string  $content The block inner HTML (empty).
 * @param boolean $is_preview $is_preview True during AJAX preview.
 * @param integer $post_id Id of the current post.
 * @return array
 */
protected function get_fields( array $block, string $content, bool $is_preview, int $post_id ) : array {
	return [
		'items' => get_field( 'items' ) ?? [],
	];
}

}
`

if I initially create the above block, and then I want to change any data of the arguments of the functions do_registration() or the get_fields(), the change is not reflected.

for example, when changing the alignment, the ui template or the acf key:

`class Accordion extends AbstractBlock {

/**
 * Register the block.
 *
 * @return array
 */
public function register() : array {
	return $this->do_registration(
		[
			'description'       => 'Adds an accordion to your page.',
			'icon'              => 'sort',
			'category'          => 'common-blocks',
			'template_type'     => 'molecule',
			'template_name'     => 'accordion/accordion2',
			'wrapper_elem'      => 'div',
			'alignment_options' => false,
		]
	);
}

/**
 * Re-format the fields to the format required by the UI component.
 *
 * @param array   $block The block settings and attributes.
 * @param string  $content The block inner HTML (empty).
 * @param boolean $is_preview $is_preview True during AJAX preview.
 * @param integer $post_id Id of the current post.
 * @return array
 */
protected function get_fields( array $block, string $content, bool $is_preview, int $post_id ) : array {
	return [
		'items' => get_field( 'items_2' ) ?? [],
	];
}

}`

I've tried clearing the cache by adding this to the lando file (then restarting lando):
cache: false
edge: false

but it doesn't work.

The only way the changes take effect is when I restart lando or wating a long time.

@adamf321
Copy link
Member

adamf321 commented Jun 24, 2020 via email

@Fcog
Copy link
Contributor Author

Fcog commented Jun 24, 2020

yes, I added this 2 no cache flag to the lando file:

cache: false
edge: false

I initially thought it had solved the issue

@adamf321
Copy link
Member

adamf321 commented Jun 25, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants