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

Handle contacts with >9 phone numbers #117

Merged
merged 3 commits into from
Feb 13, 2019
Merged

Handle contacts with >9 phone numbers #117

merged 3 commits into from
Feb 13, 2019

Conversation

andig
Copy link
Owner

@andig andig commented Feb 8, 2019

No description provided.

Copy link
Collaborator

@blacksenator blacksenator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hallo Andreas,
sieht vertraut aus (Converter) - die neuen Dateien kann ich noch nicht einordnen. Komme aber erst morgen dazu mir das zu erschließen bzw. das zu testen.

@blacksenator
Copy link
Collaborator

Funktioniert im Prinzip - aber der Bug in "getPhoneNumbers" ist noch drin: es wird immer nur die jeweils letzte Nummer pro Type übergeben.
Im Test-Account, den ich dir mitgeteilt hatte, sind zwei Datensätze mit >9 Nummern drin.

@andig
Copy link
Owner Author

andig commented Feb 9, 2019

Kann ich zu mindest im Testfall nicht nachvollziehen- da werden eindeutig 2 Kontakte mit jeweils 9 unterschiedlichen Telefonnummern erzeugt.

@andig
Copy link
Owner Author

andig commented Feb 9, 2019

So sieht das Ergebnis des convert Aufraufs im Testcase aus- genau das erwartest Du doch, oder?

Array
(
    [0] => SimpleXMLElement Object
        (
            [carddav_uid] => uid
            [telephony] => SimpleXMLElement Object
                (
                    [number] => Array
                        (
                            [0] => 1
                            [1] => 2
                            [2] => 3
                            [3] => 4
                            [4] => 5
                            [5] => 6
                            [6] => 7
                            [7] => 8
                            [8] => 9
                        )
                )

            [person] => SimpleXMLElement Object
                (
                    [realName] => SimpleXMLElement Object
                        (
                        )
                )
        )

    [1] => SimpleXMLElement Object
        (
            [carddav_uid] => uid
            [telephony] => SimpleXMLElement Object
                (
                    [number] => Array
                        (
                            [0] => 10
                            [1] => 11
                            [2] => 12
                            [3] => 13
                            [4] => 14
                            [5] => 15
                            [6] => 16
                            [7] => 17
                            [8] => 18
                        )
                )

            [person] => SimpleXMLElement Object
                (
                    [realName] => SimpleXMLElement Object
                        (
                        )
                )
        )
)

Oder liegt das Problem nicht in convert?

@andig
Copy link
Owner Author

andig commented Feb 9, 2019

Ansonsten ist hier aber noch ein Bug drin:

        foreach ($numbers as $number) {
            $addNumber = [];

            if (count($replaceCharacters)) {
                $number = str_replace("\xc2\xa0", "\x20", $number);   // delete the wrong ampersand conversion
                $number = strtr($number, $replaceCharacters);
                $number = trim(preg_replace('/\s+/', ' ', $number));
            }

            $addNumber['number'] = $number;
            $type = 'other';
            $numberType = strtolower($numberType);

            if (stripos($numberType, 'fax') !== false) {
                $type = 'fax_work';
            } else {
                foreach ($phoneTypes as $type => $value) {
                    if (stripos($numberType, $type) !== false) {
                        $type = $value;
                        break;
                    }
                }
            }
            $addNumber['type'] = $type;
        }

da wird die $type Variable 2x verwendet.

@andig
Copy link
Owner Author

andig commented Feb 13, 2019

Refactored the entire thing and added more tests

@blacksenator
Copy link
Collaborator

let´s rock

@andig andig merged commit d765ed7 into master Feb 13, 2019
@andig andig deleted the nine branch February 13, 2019 18:08
@andig andig restored the nine branch October 18, 2019 18:39
@andig andig deleted the nine branch October 18, 2019 18:39
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

Successfully merging this pull request may close these issues.

2 participants