Cannot generate UUID

Bug #283398 reported by Andrew
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Debian
New
Undecided
Unassigned
ossp-uuid (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: php5-uuid

The create_uuid() function in the php5 extension simply is not working. There are no docs to ensure that I am calling it right either

I am having the same issue as the poster at:
http://www.codingforums.com/showthread.php?t=89152

Things I have tried:
php -r 'if(!extension_loaded("uuid")) {die("skip");} $uuid = uuid_create(); print "$uuid\n";'
Warning: uuid_create() expects exactly 1 parameter, 0 given in Command line code on line 1
1

php -r 'if(!extension_loaded("uuid")) {die("skip");} $uuid = uuid_create(UUID_TYPE_DEFAULT); print "$uuid\n";'
Warning: uuid_create(): uuid_create: parameter wasn't passed by reference in Command line code on line 1
1

php -r 'if(!extension_loaded("uuid")) {die("skip");} $a = UUID_TYPE_DEFAULT; $uuid = uuid_create(&$a); print "$uuid\n";'
0

php -r 'if(!extension_loaded("uuid")) {die("skip");} $a = UUID_TYPE_DEFAULT; $uuid = uuid_create(&$a); print "$uuid $a\n";'
0 Resource id #4

php -r 'if(!extension_loaded("uuid")) {die("skip");} $a = UUID_TYPE_NULL; $uuid = uuid_create(&$a); print "$uuid $a\n";'
0 Resource id #4

Ubuntu Hardy
php5-uuid 1.5.1-1.1ubuntu1

Revision history for this message
Seth.Griffin (sgriffin) wrote :

I can confirm from working code that I have that the normal use looks like this:

uuid_create(UUID_TYPE_RANDOM);

That would create a random uuid.

This is simply broken in ubuntu. I have always had to install the package using pecl

sudo pecl install uuid

Note that you need uuid-dev, php-dev and php-pear to do this.

Still, this needs to be fixed in ubuntu.

Revision history for this message
Seth.Griffin (sgriffin) wrote :

My mistake, the packages you need are uuid-dev, php5-dev (not php-dev!) and php-pear.

Revision history for this message
Seth.Griffin (sgriffin) wrote :

Hi Andrew,

After digging around in the deb source I found that the entire interface/library is completely changed and the old interface is no longer available. Here is how you do what you are trying to do using php5-dev.

uuid_create(&$uuid);
uuid_make($uuid, UUID_MAKE_V4);
uuid_export($uuid, UUID_FMT_STR, &$uuidstring);
echo trim($uuidstring);

There are more examples at:

http://www.php.net/manual/en/function.uniqid.php#88434

I was confused by this as well, because the pecl package for uuid still uses the old interface. Not sure what the Ubuntu team did here, can someone provide some insight? Is the pecl package out of date?

Revision history for this message
Mikko Rantalainen (mira) wrote :

The real issue here is that php5-uuid is NOT the PECL uuid package, but instead OSSP uuid package (it says so in the description -- granted, it doesn't say that it is not the PECL package but I wouldn't expect Firefox package to say that it is not Internet Explorer either, if you know what I mean.).

Considering that all(?) other php5-whatever packages are PECL packages, it would make sense to rename this package to php5-ossp-uuid and to create a new package php5-uuid which would contain the PECL implementation.

In the long run, *all* PECL packages should probably be renamed from php5-whatever to php5-pecl-whatever to lessen problems such as this in the future.

See also:
http://codingforums.com/showpost.php?s=1bd71bf775eb0ada2c04f2fea5ec0865&p=881913&postcount=13
https://answers.launchpad.net/ubuntu/+source/ossp-uuid/+question/87216

Revision history for this message
Seth.Griffin (sgriffin) wrote :

Mikko,

I agree. Since there are two packages that can accomplish working with uuid's they should probably be called

php5-pecl-uuid
php5-ossp-uuid

And so on.

Naming all php packages as

php5-pecl-whatever
php5-pear-whatever
php5-whoever-whatever

is a great idea.

Revision history for this message
Mikko Rantalainen (mira) wrote :

See also bug 692968.

Revision history for this message
Mikko Rantalainen (mira) wrote :

Here's a simple shell script that creates package "php5-pecl-uuid" when called without parameters.

This script does following:
- create a build directory for this process (deb-build-$$)
- get the package source and prefix it with php-pecl
- quickly rewrite the debian control and rules files to redirect the package name (I couldn't get dh-make-pecl to correctly do this)
- build the package without signing it (debuild -uc -us)
- move the completed deb files to the parent (original) directory

This should be able to build any PECL library which should generate exactly one output deb. E.g. "make-pecl-deb apc" seems to work ok.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.