Comment On Confessions: The Phone Number

"One morning," wrote Justin Reese, "my client reported that was a strange bug on a certain page in an app I built for them. Where the contact information for a series of offices was being displayed, all the information was correct except for one piece: the phone number. For multiple locations, the phone number displayed was the same: 214-748-3647." [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Re: Confessions: The Phone Number

2012-07-17 09:04 • by KattMan
FRIST! and early

Treat all numbers as characters unless you need to do math on them.

Re: Confessions: The Phone Number

2012-07-17 09:07 • by Coffee Hound (unregistered)
1. PHP (XML?)
2. ???
3. Profit!

Now we know that step 2 is: store phone number as int (preferably while working in Dallas)... then charge consulting fees b/c the client mucked with YOUR production code... Flawless!

Re: Confessions: The Phone Number

2012-07-17 09:15 • by Gizzmo (unregistered)
What, and you didn't notice that 2147483647 is (2^31)-1? Sheesh. :)

Re: Confessions: The Phone Number

2012-07-17 09:15 • by Pista (unregistered)
Well, you seem to have kicked yourself in the butt, but at least you learned the lesson. For yourself and for a lot of us :D

Re: Confessions: The Phone Number

2012-07-17 09:15 • by Lone Phone Ranger (The bit-masked man) (unregistered)
I guess computers in Dallas adopt wild west slang when they type guess and internally monologue to themselves

Re: Confessions: The Phone Number

2012-07-17 09:15 • by Manadar (unregistered)
Only in Dallas!

Quite literally.

Re: Confessions: The Phone Number

2012-07-17 09:19 • by SODOFFFFF (unregistered)
I must say,I didn't expect this from the first line of the story,good job

Re: Confessions: The Phone Number

2012-07-17 09:21 • by Kevin D (unregistered)
I live in the 989!!

Re: Confessions: The Phone Number

2012-07-17 09:23 • by dork (unregistered)
now whos gonna call the max int32 phone number and try to convince them if they switch to at&t they will get full 64bits of service!

Re: Confessions: The Phone Number

2012-07-17 09:25 • by Dave the Destroyer (unregistered)
As the first commenter alluded to isn't the real WTF here using numbers to store telephone numbers?

Re: Confessions: The Phone Number

2012-07-17 09:27 • by Rick
385144 in reply to 385133
KattMan:
FRIST! and early

Treat all numbers as characters unless you need to do math on them.

TRWTF - A frist comment that is also correct.

I learned this lesson about numbers about 3 decades ago.

The lesson that I learned more recently is "Don't use XML unless you have a schema or at least a dtd."

Re: Confessions: The Phone Number

2012-07-17 09:30 • by flats (unregistered)
385145 in reply to 385143
Dave the Destroyer:
As the first commenter alluded to isn't the real WTF here using numbers to store telephone numbers?
I'd excuse him for not reading the whole article, in his rush to be a first poster, but yes, the submitter did realize that.

My first thought was "How on earth do you not recognize INT_MAX?" but I hadn't considered 1) someone would be living in a 214 area code, where that number would look sane, and 2) (which is much weirder to me) that young developers could have very well never developed on a 32-bit system.

Re: Confessions: The Phone Number

2012-07-17 09:31 • by Carl (unregistered)
Storing a phone number as an integer is definitely a WTF, but so is having a development server that's configured differently than the production one.

Re: Confessions: The Phone Number

2012-07-17 09:33 • by ekolis
I feel sorry for whoever has that number. I wonder if his name is Max?

Re: Confessions: The Phone Number

2012-07-17 09:34 • by KattMan
385148 in reply to 385145
flats:
I'd excuse him for not reading the whole article, in his rush to be a first poster, but yes, the submitter did realize that.


I did read the whole article first, but always felt that simply posting "FRIST" was a bit inane (some would say insane).

Re: Confessions: The Phone Number

2012-07-17 09:36 • by Shinobu (unregistered)
We've had an extensive discussion about phone numbers before.
Plus some filler text because Akismet doesn't recognise that this an internal cross-thread link.

Re: Confessions: The Phone Number

2012-07-17 09:37 • by jc (unregistered)
385150 in reply to 385135
you do realize that in php, all integers are signed, hence the one missing bit?

Re: Confessions: The Phone Number

2012-07-17 09:43 • by Mike (unregistered)
TRWTF: Languages that hide exceptions and returns random crapola as data. Nice!

Re: Confessions: The Phone Number

2012-07-17 09:47 • by notromda
385152 in reply to 385151
Mike:
TRWTF: Crapola Languages that hide exceptions and returns random crapola as data. Nice!


FTFY

Re: Confessions: The Phone Number

2012-07-17 09:50 • by Dion (unregistered)
The explanation explains that there is some magic code converting XML to arrays in a couple of steps. It seems to me that the real WTF is that the XML API he gets the data from classifies the phone numbers as numbers.

Re: Confessions: The Phone Number

2012-07-17 09:51 • by Geoff (unregistered)
Not a PHP guy so I don't know but, if you try to convert a string to an int and its to big you get the largest possible signed integer value? Its not an exception, or overflow error?

What the hell kind of sense does that make?

Re: Confessions: The Phone Number

2012-07-17 09:51 • by foo (unregistered)
Let's see, TRWTFs are:
- Type-guessing -- honestly, in all my programming work I never needed to type-guess. Either the input fits the expected type, or it's invalid.
- Not immediately thinking of 2^31 when seeing a 10-digit number starting with 21... (OK, slight excuses for the Dallas coincidence, but when a certain "magic" value keeps popping up, you better look what kind of value it actually is.)
- PHP doing saturation rounding, apparently without any warning, in a type-cast
- PHP itself
- Testing on a different configuration that production
- Storing phone numbers (or zip codes etc.) as numbers
- The US numbering system :) -- many countries' phone numbers start with an initial 0, so the previous mistake would show much earlier.
- The article:
* Typo/grammar error in the first sentence
* "2,147,483,647 is the highest integer value addressable on 32-bit systems". Triply wrong: (a) The highest *signed* integer, (b) representable, not addressable, (c) in a single register (64 bit integers stored in two registers are not that exotic, though maybe in PHP)
- The comments, including this one
- Akismet, of course

Re: Confessions: The Phone Number

2012-07-17 09:52 • by Dan (unregistered)
Did anyone try calling the number? If it was available, I'd grab it. I wonder how many calls they get for this reason...

Re: Confessions: The Phone Number

2012-07-17 09:53 • by The MAZZTer
385157 in reply to 385133
KattMan:
FRIST! and early

Treat all numbers as characters unless you need to do math on them.


I assume you mean PHONE numbers, otherwise this is just silly.

Re: Confessions: The Phone Number

2012-07-17 09:56 • by wtf (unregistered)
The real WTF is a 32bit server.

Re: Confessions: The Phone Number

2012-07-17 09:57 • by @Deprecated
385159 in reply to 385142
dork:
now whos gonna call the max int32 phone number and try to convince them if they switch to at&t they will get full 64bits of service!


Tooooo funny!
+2^31

Re: Confessions: The Phone Number

2012-07-17 09:57 • by DonaldK (unregistered)
Whahahaha 214 dialing code... you would have picked up on the problem a lot earlier in another city...

Thanks this was entertaining.

Captcha "damnum" ... hiehie that damnum won't fit into a 32 bit int...!

Re: Confessions: The Phone Number

2012-07-17 10:06 • by PiisAWheeL
385161 in reply to 385144
Rick:
The lesson that I learned more recently is "Don't use XML."

FTFY.

Re: Confessions: The Phone Number

2012-07-17 10:07 • by Matthew (unregistered)
A fairly weak story... a relatively common error that everyone makes at least once in their life, and nothing really that fantastic or funny happened as a result. In the end, pretty much your run of the mill bugfix.

Oh, and TRWTF is PHP.

Re: Confessions: The Phone Number

2012-07-17 10:16 • by Anketam
385163 in reply to 385135
Gizzmo:
What, and you didn't notice that 2147483647 is (2^31)-1? Sheesh. :)
Yea as soon as I saw the 2147 I knew it was a 2^x just had to figure out what x was. That is what you get for storing a string as a number, then again it is php and types are so retro.

Re: Confessions: The Phone Number

2012-07-17 10:17 • by Ben Jammin (unregistered)
385164 in reply to 385157
The MAZZTer:
KattMan:
FRIST! and early

Treat all numbers as characters unless you need to do math on them.


I assume you mean PHONE numbers, otherwise this is just silly.


I generally do postal codes as strings, too. Granted us Merkins generally only use numbers, whilst other countries mix in some letters (some as close as Canada) so you may not have a number only postal code.

Re: Confessions: The Phone Number

2012-07-17 10:24 • by Vilx- (unregistered)
[Insert mandatory generic anti-PHP rant here]

Re: Confessions: The Phone Number

2012-07-17 10:26 • by John Winters (unregistered)
This brings me on to one of my pet peeves - web sites that insist you have to enter your phone number without any punctuation or spaces in it.

It apparently doesn't matter to the programmer that the number would normally have spaces in it - the web site insists the *user* has to take the spaces out. Two points:

1) Why insist on storing the numbers in an unconventional format? (perhaps so they can be stored in an int?)
2) If you must have them that way, then you (the programmer) massage them after input. Don't expect the user to do it for you.

Captcah: saepius - a very wise comment.

Re: Confessions: The Phone Number

2012-07-17 10:27 • by The Doctor (unregistered)
It's not often that people post WTF's that they're resposible for here...

Re: Confessions: The Phone Number

2012-07-17 10:31 • by hymie
385168 in reply to 385157
The MAZZTer:
KattMan:
FRIST! and early

Treat all numbers as characters unless you need to do math on them.


I assume you mean PHONE numbers, otherwise this is just silly.


You don't have numeric postal codes, numeric identification (Social Security) codes, numeric part numbers ... ?

Re: Confessions: The Phone Number

2012-07-17 10:34 • by toshir0
385169 in reply to 385147
ekolis:
I feel sorry for whoever has that number. I wonder if his name is Max?

Dan:
Did anyone try calling the number? If it was available, I'd grab it. I wonder how many calls they get for this reason...

I third that.
I can picture the guy totally going *cluster F-bomb* at each other call...

Re: Confessions: The Phone Number

2012-07-17 10:39 • by KattMan
385170 in reply to 385168
hymie:
The MAZZTer:
KattMan:
FRIST! and early

Treat all numbers as characters unless you need to do math on them.


I assume you mean PHONE numbers, otherwise this is just silly.


You don't have numeric postal codes, numeric identification (Social Security) codes, numeric part numbers ... ?


I'll just wait for future "numbers that sholuld be strings WTFs" from the Mazzter. I'm sure hilarity will ensue since we have warned him.

Yes part numbers, SSN's, drivers license numbers, document numbers, customer numbers, etc, should all be strings. Cost, amount to order, inventory levels, days till end, etc should be numbers as you will eventually do math on them.

Re: Confessions: The Phone Number

2012-07-17 10:40 • by Chuck Lester (unregistered)
Congratulations on being the frist person to report your OWN WTF!!

Re: Confessions: The Phone Number

2012-07-17 10:47 • by Web Dude (unregistered)
A dubstep joke on TDWTF! How modern!

Re: Confessions: The Phone Number

2012-07-17 10:51 • by pitchingchris
385173 in reply to 385155
foo:

- The US numbering system :) -- many countries' phone numbers start with an initial 0, so the previous mistake would show much earlier.


Its not the US numbering system at fault, its the idiot who tried to put it a phone number into an int.

Re: Confessions: The Phone Number

2012-07-17 10:52 • by Rodnas (unregistered)
2,147,483,647th (so not frist ey)

Re: Confessions: The Phone Number

