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

Possible logic mistake on Kirki_Field class #1429

Closed
danielortiz opened this issue Jun 26, 2017 · 1 comment
Closed

Possible logic mistake on Kirki_Field class #1429

danielortiz opened this issue Jun 26, 2017 · 1 comment

Comments

@danielortiz
Copy link
Contributor

danielortiz commented Jun 26, 2017

Issue description:

I was reading through Kirki's code to try to find out another problem (#1425) I'm having, and I found this piece of code:

		if ( is_array( $config_id ) && empty( $args ) ) {
			$args = $config_id;
			$this->kirki_config = 'global';
		} 
		$this->kirki_config = trim( esc_attr( $config_id ) );

(class-kirki-field.php, line 320)
It seems to me that this logic may cause errors if one do what it's actually trying to prevent.
The if statement is verifying if only$args are being passed (no config_id), and set the $this->kirki_config = 'global', but then, when it leaves the if statement, it reasign $this->kirki_config to the output of trim( esc_attr( $config_id ) ), which in the case the user didn't pass it, will be an array and will output an error.
Possible fix would be to put an elsestatement there

		if ( is_array( $config_id ) && empty( $args ) ) {
			$args = $config_id;
			$this->kirki_config = 'global';
		} else {
		    $this->kirki_config = trim( esc_attr( $config_id ) );
		}

I didn't test it, but that'd probably do the trick.

I'd put a PR for it, but I didn't see anybody doing PRs here beside the plugin authors and I'm not sure the proper way to do that. So let me know the guidelines for it, if it's possible

Version used:

(Did you try using the develop branch from github? There's a chance your issue has already been adressed there)
3.0.5
edit: same thing on 3.0.6

@aristath
Copy link
Contributor

Good catch! Fixed, will be included in 3.0.7 which will be released later today.
Thanks!

aristath added a commit that referenced this issue Jun 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants