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

Using booleans as string values leads to strange results (Trac #633) #539

Closed
phing-issues-importer opened this Issue Oct 9, 2016 · 11 comments

Comments

3 participants
@phing-issues-importer

phing-issues-importer commented Oct 9, 2016

I'm using a ReplaceRegexp filter to change WordPress' wp-config.php file. In this file a constant WP_DEBUG is defined false and I would to change it to true. I have defined the regex and provided a property with a string "true". However this string will be casted to a bool and causes strange sideeffects.

Consider this build.xml example:

<property name="wp_config.wp_debug" value="true" />

<target name="setup-wp-config" description="Copies the wp-config-sample.php to wp-config.php and sets up the parameters for the audition test site">
    <copy file="./wp-config-sample.php" tofile="./wp-config.php">
      <filterchain>
        <replaceregexp>
          <regexp pattern="(define\('WP_DEBUG', )\w+(\);)" replace="\1${wp_config.wp_debug}\2"/>
        </replaceregexp>
      </filterchain>
    </copy>
  </target>

If you would run this it would not work as expected. Changing the property to "foo" it does work as expected. This is probably related to this thread:

http://phing.tigris.org/ds/viewMessage.do?dsForumId=1083&dsMessageId=958537

Using the workaround in the thread the example becomes:

<property name="wp_config.wp_debug" value="(bool)true" />

<target name="setup-wp-config" description="Copies the wp-config-sample.php to wp-config.php and sets up the parameters for the audition test site">
    <copy file="./wp-config-sample.php" tofile="./wp-config.php">
      <filterchain>
        <replaceregexp>
          <regexp pattern="(define\('WP_DEBUG', )\w+(\);)" replace="\1${wp_config.wp_debug}\2"/>
        </replaceregexp>
      </filterchain>
    </copy>
  </target>

Thus by adding the type (bool) forces Phing to work correctly with boolean values as strings. Thanks Hans Lellelid for this workaround!

Migrated from https://www.phing.info/trac/ticket/633

{
    "status": "reopened", 
    "changetime": "2016-10-07T08:28:55", 
    "description": "I'm using a ReplaceRegexp filter to change WordPress' wp-config.php file. In this file a constant WP_DEBUG is defined false and I would to change it to true. I have defined the regex and provided a property with a string \"true\". However this string will be casted to a bool and causes strange sideeffects.  \n\nConsider this build.xml example: \n\n<property name=\"wp_config.wp_debug\" value=\"true\" />\n\n<target name=\"setup-wp-config\" description=\"Copies the wp-config-sample.php to wp-config.php and sets up the parameters for the audition test site\">\n    <copy file=\"./wp-config-sample.php\" tofile=\"./wp-config.php\">\n      <filterchain>\n        <replaceregexp>\n          <regexp pattern=\"(define\\('WP_DEBUG', )\\w+(\\);)\" replace=\"\\1${wp_config.wp_debug}\\2\"/>\n        </replaceregexp>\n      </filterchain>\n    </copy>\n  </target>\n\nIf you would run this it would not work as expected. Changing the property to \"foo\" it does work as expected. This is probably related to this thread: \n\nhttp://phing.tigris.org/ds/viewMessage.do?dsForumId=1083&dsMessageId=958537\n\nUsing the workaround in the thread the example becomes: \n\n<property name=\"wp_config.wp_debug\" value=\"(bool)true\" />\n\n<target name=\"setup-wp-config\" description=\"Copies the wp-config-sample.php to wp-config.php and sets up the parameters for the audition test site\">\n    <copy file=\"./wp-config-sample.php\" tofile=\"./wp-config.php\">\n      <filterchain>\n        <replaceregexp>\n          <regexp pattern=\"(define\\('WP_DEBUG', )\\w+(\\);)\" replace=\"\\1${wp_config.wp_debug}\\2\"/>\n        </replaceregexp>\n      </filterchain>\n    </copy>\n  </target>\n\nThus by adding the type (bool) forces Phing to work correctly with boolean values as strings. Thanks Hans Lellelid for this workaround!\n\n", 
    "reporter": "burobjorn@gmail.com", 
    "cc": "", 
    "resolution": "", 
    "_ts": "1475828935569836", 
    "component": "phing-core", 
    "summary": "Using booleans as string values leads to strange results", 
    "priority": "critical", 
    "keywords": "regex, boolean", 
    "version": "2.4.4", 
    "time": "2011-01-20T09:13:15", 
    "milestone": "4.0", 
    "owner": "mp", 
    "type": "defect"
}
@phing-issues-importer

This comment has been minimized.

Show comment
Hide comment
@phing-issues-importer

phing-issues-importer Oct 9, 2016

Trac update at 20110619T05:55:15:

  • mp changed owner from "mrook" to "mp"
  • mp changed status from "new" to "assigned"

phing-issues-importer commented Oct 9, 2016

Trac update at 20110619T05:55:15:

  • mp changed owner from "mrook" to "mp"
  • mp changed status from "new" to "assigned"
@phing-issues-importer

This comment has been minimized.

Show comment
Hide comment
@phing-issues-importer

phing-issues-importer Oct 9, 2016

Trac update at 20110619T06:29:09: mp commented:

Also see #534, might be related

phing-issues-importer commented Oct 9, 2016

Trac update at 20110619T06:29:09: mp commented:

Also see #534, might be related

@phing-issues-importer

This comment has been minimized.

Show comment
Hide comment
@phing-issues-importer

phing-issues-importer Oct 9, 2016

Trac update at 20110621T10:35:32: mp commented:

#376 is also related but tried a fix in the ReplaceTokens task?

phing-issues-importer commented Oct 9, 2016

Trac update at 20110621T10:35:32: mp commented:

#376 is also related but tried a fix in the ReplaceTokens task?

@phing-issues-importer

This comment has been minimized.

Show comment
Hide comment
@phing-issues-importer

phing-issues-importer Oct 9, 2016

Trac update at 20110621T13:28:48: mp commented:

#383 might also be related

phing-issues-importer commented Oct 9, 2016

Trac update at 20110621T13:28:48: mp commented:

#383 might also be related

@phing-issues-importer

This comment has been minimized.

Show comment
Hide comment
@phing-issues-importer

phing-issues-importer Oct 9, 2016

Trac update at 20110622T09:20:32: mp commented:

(In [1177]) Remove automagical conversion of strings to booleans. See http://phing.tigris.org/ds/viewMessage.do?dsForumId=1079&dsMessageId=2771568.

Refs #539, #534, https://www.phing.info/trac/ticket/376, #533.

Introduces a BC break for existing tasks.

phing-issues-importer commented Oct 9, 2016

Trac update at 20110622T09:20:32: mp commented:

(In [1177]) Remove automagical conversion of strings to booleans. See http://phing.tigris.org/ds/viewMessage.do?dsForumId=1079&dsMessageId=2771568.

Refs #539, #534, https://www.phing.info/trac/ticket/376, #533.

Introduces a BC break for existing tasks.

@phing-issues-importer

This comment has been minimized.

Show comment
Hide comment
@phing-issues-importer

phing-issues-importer Oct 9, 2016

Trac update at 20110622T09:25:31: mrook changed milestone from "TBD" to "2.5.0"

phing-issues-importer commented Oct 9, 2016

Trac update at 20110622T09:25:31: mrook changed milestone from "TBD" to "2.5.0"

@phing-issues-importer

This comment has been minimized.

Show comment
Hide comment
@phing-issues-importer

phing-issues-importer Oct 9, 2016

Trac update at 20110622T11:37:45:

  • mp commented:

(In [1180])
Closes #633

  • mp changed resolution from "" to "fixed"
  • mp changed status from "assigned" to "closed"

phing-issues-importer commented Oct 9, 2016

Trac update at 20110622T11:37:45:

  • mp commented:

(In [1180])
Closes #633

  • mp changed resolution from "" to "fixed"
  • mp changed status from "assigned" to "closed"
@phing-issues-importer

This comment has been minimized.

Show comment
Hide comment
@phing-issues-importer

phing-issues-importer Oct 9, 2016

Trac update at 20150104T20:27:47:

  • mrook commented:

Re-opening to track rebuilding of the 3.0 branch.

  • mrook changed resolution from "fixed" to ""
  • mrook changed status from "closed" to "reopened"

phing-issues-importer commented Oct 9, 2016

Trac update at 20150104T20:27:47:

  • mrook commented:

Re-opening to track rebuilding of the 3.0 branch.

  • mrook changed resolution from "fixed" to ""
  • mrook changed status from "closed" to "reopened"
@phing-issues-importer

This comment has been minimized.

Show comment
Hide comment
@phing-issues-importer

phing-issues-importer Oct 9, 2016

Trac update at 20161007T08:28:55:

  • mrook commented:

Milestone renamed

  • mrook changed milestone from "3.0" to "4.0"

phing-issues-importer commented Oct 9, 2016

Trac update at 20161007T08:28:55:

  • mrook commented:

Milestone renamed

  • mrook changed milestone from "3.0" to "4.0"
@stale

This comment has been minimized.

Show comment
Hide comment
@stale

stale bot Jun 16, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale bot commented Jun 16, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 16, 2018

@stale

This comment has been minimized.

Show comment
Hide comment
@stale

stale bot Aug 15, 2018

This issue has been automatically closed because it has not had recent activity. Thank you for your contributions.

stale bot commented Aug 15, 2018

This issue has been automatically closed because it has not had recent activity. Thank you for your contributions.

@stale stale bot closed this Aug 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment