« first day (1495 days earlier)      last day (3453 days later) » 

3:06 PM
posted on November 19, 2014 by kbironneau

/* by HeberCosFer */

 
3:16 PM
is Brighton close to any of you?
 
ping @Danack
again
dammit
@FlorianMargaine @Fabor
Not a million miles away from me
 
I'll try to go there in january
 
@Danack @JoeWatkins also striking distance
 
Everything is relatively close in UK.
 
Unless you're driving
 
3:18 PM
I have to submit a session though...
there's a drupalcamp
 
Then it doesn't matter where you're going, it might as well be Mars
 
if I submit a session and it's accepted, my company will pay for me to go
 
Does anyone (in here) actually use Drupal?
 
Not anymore \o/. It's was more \o/ due to how we used it rather than using it.
 
@DaveRandom I was going to say Fabien :(
but yeah, it seems like I'm the only one left.
@Fabor got gtalk?
 
3:20 PM
Indeed
 
@FlorianMargaine I'm not saying it's bad, I've never used it or really even looked at it so I can't say that
Plus I've heard Drupal 8 is not-horrible
 
@Fabor florian at margaine dot com
@DaveRandom oh, the code is horrible
 
Brighton's not that far - just quite annoying to get to. Have to go via London I think, or play with the comically slow south coast trains.
 
Apparently, it would take me 141 hours to walk to Brighton. :)
 
That's... optimistic, I would say
@Danack have you seen github.com/amphp/dns/issues/16 ?
 
3:22 PM
@DaveRandom Only one way to find out...
 
Make someone else try it?
 
@DaveRandom No to both possible meanings - haven't seen that happen and haven't looked at the issue before.
 
@DaveRandom fancy coming to Edinburgh and then walking to Brighton?
 
Good lord @AndreaFaulds, I hope the cogs in your brain aren't considering making a PHP pre-processor
 
@ircmaxell I should sigh less :-D
 
3:24 PM
@salathe Swing by Southampton, me and my awesome shoes will join.
 
@salathe ummm... not really?
@Danack long story short, thoughts on github.com/DaveRandom/dns-amphp/compare/… plz
 
@DaveRandom you mean, Yet Another PHP Pre-processor!
@DaveRandom damn, I'll just have to trust Google then
 
YAPHPPP
 
Hello!
 
 
3:28 PM
i'm having an angularjs application posting to the backend.. $http.post(url, val1:'123', val2:'234', formvalue1:'abc', formvalue2:'cde').success(function(){ console.log('success')}); on the backend php code when i try to retrieve value val1 and val2, i keep getting errors
$http.post(url,
val1:'123',
val2:'234',
formvalue1:'abc',
formvalue2:'cde').success(function(){
console.log('success')
});
 
@DaveRandom Let me check out the code and think some more. Initial thoughts is that's although we should have that exception there, the calling code should know not to try to cache a null value.
 
on php, here's how i'm trying to retrieve those values..
$data = json_decode(file_get_contents("php://input"));
$val2 = $data->val2

This is giving error
 
what error?
 
@Danack Indeed, it's mostly an idiot check (btw the calling code doesn't cache the null value - it has an explicit !== null check to prevent it). I think that the extra unset() call will resolve the reported issue, although I can't figure out how it would happen in the first place, it's the only thing I can think of. The exception will at least provide a more useful stack if the unset() doesn't fix it.
 
and i can't seem to see the backend php error since it is an ajax call, i see the error in the console as angularjs code..
if i try on the other hand to do
$val3 = $data->formvalue2

it just works fine, that's because it is within the form
 
3:35 PM
@JoeWatkins since I don't have much feedback... I'll see in a couple days with Tyrael/jpauli if I can merge it
 
What I mostly want your opinion on is moving the default TTL up to the interface and using it in Redis/APC. Also I lowered it to an hour from a day because a day is silly. @Danack
@JoeSaad "an error" is not a debuggable error message...
@JoeSaad Also that's not valid javascript
 
