« first day (1754 days earlier)      last day (3194 days later) » 

11:00 AM
@NeelIon do a var_dump($a) in your code
that should point you in the correct direction
 
@tereško thanks man, now i understand
@tereško actually $array and $a is two different array, am i right?
 
yes
 
:)
 
so .. I tried to use ##php again for a bit. I think I will be leaving it again. It's too painful.
 
what is ##php?
 
11:06 AM
freenode irc channel
 
@tereško because of IRC or the people in there?
 
people
I am still hanging around on EFnet's #teksyndicate
 
are variables passed in use statement of closure passed by reference? or are they copies?
 
@r3wt you can pass them manually by ref by putting an & in front of the var…
 
11:20 AM
@bwoebi thank you.
 
user5020521
hi guys can anybody help me to fix an error code in my php pdo validation form?
 
user5020521
may i copy/paste the code here???
 
@Riccardo990 please use pastebin or 3v4l.org
 
user5020521
ok gimme one second
 
user5020521
11:25 AM
@r3wt
 
user5020521
3v4l.org/SaDv4 this is it @r3wt
 
ew
 
user5020521
what do you think about this?
 
lol. you have an opening php tag before the opening html tag...
 
user5020521
cut it
 
11:30 AM
@Riccardo990 please use english for all your code (variable names etc)
separating your html, php and sql would also be a good idea
 
user5020521
you are right patrick lemme rewrite the code and sed you again
 
user5020521
i-ll do all of this
 
Don't prepare static queries
 
one small error and a visitor to your site will see your login credentials
 
user5020521
so why?
 
user5020521
11:32 AM
i-ve entered xxxx to replace my server credentials
 
And you only need one query for that page, you're pulling the same data set out twice with different columns, you can pull it all down in one go
 
user5020521
I would need to fetch last name and address into two separate input text
 
user5020521
under a select
 
user5020521
bytheway i am rewriting the code one moment
 
@Riccardo990 but what if someone removed the <?php? Could be a merge error. What if your server setup is messed up and it is displayed as a flat file. You don't want any sensible stuff in your publicly accessible files
 
11:34 AM
Hey Patrick. :P
 
@Riccardo990 maybe bookmark this tutorial and have a look at it when you have some spare time :)
 
Ye man, thats the best tutorial.
But is dead since a few months.
 
@Riccardo990 Yeh but it's the same data set
 
user5020521
 
@Patrick Man, I needs yo help
 
user5020521
11:35 AM
i have corrected the syntax errors
 
user5020521
what is missing?
 
@HassanAlthaf I'll get to it once the weather gets worse ;)
 
user5020521
ops i forgot the english
 
@Patrick lol
I'm getting back to the tutorial.
Udemy ftw
 
user5020521
i think almost everything is in english apart from the column of the table such as address or name
 
user5020521
11:41 AM
i had to write them in italian since the column table are in italian
 
user5020521
columns*
 
user5020521
anyway what do you think about the last code?
 
@Riccardo990 is something not working? or are you asking about how you can improve other things like readability?
 
$other_objs = array_map(function($obj) { return new OtherObj($obj->getFoo()) }, $_objs);
how would you make this more readable?
 
user5020521
@Patrick this code failed to allow the user to select what data to insert into the table
 
11:45 AM
@iroegbu $other_objs = array_map(function($obj) { return $obj->newFromFoo(); }, $_objs);
 
imagine the callback being more than one line... it's bad enough as it is. I see what you did.
 
user5020521
as a matter of fact whether I click under lastname I cannot choose from the fetched lastnames
 
@Riccardo990 then... debug your code to find the error?
 
$other_objs = array_map(function($obj) {
    //more lines
    return $obj->newFromFoo();
}, $_objs);
looks okay...
 
user5020521
@Patrick i found the error as a matter of fact $conn which establishes the connection to the db is in a separate block of code and as a consequence it is undefined
 
11:52 AM
@Jimbo rsa key?
 
user5020521
i tried to put together the connection to the html which builds the form
 
@FlorianMargaine ssh-rsa
(says in public key file), so must be :-)
 
@Jimbo the name of the key isn't id_rsa maybe?
dunno what's wrong anyway
it worked for the 3 people I tried with in the office :D
 
@FlorianMargaine Nope, who honestly does that? If you have more than one key for different services, you don't want to call them id_rsa
 
@Jimbo I use id_rsa for the "generic" key and other names for specific stuff
 
11:54 AM
can php functions like var_dump be called from outside of php?
 
@OlleHärstedt like?
 
like a lib
 
like a js lib?
 
no, like from binary compiled C.
 
@FlorianMargaine Mine is something like "jim-sandbox-macbook". That way I have the user, the server and the machine all in one name
Only requirement is to use that shitty ssh-agent to add it at the beginning
 
11:56 AM
15
Q: PHP. Extension. Call existing PHP function

nkammSo I decided to write an extension for php. Everything seems to be fine except I'm stuck on a tiny problem. I have php-5.4.9 source codes. There is file ext/standard/mail.c with awesome function PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd TSRMLS_D...

 
Wow, that looks really simple
 
@pee
@PeeHaa thanks, will check.
 
Hi all. I have lots of php code to deal with... The example: 3v4l.org/vfEOK . How could I move selected lines [262-280] to the own function/method? It hurts a lot to move it manually...
I mean that most of the code is written just as in example - in-line php code...
 
Oh noes! I hurt its feelings!
@PeeHaa I do not feel your comments to be too helpful or friendly, any PHP programmer would know that, that @ mark only ignores connection errors, i do not have any. — Denis Makula 2 hours ago
 
12:02 PM
posted on August 05, 2015 by kbironneau

/* by eimink */

 
@OlleHärstedt You might want to use the embed SAPI, what are you actually trying to do?
 
user5020521
@DaveRandom please accept my invitation to the other room
 
@DaveRandom I'm compiling a subset of PHP to LLVM, and want to call e.g. var_dump from a standalone exec.
 
> <meta http-equiv="Content-Type" content="text/html; charset=wtf-8">
Doesn't seem to be working right :-P
(just found that in some of my old code)
 
12:11 PM
@OlleHärstedt What do you mean by "compiling a subset of PHP to LLVM" exactly? i.e. which parts of LLVM are you hoping to use for what?
 
on my profile below "Top Tags" how is that score calculated?
it says 58, however I have 1'6xx rep and 63% are on symfony2 -> shouldn't I have a bronze badge for the symfony2 tag?
 
@DaveRandom e.g. this:

$a = 'asd';
var_dump($a);

first line I did already. Now I need to call var_dump from LLVM somehow.
 
has there ever been the considereation to add vartype hints to list?
 
@DaveRandom This might make it more clear: stackoverflow.com/questions/31814921/…
 
Abe
@hakre list(Bar $x, Foo $y) = $arr; ?
 
12:31 PM
(OK, already answered here: stackoverflow.com/questions/4567195/…)
 
@Abe yes
to prevent things like
            /** @var $url string */
            /** @var $proxy FACTFinder_Http_DataProviderProxy */
            /** @var $curl FACTFinder_Curl */
            /** @var $data mixed */
            list($url, $proxy, $curl, $data) = $args;
at least in part.
 
That would be interesting.
 
Abe
that's useful, but also for enforcing the "you can't fuck up with types & their order" safety :P
 
@OlleHärstedt Ahh I see what you're getting at... yeh it's a tricky one this, you will spend a lot of time simply battling leaky abstractions in php-src. A lot of PHP functions (as in the routines defined using the PHP_FUNCTION macro) are just thin wrappers over a cleaner C API, but some are not.
You'd probably want a way to introduce per-function handlers so that you have a way to shortcut to the back-end, but default to just invoking the zif_* routines defined by PHP_FUNCTION
 
12:52 PM
> In the good old days, Wikipedia and Wordpress used to be the glorious examples of how you can never go wrong with PHP and MySQL. Of late, however, Facebook has become the punching bag of PHP critics. -/r/php
Often with /r/php I scroll to the downvoted comments to find the comment I am looking for.
 
lol
 
@DaveRandom thanks for your feedback, will take a break and then try to compile some stuff :) cheers
 
@hakre It's possible once we have Foo $foo = ....
 
@kelunik has that been discussed?
 
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'A non-empty PSR-4 prefix must end with a namespace separator.'
I guess I am missing \\ but I have no clue where :P http://hastebin.com/ekufebecat.coffee
 
1:06 PM
end with?
 
@hakre A week or so ago in here, yes.
 
@kelunik ah cool.
 
@Duikboot Yes, exactly. Dumb composer...
 
Might be missing some stupid things
 
@hakre But references seem to be a problem here.
@Duikboot Just add \\ to the end of the namespace in the "autoload" section.
 
1:08 PM
@kelunik have not thought about them
 
Sorry for all those pings, SO chat, you're drunk.
 
I sometime use them with list but only in rare occasions.
 
@kelunik
Fatal error: Class 'Whoops\Run' not found ...
You sure you mean: "autoload\\" : {
1 slash
 
@Duikboot Nope, the namespace below, e.g. "Amp\\Mysql\\" instead of "Amp\\Mysql".
 
ok
 
1:13 PM
I've noticed that the port gets lumped into HTTP_HOST. Anything else that should be stripped out if I want just the host name?
 
@DanLugg explode(':', $_REQUEST['HTTP_HOST'])[0]?
the HTTP_ stuff is just what's sent by the browser.. (mostly)
 
I actually use strtok, but yea, same idea.
An actual use for strtok. Who knew?
 
@Fabor indeed, that's pretty cool
 
Good morning
 
1:19 PM
morning and wood at the same time... hm...
 
heh
 
good morning
 
@Fabor I'm Dutch and that is not a joint ;)
 
heh. Was only a matter of time before someone went there.
 
You can still try to smoke it @PeeHaa
 
1:27 PM
I totally could
 
paint > marijuana
 
@FlorianMargaine lol. Paint is terrible
 
Worst case, you could bore a hole in it and make an apparatus.
 
I once got reeeally sick from it
@Fabor Fake! The background is way too blurry
 
1:29 PM
heh. It does look pretty shopped. Probably touched up at least.
 
heh
 
@DanLugg :D
 
Be throwing some flame balls after that one @ircmaxell
 
1:44 PM
in PHP, For properties on a class (without getters/setters), is the only way to define that a property is a Value Object (or any object) is to either set it in the constructor or denote it in the docblock comments above it?
 
Does anyone know what PDOStatement::lastInsertId reports when you do an insert ... on duplicate key update .... statement... goes it give you a way to tell if it was an insert or an update
 
@Orangepill there is some trick to that..., trying to remember...
 
@DavidGraham you looking at enforcing type on hydration?
 
Abe
are there any rules about &$param signature compatibility?
 
Yeah that and other things. I don't require some properties to be set on construction, and I don't have setters. So I was wondering how anyone will know they are value objects (other than the docblock comment)
@Orangepill if you do an insert like this:
INSERT INTO table (a,b,c) VALUES (1,2,3)
  ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id), c=3;
That will ensure you can get a value out of lastinsertId from PDO I believe
whether you know it's a new insert or update, not sure...hmmm
but you do get the id (old or new) regardless
if you do that
 
1:54 PM
@Orangepill I think it depends on the actual DB you are using - stackoverflow.com/questions/778534/…
oh, as david said.
 
@DavidGraham what does the final c=3 do?
 
thats the update part
If the row already exists, then you are saying "I just want to update the value of column c"
to 3
 
okay duh
 
^ lol brain fart
So regarding properties in my class that are Value Objects. I suppose I need to use private setters to enforce the type?
Even then, a property could be set directly from within the class somewhere else
This is part of the cons (pros and cons) of a loosely typed language?
 
For consistency sake, I just define getters/setters for everything. Scalars are cast, objects are type-hinted.
 
1:59 PM
Or, I suppose the docblock is good enough.
 
public function setName($name) { $this->name = (string) $name; }
 
