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
variable-set not auto-detecting integer types? #378
Comments
Well, the issue you quote was really intended for the variable-get case, but the documentation does pretty much imply that "auto" format should work for variable-set as well. The issue is that "auto" uses "is_integer()" to determine whether the value is an integer or not; with variable-set, since the value came from the command line, it will always be a string. To make this work right with variable-set, we'd have to switch this test to "is_numeric()" instead; however, that would then give the wrong result with variable-get in instances where there are string-type variables that happen to have numeric values. Today, you must use --format=integer, or maybe |
I hadn't thought about the case where you'd actually want to store a string representation of numbers. Agreed that trying to interpret the string numbers as integers could cause additional confusion. What I'm trying to do is extend the "sync_enable" extension included with drush to work with setting variables as well, so that after an sql-sync from prod to dev, I can set arbitrary system variables, like turning off CSS and JS aggregation. I'm currently doing it like this:
Since the numbers are actually coming in from the config and not command line, I should have no problem because they are represented as numbers in PHP to begin with. I think my problem is that Do you have recommendation on how to get around this? Maybe I can try using drush_invoke_process but invoke |
Have you tried the --format option for vset?. Otherwise, php-eval would work. |
The sync_enable hook does not include a facility for setting variables because you can do this in settings.php. I put the following in my dev sites' settings files once, and then I am done:
|
@weitzman - I'd have to predetermine what kind of data I'm getting from the drush alias settings and then set the appropriate format in the @greg-1-anderson - Thanks - forgot I could do that. I'll abandon my current approach in favor of that. |
May be related but just realized in order to set a field to negative 1 I had to do this:
This worked fine but seems needlessly complex. Also, you can't spider this call (like against an @sites for example) unless someone else knows how to do that |
@btopro is --format=integer not working for you with |
just updated to drush 6.3, now I get an error
|
That's a fairly serious limitation all right. You could use php-eval (ev) instead:
I'm not sure how in the general case we should allow the user to specify argument names that start with a "-". For the specific case of vset, perhaps we could support |
ended up doing What I found odd is that it was evaluating "-1" as -1 as --1 :) It seemed to me that drush vset thing "-1" should have worked but it hopped right over the quotes. |
Drush treats -v and --v the same, and then throws away the leading dashes. The quotes are only for the benefit of the shell; they are gone before Drush gets them. |
I get the feeling that this has been reported numerous times before, but I can't find anything in the github issues (just old Drupal.org posts).
When I try setting a variable
drush vset preprocess_css 0
Drush interprets the 0 as a string.
According to https://drupal.org/node/861026, this was fixed by adding auto detection of integers, but it doesn't seem to work? I see the code is there for it though: https://github.com/drush-ops/drush/blob/master/commands/core/variable.drush.inc#L218.
I'm on 6.2.0.
Am I missing something obvious?
The text was updated successfully, but these errors were encountered: