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

11:01 AM
@Danack The solution to all versioning problems is to just create a new major version for every commit
 
@Patrick dont implement it yourself means? You mean im better off using plugins or libraries that do the job?
 
@NikiC Not if you can only have one version at a time like in PHP. :P
 
@Danack , the advice in the link worked well. Thank you a lot! :)
 
@Sherif
This is what I get when I add a product for first time
Array ( [7] => Array ( [quantity] => 1 [price] => 2000 [cat] => tshirt [id] => 7 [size] => 2.6 size [name] => leecooper [color] => red) )

And when I add same product with same size and color i get this code given below:
Array ( [7] => Array ( [quantity] => 1 [price] => 2000 [cat] => tshirt [id] => 7 [size] => 2.6 size [name] => leecooper [color] => red) )

It's the same as above so does that mean that it doesn't call my comparing function?
 
@kelunik hence we need to introduce something like a v1 subnamespace
 
11:05 AM
@Demorus PHP already implements this for you
 
@Demorus look at the links in my reply
 
@Just checked. Ok because I saw someone manually doing the salt thing in a tutorial
 
@bwoebi Better just follow semantic versioning. ;-)
 
Probably an old tutorial
 
2013 and there is the problem.
 
11:06 AM
@Demorus there are lots of horrible tutorials out there :)
 
@kelunik doesn't help when a project wants v1 and another one v2…
 
That is why you guys are great help. I also often post questions on the forums here
 
@bwoebi Sure, just don't break anything ever. :P
 
hehe
 
@HardikSisodia Why are you using print_r? I suggested var_dump($_SESSION) for a reason.
 
Missing argument 1 for myFunction(). Did pass my connection ($connection) as an argument
 
@HardikSisodia Notice the var_dump($_SESSION) not the var_dump($_SESSION[$id])
 
@kelunik I was asking if @bwoebi wrote that code
 
@NikiC no.
I'm not that insane ;-P
 
11:14 AM
 
Is there some efficient way to git blame?
 
All the efficiency happens underneath the hood. Nothing about the end-user experience can be portrayed as efficient.
 
It's very annoying to a) click commit b) view state at time of commit c) view history for file d) switch to previous commit e) blame again f) repeat
 
But that just might be my experience.
 
@NikiC yeah, doing that too :s
 
11:16 AM
There should be some way to "switch to git blame before this commit"
I mean, that's the only thing that people are interested in, why is it so hard?
 
Yeah, miss that, too.
 
Blaming is probably the one area that SVN does better...
 
@NikiC I blame bad PMs
 
PMs?
 
11:17 AM
Product Managers
 
@kelunik eih, you have good experience writing to github support :-P
 
@Jay OP isn't even allowed on SO, because the minimum age is 13
 
PMs are almost always the first to blame for poor UX, in my experience.
 
Blame murica's privacy laws fo dat
 
American privacy laws ... lol
 
@bwoebi Not just github, also lxr
 
@Sherif
This is what I get when I add a product for first time
array(3) { ["id"]=> string(0) "" ["username"]=> string(0) "" ["cart"]=> array(1) { [7]=> array(6) { ["quantity"]=> int(1) ["price"]=> string(3) "2000" ["cat"]=> string(10) "tshirt" ["id"]=> string(1) "7" ["size"]=> string(8) "2.6 size" ["color"]=> string(8) "red" ["name"]=> string(13) "leecooper" } } }

