Muse frontman Matt Bellamy, 48, files to divorce wife Elle Evans, 36, after seven years of marriage as he seeks sole custody of their two children
The day Britain stood still to marvel at the heavens as once-in-a-generation eclipse stuns the country... and if you missed it, the next one isn't until 2050
Father, 56, was killed in street brawl sparked by deadly turf war between rival biker gangs that has seen horrific violence across Britain
Vogue Williams calls out Red Hot Chili Peppers frontman Anthony Kiedis, 63, for dating a 19-year-old and says 'just because you can doesn't mean you should'
Alix Earle puts on a cheeky display in VERY skimpy bikini during VIP luxury yacht trip in Italy
Netflix confronts explosive false claims that Raygun cheated her way to the Paris Olympics with her husband
Crackers for Clackers! By-election brings Clacton back to the spotlight - but what can visitors expect from the seaside town once voted Britain's worst?
IT teacher is struck off after being caught red-handed altering his pupils' coursework in the middle of an exam
Scientists Create Largest 2D Map of the Universe
Read more of this story at Slashdot.
Passwords stored in public Google Doc then showed up in search results
Jeremy Clarkson moans that he couldn't see the once-in-a-generation solar eclipse from his Cotswolds home as millions of sky watchers share their stunning snaps of the rare spectacle
Is Jack Lowden the next James Bond? Slow Horses star being 'strongly considered' to take on 007 role after creators confirmed they would have casting news soon
Mark Wright and Michelle Keegan's VERY green grass stands out next to the dry surroundings during record-breaking drought
Charlie Kirk's alleged assassin begs to take death penalty off the table, filings claim
Revealed: The weirdest things that will happen during tonight's solar eclipse - from animals falling silent to a spike in traffic accidents
CodeSOD: Never Eating the Cookie
Maciej works as a freelancer, and that frequently means picking up old PHP code that nobody wants to support.
One project had been lingering for ages with key features missing. Specifically, it was supposed to make HTTP requests to other services on an interval, and use that to populate its data. "The old dev tried, but never got it working." It was Maciej's turn to give it a shot.
$ch = curl_init( $url ); curl_setopt( $ch, CURLOPT_COOKIEFILE, $cookie ); curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie ); curl_setopt( $ch, CURLOPT_COOKIE, $cookie); // ... many other options set, of course not in a function, just copy-pasted in many locations in the code ... curl_setopt( $ch, CURLOPT_TIMEOUT, $interval ); $s = curl_exec( $ch ); curl_close( $ch );This particular block of code appeared multiple times in the code. Every place they meant to send an HTTP request, they copy/pasted this code in. The URL would be a different value, but the bulk of the code was just a dozen lines of copy/pasted curl_setopts.
Now, I don't know that they were dreaming that setting CURLOPT_TIMEOUT was setting a recurrence interval. But they do call the value $interval, and I can imagine the ignorant hoping to set up cURL to automatically reinvoke the request on an interval. But even if that's their goal, that's not the actual problem with this code.
They initialize a cURL wrapper, set a pile of options, and then execute the request, storing the result in $s. And do you know what they do with the contents of $s after this?
Nothing.
The request works, perhaps not on an interval, and populates the variable, and they just never use it. The old dev "tried" and never got it working? It seems like they started and got bored.
There was far worse spaghetti code to manage in the project, but it was this gap that really got Maciej's attention.
.comment { border: none; }