« first day (1258 days earlier)      last day (3916 days later) » 

09:05
Is apress.com down for anyone else but me?
Firewall again... Thanks
can someone tell me why im getting a fetch array warning?
09:07
@HamZa Oh, cool. Did not know about it.
@JoshC. code && error message please
@HamZa makin a pastebin real quick
@HamZa pastebin.com/JZmMDEAE error is at the bottom
225
Q: Reference - What does this error mean in PHP?

hakreWhat is this? This is a number of answers about warnings, errors and notices you might encounter while programming PHP and have no clue how to fix. This is also a Community Wiki, so everyone is invited to participate in adding to and maintaining this list. Why is this? Questions like "Headers...

/me wanted to earn some rep, ended up closing questions ...
@HamZa well i know its suppose to be because the query failed but the query works
What does learning Apache mean?
09:15
Screw this, no rep for me ...
@bwoebi it is in a form, before he/she sends his CV
im just frustrated because i have run this query before and it worked.
@bwoebi I don't see how I can get it in there =/
it wouldn't make sense
I really would love to add zero-byte vulnerable code, but I cannot see how do it, without making the code scary-long
E_PEDO :p
09:23
hehe
@tereško echo "<DOCTYPE whatever>".$ajax?:include $_GET["page"].".php";
In the last line, is also nice to play with ternary precedence
@tereško What do you have thus far?
@tereško It's been 2 or 3 days you're actively creating bad, vulnerable code.. Are you creating back-door or what? :D
53 mins ago, by tereško
@bwoebi I need a code example for "how would you fix this code?" task for the interviewee
09:26
@HamZa :D
/part sick fuckers
:D
@bwoebi Hehe, that would be fun to take that interview.
How can I run php script on the server by cron more often than once per minute? I need once per 3 seconds. Maybe I should use bash script?
@Leri hihihihi
@ArsenIbragimov not with cron. cron has only 1 minute as minimal interval
But the errors are still pretty obvious…
You just need to pay attention
09:28
@AlmaDo yes i know. So how can I do this?
@bwoebi If you want non-obvious buggy code, let the interviewee find bug caused by concurrency.
@Leri you mean threading… concurrency like in asnyc is mostly more obvious
@bwoebi : obvious errors can distract you from hidden errors
Hi all
@KarelG there are no hidden errors… see the problem? :-P
09:30
@bwoebi Yeah, multi-threaded environment.
@ArsenIbragimov You need a simple background process, basically just a little loop. But "once every 3 seconds" sounds like a bad plan, what does it actually do?
if a person finds 5, then he would think that he has found 'most' while there are 10 hidden
(mornings)
@bwoebi : create some then ;)
like in shell, #!/bin/bash/
wouldn't work :p
09:31
For php it can become even more evil if pthreads are used.
@KarelG that's obvious
@DaveRandom it will be spider - parser script
forgot the '!' lol
i meant on the last '/'
loool
@ArsenIbragimov So what, you're fetching a web page and extracting information from it?
09:32
/fail
@DaveRandom exactly
@ArsenIbragimov And you really need to do that every 3 seconds? That's basically hammering the server and it will eat a lot of resources on your own box as well, does it really get updated that often?
@ArsenIbragimov yes, bash script as a sample
1. Create `do.sh`

    #!/bin/bash
    while [ 1 ]
    do
            php /path/to/script.php > /dev/null &
            sleep 3
    done

2. Then do chmod 755 do.sh
3. Launch it as do.sh &
@AlmaDo You should nohup something like that as well
yeah. or screen
09:34
Or preferably get init to start it
@Leri Please fix that segfault!
that's just a direction to move
user924016
Mooornings
@AlmaDo thanks a lot! I'll try it.
@DaveRandom I think I don't need 3 seconds. I need to pars nest page after previous
@AlmaDo how the bash script will look?
which script?
09:37
Guys I have this issue in my foreach if anyone can help me?(It's probably quite simple for you all)
@ArsenIbragimov Take a look at github.com/rdlowrey/Artax, in particular this example
ok guys ... so .. now the "fixed version" of gist.github.com/teresko/8360b1a0866b3ea93687
is there anything I should do differently (aside form moving it to full-OOP)
Nevermind I solved it.
@tereško Shouldn't that be elseif($email === false) ?
right
09:41
Also personally I find empty(expr) === false to be obfuscation given that !expr will always produce the same result
i actually find the latter harder to see, when I am scanning the code
As in I had to think about what that would do for half a second, and all it's really checking is "is truthy"
user924016
well it is not really the same is it
@RonniSkansing Only if expr is a variable that may not be defined
well .. filter_var() returns either false of the correct value
user924016
09:43
I like it strict =]
user924016
! 0 vs 0 === false
@tereško I actually need to agree with @DaveRandom
i always use strict
@tereško return value of the function
that nothing would gobble through the checks
user924016
09:44
like !== true even better lol
Actually I didn't really solve it, if anyone can still help me?
@RonniSkansing that would be a mistake , look up what filter_var() returns
user924016
@DavidH put the code in some pastebin thing and share the link
Will do.
But actually i'm not sure what to paste..but hold on i'll try
the foreach from which you've issues ...
user924016
09:45
@tereško hmm.. thanks I will do that now
and the var instantiation used for that
fast problem: replace with space OR remove last char from any string...
can be done without a function call?
user924016
@tereško yes right you are.
@tereško Don't escape input to the database (SQL Injection vulnerability)
09:49
it's a test ...
@tereško Is this just a typo?
maybe @tereško : mention it each time you place it
@CSᵠ regex ?
@CSᵠ replace is function call
Also, any specific reason you're using XML in the bad version and JSON in the good?
You know that XML isn't necessarily bad right?
09:51
@bwoebi i'm not sure I get that
static_scalar isn't used for just constants
Also consider adding PDO typehinting to the orderExists function.
but for all kinds of initializers, including property, parameter and static variable defaults
actually constants are the only operators allowed here (apart from literal values)
So this is what I need help with, I added the question in it.
http://pastebin.com/ZmBR5DBq
and as constants aren't allowed actually to be array, it makes no sense
09:53
@NikiC Your comment here is not entirely correct; __get() is not called either in that particular case.
@bwoebi Yes, constants not, I get that part. But everything else is allowed to be an array
Also I don't see why we'd need to use the plus operator on literal values only
The "problem" seems to be that spl_array_get_dimension_ptr_ptr() cannot be overridden in userland.
It just makes no sense
@bwoebi What does that have to do with arrays?
09:54
hm?
I mean, if I can use public $foo = BAR ? 1 : 2; I don't see why I can't use public $foo = BAR ? [1] : [2]; as well
oh...
@HamZa neah.. function call plus regex for such a simple thjing...
@CSᵠ Can you provide an example input and expected output ?
09:56
@AlmaDo well... what about $str[5]=' ';
@HamZa lol !
@CSᵠ E_UNCLEAR :)
thing is i don't lknow how long my strings are
@LeviMorrison I don't think that's Not A Bug. Lack of reference support in SplFixedArray is one of the major PITAs if you try to actually use that damn useless class...
@DavidH :
<?php
foreach($sql_offices as $result)if($i++ < 1){
$office_id = $result->officeID;
?>

= syntax error. Maybe missed something ?
@KarelG Does that give you a syntax error?
09:59
@CSᵠ $str[strlen($str) - 1] = ' ';
Q : how to you place a small formated code here ? >_>
@DaveRandom too bad, function call :D
you have a left bracket { without a right one } ...
@bwoebi really, I'd just handle arrays via ast as well
@AlmaDo Oh right yeh :-P
09:59
No I know that's the point
@KarelG select all, ctrl+k
and get rid of the (broken) constant updating hack altogether
@DavidH please use brackets {} ...
I add the bracket, close the code and suddenly all the divs under the foreach invert.
You're not using python xD
10:00
<?php
foreach($sql_offices as $result) if($i++ < 1){
$office_id = $result->officeID; }
?>
@NikiC So, I should revert that one commit and add some check in lxr.php.net/xref/PHP_TRUNK/Zend/zend_execute_API.c#666 if the result is an array?
@Jack Can't you do a ref-return from getOffset?
>.< I know I know I do close the code it's an example.
@NikiC Do you have some bug id?
@NikiC Not sure whether ArrayObject handles that very well, but currently that's not even called :)
10:01
@DavidH : do you want the first result ? It seems that you are ignoring other results ($i++ < 1)
The issue though is that the foreach forces the divs to close the gray area(Supposed to be CSS). The only way to stop this is to add the "IF" just to check how it's supposed to be but I need to show all the results.
I am well aware that without the IF it shows all the results but it somehow forces the divs to close on eachother.
@bwoebi Yeah, something like that
@DavidH Wait what ? You want to use the first element and that's it ?
either do a ct check by walking the ast or check the result at rt
either should be okay
@NikiC I suppose you wouldn't support this kind of change? heh
10:03
the AST doesn't know anything about if it's a constant or property
user924016
@DavidH
@HamZa Nono whenever I add the IF the entire page shows correctly in STYLE but since I need to show all results I have to REMOVE the IF. Whenever I DO show all results, the DIVS seem to close up on each other and remove the GRAY space between them.
@RonniSkansing Does that however show all the results?
@DaveRandom with lang. construct (not a function):
E_UNCLEAR, good luck though. Need to go to a course now ...
for($i=0; isset($string[$i]); $i++);
$string[$i-1]=' ';
10:04
@NikiC Do you have some bug id with an example about the broken constants in arrays? I don't remember exactly…
@AlmaDo Sorry but what exactly is that?
what?
@AlmaDo nice use there :)
seems like code golf
lol didnt do php for months, isset checks if not null /or is initialized?
10:05
@AlmaDo Yeh but that defies the point, surely. I mean yes, technically that satisfies the requirements but it's just stupid...
@bwoebi you can only do the check on the actual property constant declaration. The nice thing about an ast is that you can walk it, you don't need to do all tests at the earliest possible time :D (But really, RT check sounds simpler)
@bwoebi It was something about duplicate array keys I think
@DavidH : not sure if you're using templates, but
    <div id="foo">
    <?php
        foreach($sql_offices as $result) {
             echo '<p>' . $result->officeID . '</p>';
        }
    ?>
    </div>