And when I add same product with same size and color i get this code given below:
array(3) { ["id"]=> string(0) "" ["username"]=> string(0) "" ["cart"]=> array(1) { [7]=> array(6) { ["quantity"]=> int(1) ["price"]=> string(3) "20
 
@HardikSisodia Ahh!
See now THAT is useful
 
@Jay I felt so bad that I had to flag him for mods. Now I feel so much better.
 
@NikiC not using lxr for that… lxr blame is fucked up in some browsers
 
11:21 AM
chat.stackoverflow.com/message/25201657.txt < Does anyone know if that worked before?
 
Time to check error logs ;)
 
@NikiC I like that. /me puts it on the ever growing list :P
 
@kelunik there was a JSON source, IIRC
 
Yeah, .json returns also an error instead of a 404 like other pages.
 
@kelunik I'd have though something like that would be Accept: based
 
11:25 AM
@Sherif I am just not sure where exactly am I going wrong, How can we check error logs in this session
 
meta it up
 
@HardikSisodia I'm not either, but I'm willing to bet you have an uninitiailized variable error somewhere according to that var_dump
The error log will help you with that
 
@DaveRandom Indeed. http "http://chat.stackoverflow.com/message/25201657" "Accept: text/plain" works.
 
Anonymous
user image
2
 
Anonymous
^ @tereško
 
11:27 AM
@Sherif So how can I check error logs?
 
@kelunik remove the .txt
 
@HardikSisodia You'll have to look at phpinfo() to figure out where you're storing your error logs or if error logging is even enabled and error_reporting is turned up. If the value of error_log in phpinfo() is empty and you're using something like mod_php it means it's likely going to apache's error log. Otherwise it's the given path.
 
@AwalGarg Yes, just noticed that, thanks.
 
11:30 AM
@kelunik ok :( you can also add ?plain=true to get raw message instead of a blob of html
 
It seems like the blaming is a regression
They used to have an extra >> in there that went to the parent blame
 
@Jay are you said that I did something wrong? Please, convince me that I should not report 12-year olds who are using this site. Gimme your best argument.
 
Anonymous
@tereško It was a joke... Chill.
 
> there have been several dozen
times in the last few years where I think “What moron added this code?
It looks as if a slow monkey on barbituates got arbitrarily angry at the
keyboard!”, only to find through my friend ‘git blame’ that that monkey
was me. That’s helpful information to know before you go yelling at
your co-workers.
So true
 
I think I missed the "joke" part.
 
Anonymous
11:32 AM
@tereško That's unfortunate.
 
@AwalGarg Great, thanks!
 
Cool to see random tutorials with Auryn popping up :)
4
 
@tereško hey, have you thought about attending this ?
 
@tereško there will be Yii devs!
 
11:41 AM
0
Q: Re-nest arrays into tree using its field as parameter

Aedix RhinedaleI'm losing my hair on this one... I have an array structure that print_r's like this (I've hidden unnecessary fields): [0] => Array ( [id] => 14 [name] => Foo Directory ) [1] => Array ( [id] => 16 [name] => Bar Project [parent] => Array ...

Love questions like that.
But looks like the OP already found the solution. :/
 
Well, it's PHP: 3v4l.org/TuQvK
 
@kelunik heh, weird. I can't even remember why it does that.
 
@NikiC Can I ask you something regarding your PHP-Parser?
 
@Sherif Just found it on /r/PHP
 
@kelunik dahell
 
11:46 AM
@kelunik Yea, I know there's a reason. I just can't seem to recall it.
However stupid it may be.
Has something to do with truth in value as I so vaguely recall
 
hey guys, has anyone ever worked with ibm informix pdo?
 
@kelunik yay PHP!
 
I need help to test why it is telling "optional features not implemented" ? If any one.. I made discuss in here : chat.stackoverflow.com/rooms/87474/…
 
@treegarden sure. Though off for lunch now, so can only answer in 30 min or so
 
11:53 AM
@kelunik What was the redit thread?
 
@kelunik Yea, it's a silly bug really, but he's right. It's still a bug.
 
@NikiC no problem. So I'm traversing the tree as described in the documentation, and I'm wondering if I can easily access the parent of a node somehow while doing that.
 
IS_NULL < IS_FALSE unfortunately
heh
 
@SergeyTelshevsky oh, joy.
last time I checked, DevClub.lv was expensive and pointless
.. and since this one is free, it's probably because they know how terrible this one will be
 
11:57 AM
@Sherif I wonder if someone will complain, because they abused this behavior.
 
I'm sure they will.
PHP is a popular kid. Someone, somewhere, decided to rely on this behavior at some point in time.
Then again this warning was actually not that old. If I recall correctly @NikiC was the one that added it in 5.4
oh no wait that was the offset one
bah
 
@kelunik any idea what that person thinks the actual behaviour should be?
 
I'm guessing he'd want it to work same as with $foo = false
I mean it makes sense
No obvious reason why you'd expect different behavior between them. They're both booleans.
The beauty of nested ifs :D
 
@Danack I could imagine something like this:
 
@tereško that means no? :) I've registered, but will think about it again
 
12:02 PM
$foo = false;

while (...) {
   if ($foo) { $foo[] = "foo"; }
}
 
posted on August 20, 2015 by kbironneau

/* by arterzatij */

 
But you could just set $foo = [] there.
 
@SergeyTelshevsky well, if you are interested, I am not saying you not to go ... just be braced for impact
 
@Sherif I just now saw in cart it is showing one error
Undefined index: qty in J:\XAMPP\htdocs\ekart\viewcart\cart.php on line 109
@Sherif I even saw logs there are no such error shown to help out resolve this problem
 
@HardikSisodia Looks like an error to me
 
12:09 PM
@Sherif So does this mean add to cart button works well but not the cart.php?
 
It means you have an undefined index on line 109 in the file J:\XAMPP\htdocs\ekart\viewcart\cart.php
The rest remains to be seen
Start with what you know and leave what you don't know alone.
What you know for sure is what PHP is telling you in that error message. What you don't know is what the ramifications of that bug could be.
That's where you have to first fix the problem and then continue to investigate how it changes behavior. The more you investigate, the more you can know and begin eliminating possible causes effectively.
 
@Sherif It's not a bug
PHP promotes falsy values to arrays
 
@NikiC No?
 
It sucks, yes, but it's not a bug
You'll get the same difference with 0 vs 42
 
@NikiC really?
 
12:20 PM
It looked like someone had overlooked a potential branch in the code to me at first glance.
 
or "" vs "a"
 
But I really didn't look that deeply into it.
@NikiC Right, but that's because it's only looking for falsey values
Which seems weird to me.
But I guess if you think it's intentional, then whatever.
 
@NikiC Warning: Cannot use a scalar value as an array in Command line code on line 1 … only null and false are promoted … but why false?
 
It very well may have been defined somewhere at some point in time, but yea it's silly because it makes the intended behavior seem non-obvious
 
3v4l.org/qoe6i < Whoever added that, thanks! /cc @Sjon Why is that marked as abusive script?
 
12:22 PM
IS_NULL < IS_FALSE
 
@bwoebi Hm, maybe I'm confusing this with reads instead of writes
@bwoebi It works with "" but not with 0
 
@tereško I still owe you a drink, btw
 
@NikiC and it doesn't work with "0" btw.
 
@bwoebi Now this is PHP
 
That giant wad of nested ifs is just difficult to decipher :/
 
12:24 PM
I think someone wanted to make it work on falsy values and reimplemented some of the checks, incorrectly...
 
why is there a 3x in the top left corner of my page? stoques.eu?
 
@NikiC put it on the list of things to fix in PHP 8
 
@treegarden Nope, I don't think so
 
@NikiC Yea, but that only works when the type itself is either false or null.
So, if it's a string or array or object, for example, it falls into a different branch of code
So you never get there. So it's hacky at best.
So $foo = null; $foo[] = 'something'; works, and $foo = false; $foo[] = 'something'; works, but $foo = 0; $foo[] = 'something'; doesn't
 
★ ★ ★ ★ ★ github.com/laruence/php7-internal ★ ★ ★ ★ ★
7
 
12:28 PM
bob-weinands-imac:~ Bob$ php -r '$a = "0"; $a[] = 1; var_dump($a);'
PHP Fatal error:  [] operator not supported for strings in Command line code on line 1
bob-weinands-imac:~ Bob$ php -r '$a = ""; $a[] = 1; var_dump($a);'
array(1) {
  [0]=>
  int(1)
}
 
Holy stars, batman.
 
^ wtf? not supported for strings, but works on "" ?!?!?
 
@treegarden And it's probably not possible to add parent nodes using a node visitor
 
@MagnusBurton Because it's in the source:
> <body class="external-page sb-l-c sb-r-c onload-check">x3
 
@bwoebi I vaguely remember that being a deliberate decision... but don't ask me by who, or why.
 
12:29 PM
@Sherif As per error showed the error is in this line given below but I am not able to understand what's wrong with this line given below:
if($_POST['qty'])
 
@salathe lol
 
@salathe óÒ
 
@bwoebi Because the code is retarded lxr.php.net/xref/PHP_TRUNK/Zend/zend_execute.c#1680
It specifically allows 0 length strings.
Too many one-off branches
 
user3119231
function setItUp($import, $default, $orders){
	$handle = fopen($_GET["csv"], "r+");
	while (($data = fgetcsv($handle, ";", '"')) !== false){
		$num = count($data);
		$output = [];
		for ($i = 0; $i < $num; $i++){
			foreach($orders as $order){
				$parts = explode(" > ", $order);
				if ($data[$i] == $parts[0]){
					$data[$i] = $parts[1];
				}
			}
			array_push($output, $data[$i]);
			fputcsv($handle, $output);
		}
		print_r($output);
		break;
	}
}
 
user3119231
Not possible to overwrite field per field in first row?!
 
user3119231
12:31 PM
Only pastes all in the first field in second row?
 
@Sherif yeah, that's stupid
 
But guess what happens when it's not a zero-length string
 
@Danack but i didnt add it to my page
 
;)
 
@Danack it's come from nowhere
 
12:32 PM
Which is why I would think it was a bug upon first glance
 
I really doubt it has.
 
But what do I know. I stopped touching internals years ago.
 
Either you have a weird typo in your code somewhere or some of your javascript is malfunctioning.
 
@Sherif As per error showed the error is in this line given below but I am not able to understand what's wrong with this line given below:

if($_POST['qty'])
 
@Sherif Do you touch anything any more?
 
12:33 PM
@NikiC Oh okay, well I think I found a workaround anyway. Thanks anyway! :)
 
@treegarden What workaround did you use?
 
@HardikSisodia The error is telling you exactly what's wrong. The index "qty" was not defined in the variable $_POST. You are using it as if it was. Use isset() instead.
 
@Maurize Writing back to the fp in the loop you are reading from it using the *csv() functions is not going to end well
Use php://temp or something and copy it back after the loop
 
@salathe Physically?
 
Also fopen($_GET['csv']) is a ridiculous security issue
 
12:34 PM
Because that could get dirty real quick.
 
@kelunik seems like a fluke
rerun fixed it
 
user3119231
@DaveRandom the point is, that array is correct. I just am unable to write stuff in the first line. It is overwriting and cell per cell...
 
@salathe If you meant in PHP, I think I might have pushed a doc fix a few weeks back.
 
@Sherif *grin*
 
In fact that whole function makes very little sense
 
12:36 PM
I don't know what I was thinking.
 
@Sherif A moment of madness, huh? :)
 
Meh, I felt like being nice.
 
@Maurize The fputcsv() call is in the wrong loop (should be in the while I assume) but seriously, that approach is really going to cause you no end of issues
 
user3119231
so how would you do a function like this?
 
@Sherif since php is evil, isn't it bad to contribute to evil?
 
12:38 PM
@Sjon I still see that warning.
 