it works when i try to retrieve the form post values but when i try to retrieve the other values (val1 and val2) it doesn't work @DaveRandom
 
we need errors...
we can't guess for you
check out your network tab
 
seriously though, that's not syntactically valid JS...
 
come on, don't note silly things like this.
 
3:40 PM
@FlorianMargaine I understand that, the netword tab is not showing any errors
 
trigger_error('@DaveRandom wrote this code', E_USER_TOO_SEXY_FOR_SHIRT);
6
@JoeSaad How do you know there was an error then?
 
@DaveRandom Yeah should be fine then.
 
@DaveRandom cause it shows angularjs error only when i try to access that value.. but when i change the php i never get that error
 
Yes but what's the error message?
I highly doubt it just says "error"
 
if it's angular... it might
 
3:53 PM
^^ lol codinglove.
 
So, if no backups existed (which they probably didn't)... the country is now screwed?
 
@DanLugg will listen to later .. currently watching this madness
 
Neat sauce, you might dig it; psychedelic drone
 
3:57 PM
it goes into the ajax error function and gives the following error in the console:
SyntaxError: Unexpected token B at Object.parse(native)
 
Anthony, you are quite good with programming concepts, may I ask you something related?
 
am i trying to retrieve the values right in the php with my above code?
$data = json_decode(file_get_contents("php://input"));
$val2 = $data->val2

echo $val2 // it gives error
 
well, @DanLugg , try watching it :D ... give you an awesome insight into the beliefs of this "crystal healers" and other bullshit peddlers
 
cause when i try to access
$val3 = $data->formvalue2

echo $val3 // it just works fine
 
@tereško watching now :-P
 
4:00 PM
@ircmaxell ping
 
@JoeSaad looks like your are passing the data in multiple params, should all the data not be in the second param?
 
@FlorianMargaine yo
 
@RonniSkansing i tried even that yesterday and it produced the same error.. i can try again now and see..
 
@ircmaxell do you have gtalk or a private message platform we can use?
 
@JoeSaad Well if it made the same error or not, I do not think you should begin trying to just add the data to more params.. lets look up the function. Am not saying it not possible (have not looked at the api yet). but where did you get the idea to do that?
 
4:02 PM
irc?
 
sure
you're on efnet?
 
@tereško say WHAT!? :-P
 
@DanLugg the video, to which this is a response to, has 1.5M+ views and 300k+ subscribers to the channel
 
I feel compelled to watch it.
 
i wanted to do that to have less functions on the backend code.. just passing parameters which will be passed to the php script rather than writing a couple of those functions @RonniSkansing
 
4:06 PM
And, I've watched enough because it starts with a misused Einstein quote.
 
@DanLugg wait till you get to to the space-jews fighting martians in atlantis
and no, I am not making it up
 
I can see you're not.
 
@JoeSaad I do not understand that. How did you get the idea that you could pass the data into the multiple params in the $http? Try looking at docs.angularjs.org/api/ng/service$http in the bottom, It says "data – {string|Object} – Data to be sent as the request message data.", and the next is headers. So I think you are writting your data into the headers as well. This might not be the reason for the error. But it is surely something that makes something not work at some point.
 
Adobe Illustrator + voice up an octave + bullshit = views
 
@JoeSaad atm only talking about the clientside code.
 
4:08 PM
@RonniSkansing so the problem you think problem is on the js code ?
 
@Fabor the Turkish website looks quite advanced, forms and stuff :D
 
@DaveRandom I can't see how that value got set to null. Re-reading the issue but ignoring the last line it seems what is happening is that the DNS request is just timing out....and the code is behaving exactly as it should do otherwise. If he's just using the memory cache, and is doing a lot of requests, it's entirely possible that they're just overwhelming their DNS lookup host.
 
@DanLugg views / insanity → 0
 
@JoeSaad I am pointing out you might have multiple problems. And it is hard to debug what you send to the serverside if it is already wrong at clientside. Are you using the developers tools to debug it? You should be able to see the ajax request and look into the data that is send with the request
 
The glass is half empty.
The glass is half full.
The glass is sad.
 
4:12 PM
@RonniSkansing the problem only shows up when the php tries to access data that isn't in the form .. yes i'm using developer tools to debug it
 
@Danack Yeh I mean the stack trace quite clearly says the request is being completed with a "server timeout" error, which is pretty clear cut, and shouldn't really be anything to do with the cache. I think the changes in that patch do have value, but I also think he's probably just got a local problem.
I'm just going to wait and see what happens when he runs with the patch, either it will fix the problem, get us another stack trace to work with or clarify that it's a problem at his end.
 
@DaveRandom What do you think about doing something like github.com/amphp/amp/blob/master/lib/ReactorFactory.php#L24-L35 for using apc cache if it's available?
 
@JoeSaad so in the developer tools, can you inspect the request and make sure all the data is in the request? You should also be able to see what the serverside is giving back to clientside (js/angular) before the error.
 
@Danack I'd be fine with it if @rdlowrey is, can't see any reason why he wouldn't be
 
@DanLugg eih
 
4:18 PM
@RonniSkansing i'm trying to see this now.. where can i see the request data?
 
@DaveRandom I don't think the stack trace will change....the one given before didn't touch the cache so the patch won't change anything.
 
@ircmaxell there are various levels of crazy
 
@JoeSaad in chrome its -> F12 -> Network -> (click on the request)
Now on the righthand of the request you should have a window with the tabs ( Headers, preview, response, Cookies, timing) .. it is in the response. So if you output something on the serverside, you should be able to see it there in clear text.
 
i just found it.. thanks for helping me debug it the right way @RonniSkansing
 
@Danack No but the error he reported suggested that he'd debugged it enough to determine that there at least is a case where the cache can record a false positive hit. I can't repro it but I don't know exactly what he's doing - I see no harm in the safeguard
 
4:21 PM
@JoeSaad no problem. Happy bug hunting
 
@RonniSkansing so i can the response as expected.. it is coming right
@RonniSkansing now the problem would be in the front end trying to see that
@RonniSkansing as you said it could be in the frontend code.. i don't understand why it is going to the ajax error function though..
 
@JoeSaad did you fix it, so the data was not spread in multiple params in the $http and contained to the data only (in a single object). Could you paste the js in a pastebin (including the error(s)), I have to go atm, but I can help you later if you still need it
 
@RonniSkansing sure, i'll past it in pastebin, thanks for offering help!!
@RonniSkansing the data is in the request payload
 
@AlmaDo I would go for it, but I don't think it would pass ^^
Also, I think it may make it prohibitively hard to upgrade to PHP 7.
And it would just reinforce the singleton anti-pattern.
 
@ircmaxell Its a cute, poetic notion, but to sell it like that is heresy.
 
4:35 PM
In order to start implementing classes for resolving tax rates, we must first define the tax type “zones”. The zone specifies the territories where the specific tax type and its rates are in use. Common sense tells us that French VAT is used in France, German VAT is used in Germany, etc.

But is French VAT used only in France? No, it is used in Monaco as well, which is a separate country. The UK VAT is also used on the Isle of Mann, a Crown dependency, but not an EU member. German VAT isn’t used on the island of Heligoland and the town of Büsingen (where Swiss VAT is used), but it is used i
 
I thought we were past 'use jQuery' >:(
@LeviMorrison "anti-pattern"? Singletons are AWESOME.
^ The only type of singleton I like.
 
user895378
@Danack I don't really see any benefit to this? The instantiation overhead for the reactors isn't expensive. And for anything other than the NativeReactor you're going to break things because you can't serialize the resources used internally by pecl/libevent or php-uv. Could you elaborate on where using apc for this would be helpful?
 
@RonniSkansing I fixed it.. Thanks for your help!! and thanks everyone for thinking through it with me.. the response wasn't returning JSON, after seeing through the network tab which i didn't know how to see the response in it, i was able to make sure on the php side that the response would be always JSON. Thanks again!!
 
@rdlowrey (Fabien) hey I don't suppose you took a look at that crappy ssl site thing through artax? It's more me being curious as to how I 'should' handle it.
 
@rdlowrey We're just talking about caching the DNS lookup results. As the caching is only stored in internal memory, it currently has to do the DNS lookup each time the script runs, which sucks for people who don't have long running scripts, but instead have short scripts.
 
user895378
4:49 PM
@Danack Oh I was confused. Yeah caching DNS lookup results in apc would make sense for normal environments like the web sapi.
 
I think the only thing that needs thinking about is the key name....
 
@BenjaminGruenbaum good choice! :)
 
user895378
@Fabor I'm sorry, I haven't. I've been super busy the last couple of days. I will look at it this evening for sure.
 
@Fabor If in doubt, HTTP 422
 
That'd be great thanks :) Hit me up on gTalk anytime regarding it.
 
4:50 PM
morning
 
@Jimbo heh it's something else.
 
@salathe ty :)
 
Fabor == Fabien?
 
Correct.
 
WHAT HAVE YOU DONE WITH OUR FABIEN!? @Fabien! @Fabien!! Are you out there!?
 
4:54 PM
It's a step towards separating my online person from real life.
 
@Fabor Why?
 
lol, I hear that, I was consolidating, and now am splitting.
 
user895378
@Fabor I wish I could do this because I'm paranoid. Unfortunately pretty much everything online associated with me at this point is using "rdlowrey" ...
 
My first + last name is super unique as a combination. And this being a google-able chat room I often talk about work related things. I'd like to make it a little more difficult in case someone does try to find out about me.
I'm a pirate hunter remember :)
@rdlowrey Luckily I had the foresight to not make anything (open) great so far in my programming career :P
 
This may seem like a silly question, but there are so many approaches that I guess I'm not clear on the best practice anymore: how do you return errors from objects?
 
4:57 PM
@ChrisBaker Exceptions?
 
One could use exceptions, but I've seen that panned as bad practice.
 
@ChrisBaker throw new WhatDoYouMeanBadPracticeException('?')
 
Did we mention exceptions yet?
Hot Chocolates. To keep us warm in winter.
 
I've seen the phrase "exceptions are for exceptional situations", but let's say this method is business logic, like "Is the venue available during X - Y time range"
A no answer isn't an exception.
 