Yeah, I like type hinting the objects in a setter. But I don't like setters.
 
I used to define only setters for scalar types, to ensure they're cast (or typechecked and thrown) accordingly. Now I just gen them for everything cause my IDE does it.
 
posted on August 05, 2015 by kbironneau

/* by Kibbas */

 
2:01 PM
$stmt = $pdo->prepare("INSERT INTO table (a,b,c) VALUES (:a,:b,:c) ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id), a=:a, b = :b, c = :c");
$stmt->execute([":a"=>1, ":b"=>2, ":c" =>3]);
$entity->setId($pdo->lastInsertId());
 
dat's a lot of syscalls and faults
 
^ the right way?
 
@ircmaxell what's that process doing?
 
@Orangepill ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id), a=VALUES(a), b = VALUES(b), c = VALUES(c)")
@bwoebi phploc
 
@ircmaxell 200 million is not bad…
 
2:03 PM
@ircmaxell thanks
 
not bad
 
@ircmaxell you have any idea about the difference between mach and unix syscall?
 
@bwoebi nope
all I know is 6 hours of CPU time and I'm at 36% completion (this will take some time)
 
I thought phploc would be a quick tool…
 
it is quick
this is a large codebase
and I'm running it over tens of thousands of commits
 
2:11 PM
Dear IMAP,

You suck. Go away.

Best Regards
Chris
 
@DaveRandom should be Best Regards, The Internet
 
I think The Internet as a whole should focus on SMTP first, I'm fed up of arguing with SMTP though so I thought I'd take a piss at IMAP instead for a change.
 
Just use a stupid REST API for mails and be done [why not?]
 
Because internal through local Exchange server
But yeh, for public mail I generally do
 
> 503 Valid RCPT command must precede DATA
 
user5020521
2:16 PM
@DaveRandom I have tried to write you in the other room
 
Oh sorry I went for lunch and then got distracted by real work
 
@Orangepill that looks good. That's how I'd do it.
 
@DaveRandom Wait, people here have jobs?
 
user5020521
ok no metter can you go back ther @DaveRandom
 
will respond shortly, just got to go sort something out in the other office
 
2:17 PM
@Orangepill although I'm thinking of using Reflection to setId
 
@DavidGraham that's what i'm doing now...
 
? now? Meaning later you will use Reflection?
Problem for me is...I want my cake and to eat it too. I don't like unnecessary setters, but I like the type hinting.
I don't think public setters are good. They open up the entity to be in an invalid state. The context or interaction isn't captured.
 
@ircmaxell are you planning to plot the size over time, or to find which commits/committer made the biggest messes?
 
Each interaction should be validated. Yes, you can validate in setters, but you don't know the context. Plus, many times validation is based on multiple values, not on an individual basis. I do use validation in my Value Objects, and that helps.
 