@FlorianMargaine PHP use(d) Crockford JSON parser, ergo PHP is not evil
 
@FlorianMargaine ^
 
user3119231
Man this Florian is everywhere...
 
@NikiC Something very simple. I need to know if a specific Node is a subnode of a function call, so I just check for that on enterNode(), so I have the information in leaveNode()
 
@NikiC didn't he amend his license?
 
12:38 PM
@Maurize I'm struggling to work out what it's supposed to be doing...
 
@FlorianMargaine Nope, he was always a dick about that license
 
@kelunik HTTP 304 strikes again. But it really is fixed ;)
 
It's good to know people took his license so seriously.
"But but but.... I want to be evil :-("
 
@Sherif Well I cleared that error but still now problem is with adding same product to cart with different size and color, that overlaps the product added in my cart already
 
user3119231
@DaveRandom Open the .csv file, read out first row cell per cell, then compare if there is a match with the 2 parts in order array and replace them.
 
user3119231
12:39 PM
			foreach($orders as $order){
				$parts = explode(" > ", $order);
				if ($data[$i] == $parts[0]){
					$data[$i] = $parts[1];
				}
			}
 
user3119231
later the .csv must be imported with the correct columns, so I need to replace certain column names with the ones in array
 
@Sjon Ah, yeah, confirmed. :)
 