No, your return response from that is a boolean - true or false
 
4:59 PM
So maybe it returns false, but what about a little more complex example, where the false could be for a few different reasons?
 
If it couldn't get that information to return the boolean you state it should return, that's an example of an exception
@ChrisBaker Example?
 
@ChrisBaker I go round to the user's house, write the error message down on a post-it note and then staple it to their forehead. I used to just rely on the post-it glue but I found the notes would often get lost that way.
 
Now, in the code that got "false" -- why false? What do I say to the user?
 
Ahh... maybe that was why I wanted multiple return values.
 
Okay, same system, venue reservations. There's a method to get the estimate for the total reservation
 
5:00 PM
One to declare boolean result another to send a message
 
My true / false returns usually have Object::isAbleToEtc() so in english it makes sense
 
It is going to process several dates. One of them is not available anymore -- a race condition scenario.
So "false" tells me, okay, the thing couldn't make an estimate. Why?
I'd like to return "False, because date Z is no longer available"
So I could throw an exception, but is that exceptional?
 
@rdlowrey Sounds like something for the Tao.
 
It seems like it is predictable
 
@ChrisBaker Let's say you have this method, isAvailableBetweenDates(DateTime $pre, DateTime $next)
That returns true, or false
 
5:01 PM
That's really true/false, if I wanted to know why it isn't available, I would make a different method.
 