@DavidGraham no I'm working on it now... for a general solution this is what I'm looking at adding to my mappers to support reflecting properties in
private function cacheProperties(){
    if (!is_array($props)){
        $obj = new \ReflectionClass(self::ENTITY_CLASS);
        $props = $obj->getProperties();
        foreach($props as $prop){
            $this->propCache[$prop->getName()] = $prop;
        }
    }
}
private function reflectInfo($object, $property, $value){
    $this->cacheProperties();
    if (!array_key_exists($property, $this->propCache)) throw new Exception("$property Does not Exist on ".get_class($object));
    $this->propCache[$property]->setValue($object, $value);
 
2:24 PM
So you are sort of "auto mapping"? You aren't explicitly mapping each property?
How are you protecting from updating properties that shouldn't be updated?
 
@DavidGraham... probably should ... but in this case everything is scalar....
 
I'm thinking also, that mappers need some sort of way to check for "dirty" properties only
 
user5020521
@DaveRandom this is where i am at now pastebin.com/BWLpwuXc
 
user5020521
as a consequence those variables are undefined
 
@Orangepill what do you mean by "scalar"?
 
user5020521
2:27 PM
as I tried to tell you earlier I would like to use prepared statement
 
what situation would I want to exclude a property from updating assuming that you don't have any contextual validation rules
 
user5020521
@DavidGraham and whoever interested could you please take a look at the link above
 
@davidGraham simple native types... probably should be making sure the pk is an int and such
 
@Riccardo990 That makes no sense, it's not a parameterised query. Honestly, I promise, you don't need (or want) a prepared statement there
And yes, those vars will be undefined because... they're undefined ;-)
 
user5020521
2:30 PM
go back the other room
 
@Orangepill well, maybe the dirty helps with Collection queries more
Like you just want to update a bunch of users to have a status
 
@Riccardo990 Why are you using ENT_COMPAT?
 
I guess you don't need it though. Since I'm changing my strategy to "always hydrate an entity before updating it"
 
Also don't prepare static queries, but I think I have seen @DaveRandom say that a couple of times now during the day
 
What's the consensus on "extension" methods? As in, registering methods to existing types (as a builtin feature, not runkit, etc.)
register_method(string $type, string $name, callable $method) : void;

class Foo {
	public function bar() { ... }
	public function qux() { ... }
}

register_method(Foo::class, 'barAndQux', function () {
	$this->bar();
	$this->qux();
});

(new Foo())->barAndQux();
 
2:34 PM
@Orangepill I'm just starting writing new code for this stuff. I'll have to get back to you soon when I have my approach down. You also look like you are taking advantage of caching, I'm not that far along to do something like that.
 
@DavidGraham for protecting the properties that shouldn't be update I am just removing the setters on the Entity for those properties.
 
A practical example being:
register_method(Traversable::class, 'map', function (callable $function) {
	foreach ($this as $key => $value) {
		yield $key => $function($value, $key);
	}
});

(new ArrayIterator([1, 2, 3]))->map(function ($value) { return $value * 2; });
 
@JoeriSebrechts I'm planning on trying to see what I can see. Whatever that means
 
@DanLugg monkey patching in php didn't realize that was a thing
 
@Orangepill Ah yes, "monkey patching"; forgot that term.
I think it'd be useful here, especially given interfaces. You could have a collection of behaviors and interfaces existing orthogonally.
 
user5020521
2:38 PM
@PeeHaa is ENT?COMPAT misleading?
 
@Danlugg my only issues with that is my ide wouldn't know how to hint on it
 
@Orangepill Not currently, no.
 
@Riccardo990 Why did you use it?
 
user5020521
should not I use it? @PeeHaa
 
I opened a ticket on a website where I used a catchall email address to sign up. I received spam from the catchall I used for them despite their T&C/Privacy saying they don't share the information. I asked where in their terms it says they can pass on my email address. Should be interesting to see where this goes.
 
user895378
2:46 PM
morning
 
The first response was the guy not understanding what a catchall email address is and telling me they don't own "that" domain. Referring to mine.
 
i did that for a while, keep track of separate e-mail addresses to know who were the worst offenders, but i concluded eventually there were too many worst offenders to keep track of, so i returned to using a single email address and spam filtering
 
It all goes to one folder from that catchall anyway. Used for trivial orders mostly.
 
it would be interesting to try it also in the real world, every time i've moved i've noticed the influx of spam congratulating me with the move from companies that shouldn't know about it
 
user5020521
ent compat should be a special char am I wrong_
 
user5020521
2:51 PM
?
 
what is really creepy is companies congratulating me for the baby that will be arriving soon, and trying to market products. i keep wondering whether it's data mining from online stores where we've bought baby goods, or just the hospital selling our data
 
Yeah, it's a little concerning. Not enough to lose sleep over and ultimately with this current ticket I don't care. Just something to do I guess.
I feel a little like "Can I speak to your manager" types but at least it's a valid reason.
I didn't presume they sold it either. I asked to be pointed to the term where it says my email address will be passed on.
 
@Fabor uk website?
 
Yeah.
Seems like they've closed the ticket, without response.
 
you could report them to the information commissioner's office
but i don't know if it would make any difference
 

« first day (1754 days earlier)      last day (3194 days later) »