or something like that
@DaveRandom lol (: it's stupid by question definition :p
user924016
@user3123545
http://www.php.net/manual/en/function.isset.php
"Determine if a variable is set and is not NULL."
@user3123545 yes
@KarelG I'll try that one moment
though actually, I think that but can probably be fixed even with the current update constant hack...
( actually, <p> is a bad example, i usually wrap it in <ul> )
@AlmaDo It might be good if negative string offsets worked and counted backwards, I'm sure people would hate that if I suggested it though...
@NikiC I think it's easier to fix it with the AST…
10:08
@DaveRandom I'm among those people :p
I'll try…
@bwoebi I think it's better to fix with the AST because we get more AST :D
anyway, I'd first add support for operations on arrays. That's the important bit :) the rest is just implementation details
@NikiC It sounds it was a really good idea to make the constant scalar expressions an AST :-)
ast, we need moar of that!
@NikiC that's also just a rather small change I think… Let me have first a shower, then I'll start fixing these things…
10:10
hello how are you ?
Cakephp?!? I must resist the urge to not bin trash it!
@KarelG The source on the page is a complete wreck I can see. Perhaps I should try and sort it out with paragraphs everywhere?
user924016
@PuzzledBoy room-11.github.io =]
ohk thank you
10:13
@AlmaDo you really should have trashed it :-(
your question is posted just 10 minutes - please, be patient
@bwoebi oops?
@DaveRandom yeah.. cant get much better than that
@AlmaDo I thought posting it once is ok but posting it several times is considered as spamming
@HamZa it's also not ok to post it here too fast after main site (well, I'm judging according to how it was done here before)
@AlmaDo ok, cool
10:15
but it's just my opinion - I may be wrong to treat that as a double-posting
@bwoebi Nevermind, only way to fix it is with ast. I was confused about something
@Jack Nah, that completely breaks the feature ^^ Can't you make get_dimension_ptr_ptr work properly instead?
(Though honestly, I still don't get what part isn't working properly ....)
@Leri typo, yes
@SecondRikudo say wha ?
@tereško In the bad version
Introduce a SQLi vulnerability.
@SecondRikudo there is already one
Hmmm
Yeah, alright, missed it.
30 mins ago, by Second Rikudo
Also, any specific reason you're using XML in the bad version and JSON in the good?
@tereško also ^
10:22
because I am an asshole .. the "bad" part is actually about not sending the header ... making it with json was easier
@tereško What I mean is, are you counting that as a mistake?
Ah, okay
as for the SQL injection, bugs.php.net/bug.php?id=60398
see this one
you will understand
@tereško Yes, yes, I know.
It works especially well when there aren't quotes around the "safe" variable.
It's a nice one, I missed it on my first go :P
(Mainly because I haven't touched in mysql for so long)
@Jack Duh, you had me all confused. There is no get_dimension_ptr_ptr ^^
@NikiC Eh?
10:25
offset access doesn't have proper support for indirect modifications it seems ;)
Right :)
My patch basically forces the engine to perform two steps for the operation.
Which ... well, it does the job I suppose heh
no, that just breaks the feature
you got that the other way around
properties have support for indirect modification via get_property_ptr_ptr
and dimensions don't
properties behave correctly, dimensions don't
I suppose that's another way of looking at it :)
we'd have to implement a get_dimension_ptr_ptr to make it work properly ^^
But that said, at this point no userland functions can be used to intercept such a call
Yeah
10:28
@Jack shouldn't getDimension do it? or __get? or whatever was the case there
So ... we'd have to make it in such a way so that offsetGet() gets called for both properties and dimensions ... as in, it returns a reference when += etc is used.
Like how __get() works.
I suppose __get() gets called when you don't use the "dimension as property" option of ArrayObject.
btw, how does $foo[bar][baz] = xyz currently work for overloaded objects?
I kinda was thinking that that works with &offsetGet
Depends on whether the second dimension is a regular array or another ArrayObject I reckon? :)
independently of array object
lets say second dim is an array
let me double check that that actually works and I'm not just imagining things...
I think read_dimension is called with VAR_RW ...
10:34
Okay, so turns out it really isn't supported
bummer
If offsetGet() is defined, it doesn't return reference when you do that =(
If you assertFalse(methodThatDoesntReturnAnything()) - what is the expected outcome?
@Jimbo failure
void == null !== false
@NikiC So hmm .. any easy fixes you can think of? ;-)
@NikiC How about assertNotTrue()?
10:35
@Jack Add get_dimension_ptr_ptr :D
it would be pretty rad to support indirect modification there...
Yeah .. okay, let me play around with that :)
I always thought SPL classes were just too stupid to implement it, but turns out it's not supported at all ^^
So it should call offsetGet() ya?
Ah there's assertNull. Cool
If it's overridden that is ...
10:36
On the other hand: codepad.viper-7.com/5wbxj7
Seems like it works for ArrayObject... so wtf
I give up
user2286243
Anybody knows what happens of $var if we use return $var; in a PHP procedure (not function/method)?
@VarunAgw A PHP what?
@NikiC Yes exactly ... because you didn't override offsetGet() :P
S(PL)urprise!
user2286243
@Jimbo php code
@Jack Yeah, but how does it support it internally?
10:37
@VarunAgw What's a "php procedure"?
Ah, it tricks the engine heehee
It that can do it internally, we should be able to do it in userland as well, right?
@VarunAgw procedure ? mysql O_O ?
user2286243
like <?php return $abc; ?>
10:38
We should definitely be able to do such a thing!
@VarunAgw it exit the code
@VarunAgw Nothing'll happen... ^
user2286243
I think something happens with $abc.
@Jack Iei hacks
user2286243
just a minute
10:39
w00tz
@NikiC Perhaps that code was written when there wasn't any good alternative?
Not sure ...
user2286243
How this file work
@Jack nah, that should be the only way
Hehe okay
so, instead of doing get_dimension_ptr_ptr that hack could be extended to be supported everywhere :D
10:40
a git push for some spelling errors ?
I have certain doubts regarding that being a good idea tho ^^
Did I ever mention how much PHP sucks?
Eh yeah, well, this is SPL though.
user2286243
@NikiC yes
PHP + SPL == PHP + 97 bugs.
@Jack Also PHP... the object handlers are not spl...
10:43
Good point :)
user2286243
Anybody have idea how overriding works here github.com/zendframework/ZendSkeletonApplication/blob/master/…?
@VarunAgw $config = require $file;
that's where the return value goes ;)
yup, your php code is one big function.
user2286243
oh. first time seeing require returns value
user2286243
thanks for help
10:52
    $header = $result->noteheaderID;
    $text   = $result->note_text;
          if($text!="!!NEW NOTE!!") {
            $str_return .= '<div class="card">' . "\n";
            if(strlen($header)>1) $str_return .= "<h2>" . $header . "</h2>" . "\n";
            $str_return .= "<p>" . $text . "</p>";
    		$str_return .= '</div>' . "\n";
    	}
    	return friendly($str_return);

Guys why does this tell me that I can't use friendly and that $str_return isn't a defined variable?
To be specific: Undefined variable: str_return in ... on line 137 Fatal error: Call to undefined function friendly()
Because you can't and because it isn't.
But str_return has multiple values?
@DavidH Well, that mus mean that your if condition failed.
@DavidH You didn't initialise the variable you just started using it, you didn't define it if $text is !!NEW NOTE!!, and clearly you didn't define the function but we can't see that from the code you show.
@DaveRandom I don't quite get what you mean..
11:00
@DavidH Well don't do $var .= if you haven't initialised $var as a string, and think about what will happen when your if block is not entered
Good morning.
So... I just figured out, if I have noise cancellation enabled on my headphones and the sound reasonably loud, I can't hear the fire alarm.
.= should call __append() hehe
(fire alarm just went off at the office for testing)
@DaveRandom Hmm that helped, thanks!
11:49
@VarunAgw hm?
@VarunAgw that's just an empty config file

« first day (1258 days earlier)      last day (3916 days later) »