If you need to know why it was false, seems like there's something else needed
 
@Danack I was thinking __CLASS__ would work well, since it's the default cache when you create an instance of that class without passing a cache in
 
Maybe it doesn't return true or false any more
Maybe it returns an object containing a response
?
I would argue exceptions are useful there though
 
So GetEstimatedTotal returns a number if it is able to estimate the total. I call it, something is funky about the data, and it can't give me a dollar amount. So it returns false, and I'm flat-footed as to what to tell the user. That's where I'm wondering what the best practice is. Exceptions, a getLastError internal thing, a ResponseObject that is returned for positive OR negative results...
 
^^ This is something I always flip-flop on. How to handle "response" objects.
 
5:03 PM
There's a ton of ways to do it that I've seen in the wild.
 
Maybe there's no single correct/preferred solution.
 
    Response
     /    \
Success  Failure
            ^-- basically a "null" object
function doTheThings($input) : Response { }
So if you end up calling Response::getSomeArrayOfShit() the Failure just returns []
 
> something is funky about the data
 
And as far as testing whether it succeeded or failed; instanceof ___
 
Sounds pretty exceptional to me...
 
5:07 PM
The ResponseObject bit seems like a good solution, but then I've got to mess with instantiating a new one for every object call. Do you inject that? Ugh, another parameter, or ugh using new inside object calls, hidden dependency. The idea seems good but the implementation is poor in both cases/
 
@ChrisBaker It's not a "dependency" if it's just a VO struct-y thing [citation-possibly-needed] but that's how I see it.
 
@DaveRandom By that I mean any of a variety of reasons where valid data is still not acceptable data to a particular set of business rules.
 
I'm not sure why using exceptions would be bad practice there. You aren't using them for flow control, you are using them to report a failure, that's what they are for.
 
@DanLugg That's an interesting side bar unto itself, because I've seen the argument for everything up to static database access, of all things, being "just part of the environment, like $_POST"
@DaveRandom Maybe that's the case, and I'm over-thinking it.
 
5:12 PM
I like a schema, and favor defined "structs" over using arrays like Lego. I feel that when an object owns/creates the "struct" it's not a dependency, and shouldn't warrant any "creational patterns" to facilitate it's creation. You can just return a new ResponseSubtype
 
@ChrisBaker Good rule of thumb for this, IMO: Is anything else outside the public API of this unit of code ever going to create one? Can the caller usefully substitute my implementation for another? If no to both (and the case @DanLugg describes I would say then that is the case) then just new it. What @DanLugg said ^
 
user895378
@DanLugg +1
 
Especially with return types in the pipe, you can, as mentioned, function foo(): BaseType { }
 
Where are we up to on the return type covariance thing? @LeviMorrison
 
I can't frickin' wait for that. We're working on moving to 5.6 right meow, hopefully I can prod the dude into 7 a few years after that drops (roll eyes). Unless return types are also slated for 5.7, in which case I will surely be able to get there as soon as it is released.
 
5:16 PM
@DaveRandom Very relevant ^^^
 
I know, that's why I asked :-P
 
@BenjaminGruenbaum no they are not. one might be okay, but if you take too many of they'll ruin your system. and yes, I am aware that you are talking about the whisky. same thing though. and this one is bland anyway. I only use it for mixdrinks.
 
17:20 O LORD, there is none end of the regexp. http://tmblr.co/ZPJihp1V_DLLW
 
5:43 PM
@DanLugg $response = class_exists('ResponseObject') ? new ResponseObject : new stdClass; eh?
Co-worker gripe: using VO means that I can't have an isolated test without bootstrapping. All the test will at least have to include the structure definitions, and no class is an island anymore.
 
Morningn all
 
Good morning, P
 
So I read this comment and was going to laugh. But then I went to the Wordpress website and realized they don't mention PHP anywhere on the front page. Well played, PHP. Well played...
 

« first day (1495 days earlier)      last day (3453 days later) »