2012-07-17 10:55 • by willaien (unregistered)
PHP does automatic type casting in some cases, and won't even let you specify a type. So, the big WTF is using PHP in a production system.

Veekun has an excellent article on why PHP is a bad idea for any project of sufficient size to warrant a language be used.

Akismet seems to think I'm spamming up the joint, so adding a bit of text below the URL.

Re: Confessions: The Phone Number

2012-07-17 10:57 • by Cbuttius (unregistered)
Sorry, the number you have called has been changed.

Please redial 9223372036854775807

Re: Confessions: The Phone Number

2012-07-17 10:58 • by Spoe (unregistered)
385177 in reply to 385154
Geoff:
Not a PHP guy so I don't know but, if you try to convert a string to an int and its to big you get the largest possible signed integer value? Its not an exception, or overflow error?


Yep. Much like many overflow conditions in C, e.g.:


int foo ( int x) {
return ( x+1 ) > x;
}
int main ( void ) {
printf ("%d\n", ( INT_MAX+1 ) > INT_MAX );
printf ("%d\n", foo ( INT_MAX ));
return 0;
}


GCC (and several other compilers) with -O2 will output:
1
0

Meaning INT_MAX + 1 is both greater than and less than INT_MAX depending on how it's calculated.

No error is reported for the overflow. As I understand it, the behavior in this case is valid per the C99 spec since INT_MAX + 1 represents undefined behavior: the compiler can do what it wants.

I don't see C receiving the same level of disrespect as PHP.

Re: Confessions: The Phone Number

2012-07-17 10:58 • by A Person (unregistered)
385178 in reply to 385174
Started at a new job about 6 months ago. Week 2 I am putting together some tables including you guessed it a telephone number.

Boss looks at it later. 'Youre storing a phone number as text, why?'

Little perplexed as boss is supposed to be a programmer.

'Well you never need to perform arithemtic on it so this avoids any potential unintended math operations being performed on it'

I expected a sage nod and for him to move on. What actually happened was the 3 other developers and my boss looked at me as if I was insane.

It got stored as an int, and I realised I'm not going to learn anything here.

Re: Confessions: The Phone Number

2012-07-17 11:05 • by Spoe (unregistered)
385179 in reply to 385177
Spoe:

GCC (and several other compilers) with -O2 will output:
1
0


Correction:
0
1

Re: Confessions: The Phone Number

2012-07-17 11:06 • by Bubbah Ewing (unregistered)
385180 in reply to 385138
This must have been over 15 years ago.

Around that time they "divided" Dallas into 2 area codes, 972 and 214 with the old code being the "inner" area. About 4 years after that they added the 469 area code as we consumed all the 972 numbers. Now it's an amalgamated 214/469/972 block where your neighbor could be assigned a different area code than you and you could have a phone number that is "next to" one that is a 1 hour drive away.

Re: Confessions: The Phone Number

2012-07-17 11:12 • by pantsman (unregistered)
385181 in reply to 385178
Started at a new job. They are using PHP. Realised I'm not going to learn anything here.

Re: Confessions: The Phone Number

2012-07-17 11:12 • by callcopse
385182 in reply to 385137
Lone Phone Ranger (The bit-masked man):
I guess computers in Dallas adopt wild west slang when they type guess and internally monologue to themselves


Of course. I think they would look, or see their avatars as, a little like Yosemite Sam. Ooohhh that rackin, frackin PHP ...

Re: Confessions: The Phone Number

2012-07-17 11:13 • by Cbuttius (unregistered)
A few years ago between jobs I decided to teach myself PHP as I wanted to learn a bit more about it.

The main WTF as I saw it that having a large amount of server-side scripting was likely to be slow on the server. However a small amount, or for a small intranet web-service with a few users, it isn't such a bad thing.

Of course with any language, there will be WTF uses of it.

I never got to write a project of any size to discover some of its WTF-ness, although it seemed at the time that it could integrate with C libraries quite well that you could actually write large amounts of your web-service code in C (or C++ with a C interface) and use PHP as a simple thin layer.
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Add Comment