@HardikSisodia Update a gist with the code including how you got the $size, $color, etc... variables. It's hard to tell anything more without a broader view
 
@Maurize Ahh, so you are only trying to manipulate the column headers?
 
Try not to remove bits and pieces of the code as you may inadvertently remove the bug you're looking for
 
user3119231
12:41 PM
@DaveRandom yep, thats all. Here is a template of array terminal.bm-designs.de/index.php?id=1
 
user3119231
the js way :D
 
@kelunik I believe credits go to @Ja͢ck
 
@NikiC I thought he changed it for IBM at least
 
IBM has Watson pondering how one can use JSON and not be evil.
I think they also tried to get him to solve the Halting problem. Unfortunately, I heard he halted.
 
I prefer Hudson as a name
 
12:44 PM
@FlorianMargaine Didn't change the license, only gave IBM and its minions explicit permission to use it for evil ;)
 
Is it possible (by some hack, maybe) for an object to substitute itself by another one?
 
@SergeyTelshevsky Substitute itself to another one?
I can't mentally parse that sentence for some reason.
 
@SergeyTelshevsky no, not directly. You would have to make some "decorator" type thing and replace the contained instance instead.
 
class MyClass = {
      public function f()
      {
              $this = new stdClass;
      }
}
$x = new MyClass();
$x->f();
 
@Sherif Another itself to substitute one!
 
12:47 PM
@salathe Ahh, you complete me
 
fixed that yoda sentence
 
@SergeyTelshevsky shudder
 
just wondering, not practical but in theory
 
A theory is something that you can neither prove nor disprove. Since we can prove that you can't write to $this then it's practically impossible. Therefore not theoretically possible.
s/can/have
 
@Sherif I know you can't write to $this, but ain't there no other way?
 
12:50 PM
.. I already gave you a way
 
@SergeyTelshevsky Inside of object context?
None that I can think of.
You'd have to be outside of the object context to be able to replace it.
Which means you're already at the container level
Unless you want to use reflection and do some really nasty stuff
 
@tereško yes, forwarding everything as a wrapper, but that's not substituting :)
 
yes, it only lets you substitute what has been wrapped
 
Hi.
Guys, what is the best way to separate business logic and the basic CRUD operation functions in an application?
 
but it requires a wrapper for the object itself
 
12:52 PM
@NikiC We used to do this all the time when Exceptions didn't exist yet, our codebase was full of function __construct(){ if () $this = new error; }
 
Metamorphic PHP is not something I even want to think about
 
.. well .. you probably could do something really ugly and use global variables ^^
 
obviously this was ~ 10 years ago
 
Mutative types? I don't even know what to call that.
 
12:53 PM
@Sherif "clusterfuck" comes to mind
 
@Sjon wow
 
@tereško Sounds about right.
 
Didn't expect that that ever worked
 
@NikiC and we had an Error::in method to detect errors, guess what our codebase looked like ;)
thank god for try/catch
 
@NikiC @Sjon Wait, how does that even work. I don't get it.
 
12:56 PM
@Sherif if for instance the database has an error; you let the constructor replace $this with an error object
in your controller you do if (error::in(new database)) ..
 
@Sjon But you can't write to $this.
 
@Sherif that's the point, in older php-versions you could
 
@Sherif you can't today. You could long ago, AFAIK.
 
@bwoebi When was this? PHP 4?
 
@Sherif yeah
 
user3119231
12:58 PM
@DaveRandom good. fixed some mistakes and refreshed page. .csv is now empty :D
 
Holy crap! 3v4l.org/SCie8
heh
TIL
PHP 4 sucked then, it still sucks now.
 
xD
 
yeah php4 didn't improve :X
 
@Maurize fixed
(forgot to rewind the temp fp)
 
3v4l.org: reminding you of the dark age of PHP how PHP 4 nearly ruined the world
 
12:59 PM
lol
 
Yea, nobody got OOP right in PHP 4
Lesson learned
 

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