Problem/Motivation

We have some "beautiful" JSON converted from XML, yay IBM!

"@columnnumber": "2",
"@name": "WriteLog",
"textlist": {
"text": [
{
"0": "2008.OCT.28 12:54:39 CET # Admin/EMI"
},
{
"0": "2009.MAY.25 04:56:16 CEDT # Admin/EMI"
},

This would be a piece of cake with Iterator but the necessary source: 0 triggers the Get feature where you can insert the current value into the Get array.

Proposed resolution

Change empty to === ''. API break, baby! Yay! I wonder how many even used this feature (I know we discussed on IRC and it was needed) but among those who have used it I would bet practically anything it looks like this:

source:
  - foo
  -
  - bar 

so empty string should be fine.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

chx created an issue. See original summary.

chx’s picture

Status: Active » Needs review
StatusFileSize
new626 bytes
benjy’s picture

StatusFileSize
new1.69 KB

Simple unit test.

chx’s picture

StatusFileSize
new1.08 KB
new1.69 KB

Reuploading #3 but also with a -fail patch to see it failing.

The last submitted patch, 4: 2684575-3-fail.patch, failed testing.

quietone’s picture

Yes, integers need to be allowed. But now getSourceProperty() or getDestinationProperty() can be called with other empty values, like NULL or false. Is that desirable?

benjy’s picture

That's a valid point, maybe we should have if (empty($property) && $property !== 0)

benjy’s picture

StatusFileSize
new2.6 KB
new2.08 KB

OK, updated the logic and added two more tests for the NULL/FALSE cases. Also flipped the conditions which makes it more readable.

quietone’s picture

Status: Needs review » Reviewed & tested by the community

Thx benjy. It is easier to read. Looks good to me so RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 6fd640f and pushed to 8.0.x, 8.1.x and 8.2.x. Thanks!

I've committed this to 8.0.x because whilst this is an API change this is a very minor API change to an experimental and making this work the same in all branches is desirable.

  • alexpott committed afb2a79 on 8.2.x
    Issue #2684575 by chx, benjy, quietone: Get is unable to pick up 0
    

  • alexpott committed 92da1fc on 8.1.x
    Issue #2684575 by chx, benjy, quietone: Get is unable to pick up 0
    
    (...

  • alexpott committed 6fd640f on 8.0.x
    Issue #2684575 by chx, benjy, quietone: Get is unable to pick up 0
    
    (...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.