ramsey / uuid-doctrine

:snowflake::file_cabinet: Allow the use of a ramsey/uuid UUID as Doctrine field type.
MIT License
893 stars 84 forks source link

Node of UUID is 0 #186

Closed zedar187 closed 1 year ago

zedar187 commented 1 year ago

I'm using uuid-doctrine with UuidBinaryOrderedTimeType as an id field on multiple sql tables, which is working fine on a local dev environment. When using same code on the prod server (identical config, versions etc) the node of each UUID is always just 0.

How do I debug/ how can I get any more info of this problem, as to why the node is always zero'd? Unfortunately there is no exception thrown...

php-fpm 7.4, ramsey/uuid-doctrine 1.8.1, doctrine/orm 2.13.2

zedar187 commented 1 year ago

After digging through the sources, I've found the issue. The origin is in ramsey/uuid instead of the uuid-doctrine. It seems that there has been an issue in 2016 about this: ramsey/uuid#133.

The server is running on a vpn network, which interface hasn't got a mac address (as in: 00-00-00-00-00-00). As this interface is the first one listed by SystemNodeProvider->getIfconfig() it takes the mentioned zeroed mac address as the returned node.

When going through the interfaces, I've put a quick if-statement to it:

Ramsey\Uuid\Provider\Node\SystemNodeProvider.php line 138

        if (preg_match_all(self::IFCONFIG_PATTERN, $ifconfig, $matches, PREG_PATTERN_ORDER)) {
            foreach($matches[1] as $iface) {
                if($iface!="00-00-00-00-00-00"){
                    $node = $iface;
                }
            }
        }

This cycles through all interfaces and takes the first "usable" one, while dismissing zero'd entries.