@@ -96,53 +96,52 @@ function write($vcard)
9696 $ collectedNames [$ fn ] = $ vcard ;
9797 ++$ stats ['Unique cards ' ];
9898 continue ;
99- } else {
100- // Starting comparison for all properties. We only check if properties
101- // in the current vcard exactly appear in the earlier vcard as well.
102- foreach ($ vcard ->children () as $ newProp ) {
103- if (in_array ($ newProp ->name , $ ignoredProperties )) {
104- // We don't care about properties such as UID and REV.
105- continue ;
106- }
107- $ ok = false ;
108- foreach ($ collectedNames [$ fn ]->select ($ newProp ->name ) as $ compareProp ) {
109- if ($ compareProp ->serialize () === $ newProp ->serialize ()) {
110- $ ok = true ;
111- break ;
112- }
99+ }
100+ // Starting comparison for all properties. We only check if properties
101+ // in the current vcard exactly appear in the earlier vcard as well.
102+ foreach ($ vcard ->children () as $ newProp ) {
103+ if (in_array ($ newProp ->name , $ ignoredProperties )) {
104+ // We don't care about properties such as UID and REV.
105+ continue ;
106+ }
107+ $ ok = false ;
108+ foreach ($ collectedNames [$ fn ]->select ($ newProp ->name ) as $ compareProp ) {
109+ if ($ compareProp ->serialize () === $ newProp ->serialize ()) {
110+ $ ok = true ;
111+ break ;
113112 }
113+ }
114114
115- if (!$ ok ) {
116- if ('EMAIL ' === $ newProp ->name || 'TEL ' === $ newProp ->name ) {
117- // We're going to make another attempt to find this
118- // property, this time just by value. If we find it, we
119- // consider it a success.
120- foreach ($ collectedNames [$ fn ]->select ($ newProp ->name ) as $ compareProp ) {
121- if ($ compareProp ->getValue () === $ newProp ->getValue ()) {
122- $ ok = true ;
123- break ;
124- }
125- }
126-
127- if (!$ ok ) {
128- // Merging the new value in the old vcard.
129- $ collectedNames [$ fn ]->add (clone $ newProp );
115+ if (!$ ok ) {
116+ if ('EMAIL ' === $ newProp ->name || 'TEL ' === $ newProp ->name ) {
117+ // We're going to make another attempt to find this
118+ // property, this time just by value. If we find it, we
119+ // consider it a success.
120+ foreach ($ collectedNames [$ fn ]->select ($ newProp ->name ) as $ compareProp ) {
121+ if ($ compareProp ->getValue () === $ newProp ->getValue ()) {
130122 $ ok = true ;
131- ++ $ stats [ ' Merged values ' ] ;
123+ break ;
132124 }
133125 }
134- }
135126
136- if (!$ ok ) {
137- // echo $newProp->serialize() . " does not appear in earlier vcard!\n";
138- ++ $ stats [ ' Error ' ] ;
139- if ( $ debug ) {
140- fwrite ( $ debug , " Missing ' " . $ newProp -> name . " ' property in duplicate. Earlier vcard: \n" . $ collectedNames [ $ fn ]-> serialize (). "\n\n Later: \n" . $ vcard -> serialize (). "\n\n" ) ;
127+ if (!$ ok ) {
128+ // Merging the new value in the old vcard.
129+ $ collectedNames [ $ fn ]-> add ( clone $ newProp ) ;
130+ $ ok = true ;
131+ ++ $ stats [ ' Merged values ' ] ;
141132 }
133+ }
134+ }
142135
143- $ vcard ->destroy ();
144- continue 2 ;
136+ if (!$ ok ) {
137+ // echo $newProp->serialize() . " does not appear in earlier vcard!\n";
138+ ++$ stats ['Error ' ];
139+ if ($ debug ) {
140+ fwrite ($ debug , "Missing ' " .$ newProp ->name ."' property in duplicate. Earlier vcard: \n" .$ collectedNames [$ fn ]->serialize ()."\n\nLater: \n" .$ vcard ->serialize ()."\n\n" );
145141 }
142+
143+ $ vcard ->destroy ();
144+ continue 2 ;
146145 }
147146 }
148147
0 commit comments