« first day (4282 days earlier)      last day (649 days later) » 

12:41 AM
@Crell Could it be used to implement some kind of lazy loading for proxy objects ?
 
 
3 hours later…
3:35 AM
@sj-i Yeah, so in regards to the side effects for lazy evaluation, what NikiC tried to avoid by not allowing new in class constants and properties (static or not) initializers is already possible.
@IluTov didn't asked here what you think about it but I'm still on the page that starting to call them more like "initializer expressions" instead of "constant expressions" would be good on the long term.
maybe it would even have made it a bit less controversial... yeah, I don't know.
But I reminded myself about this when reading "Imho Const expressions should soley be about declaring state not traversing it".
 
 
3 hours later…
6:59 AM
@Danack found a Twitter thread that explained, with entertaining commentary, what's going on... and wow...
British coworker commented that there was a "lovely political crisis going on" and only now I understand the magnitude
 
 
2 hours later…
8:50 AM
@Pierrick Yes, Doctrine is one of the use cases we have in mind. If the parent declares properties with implicit accessors the child proxy can override them and load lazily.
@AlexP I think we're past that point if DIMs are allowed.
 
9:11 AM
Can someone explain me why:
$a = ["bar" => [0]];
xdebug_debug_zval('a');

Shows a refcount of 2 for $a.

$a = ["bar" => [0]];$a["foo"] = "bar";
xdebug_debug_zval('a');

Shows a refcount of 1 for $a.
and on a side note, I expected debug_zval_dump() to show a refcount of "+ 1" because of passing the variable, but actually, it is always "+ 2"
 
9:38 AM
PHP 8.0.21 announced - @cmb @ramsey @RemiCollet @Girgias I've dropped a special thanks to you in the email - if you haven't spotted that regression, our next days would be pretty busy
 
10:09 AM
@PatrickAllaert If I'm not mistaken it has to do with the fact that ["bar" => [0]] is stored as a constant in the oparray. So there's a reference to it from the oparray and from the variable $a. Once you try to modify it it gets copied (to not modify the constant) thus losing a reference.
 
@Crell How the guard differs from before when setting a value?
 
@brzuchal They're a little redundant. before could maybe return the value to return for easy transformation of the stored value, but otherwise there's no real difference.
 
@IluTov Personally, I'd drop before and after for now. It is enough complex without these two to consider.
 
@IluTov Makes sense then...
thanks
 
@brzuchal Note that this is not an RFC. We're not planning to add most of those hooks.
It's more of a write-up so we can make more informed decisions.
 
10:16 AM
That would explain as well why:
$a = ["bar" => 0];
=> refcount = 2

$a = ["bar" => rand()];
=> refcount = 1
 
@IluTov Ok, got it. Digging deeper it sounds weird to disallow get/set by-ref if a typed property can deal with type checks by-ref.
 
@brzuchal Typed properties have the "privilege" of only checking the type of the "top" element. If we had array shapes or even just flat array types they'd break.
 
@IluTov I understand
 
cmb
10:43 AM
@PatrickAllaert I think debug_zval_dump() is unusable as it is now. See externals.io/message/113298.
 
I'm using jquery ajax and during success function I just do this success:function(data){
$('tbody').html(data);
}
how do I securely output instead of outputting it as html()
Its vulnerable to XSS
although laravel filters output using the '{{}}' in my controller I'm currently doing this $output.='<tr>'.
'<td>'.$product->id.'</td>'.
'<td>'.$product->title.'</td>'.
'<td>'.$product->description.'</td>'.
'<td>'.$product->price.'</td>'.
'</tr>';
p.s. its does not filter it, if I do <script>alert('kek')</script> it executes it as js and alerts in browser
 
11:05 AM
@helpmeplease Well do you want to output it as HTML? That is not always wrong. What you need to make sure is that user provided content isn't output as HTML. In this case, what you want is probably wrapping your $product->title and description in a htmlspecialchars().
 
@helpmeplease or output it as raw html with $('tbody').text(data); that would not interpret it, as far as I know.
or... put it otherwise, it would escape it in jQuery.
 
is htmlspecialchars() enough to do the work because what if some idiot named a product <script>alert()</script>
I've tried this with data that is being outputted with '{{}}' in laravel and it filters it for me
 
11:22 AM
@IluTov I've also tried finding the magic behind laravel's {{}} so that maybe I can implement it manually but I just can't seem to find it
@AlexP I do have <td></td> so I need it as html what bothers me is the $product->something that has to be filtered in a secured manner
 
@cmb Does this laravel.com/docs/9.x/blade#displaying-unescaped-data mean behind the scenes laravel just uses htmlspecialchars()?
well that solves it... and it was in the documentation
 
11:38 AM
@helpmeplease That should still escape it. 3v4l.org/QXhhP#v8.1.8 alert() without <script> will be interpreted as just plain text.
And htmlspecialchars will escape < and >, so
 
@IluTov Yeah and I didn't even realize the answer was just a few clicks away
 
12:09 PM
@GabrielCaruso @ramsey NEWS cleanup done in PHP-8.0 and PHP-8.1
 
@RemiCollet Thanks, I forgot to do it, I did only for the release branch
 
12:32 PM
Morning o/
 
 
2 hours later…
2:45 PM
@brzuchal They don't really. guard is the language Nikita had used. willSet in Swift can do basically the same thing, so implementing both is probably pointless.
@brzuchal The RFC is only going to have get/set at this point. The goal here is to flesh out the future as well so that we ensure whatever we do can "scale up" gracefully. This doc at the moment is largely "Larry talking to himself in writing", because that's how I think best. :)
@IluTov Do you have an example of a Doctrine proxy object now that I could noodle with, to see how it looks in either new-style?
 
3:43 PM
Does anyone know how to access a php object property that looks like this

SimpleXMLElement (object) [Object ID #5][2 properties]
- @attributes: (array) [2 elements]
- id: (string) "MAT"
- name: (string) "_Advertising materials"

I want to access @attributes but i don't know how- I've tried $elem->{'@attributes'} but that doesnt work
 
Thanks, i just found that also from googling, mybad
 
cmb
4:22 PM
Any zlib expert who'd like to review github.com/php/doc-en/pull/1660?
 
4:53 PM
 
cmb
lol
 
5:06 PM
@Crell SimpleXML is very simple; the problem is that people expect it to be a standard PHP object "containing" the XML in some linear way; it's not, it's an API for accessing things in an XML document
the main flaw in the extension is therefore its debug output, which struggles to represent the many different ways it makes the data available
I'd like to fix it, but there's a limit, which is that print_r/var_export/etc basically represent objects as "arrays decorated with a class"
ideally, print_r(simplexml_load_string('<foo><bar baz="quux" /></foo>')); would show something like this:
SimpleXMLElement <foo>
    ->bar = SimpleXMLElement <bar>
         ['baz'] = 'quux'
but there's no way to over-ride the output to that extent
 
cmb
In my opinion, SimpleXML is too simple.
 
yeah, there's an internal version of __degugInfo (which SimpleXMLElement already implements), but they both work by returning an array; so you have to come up with some "array key" for things like "here is the list of attributes"
hence the "@attributes" in the current output, but then everyone thinks that's a real property name
 
'list of attributes, use [] to access'
 
I give it a week before the Stack Overflow question asking why $foo->{'list of attributes, use [] to access'} doesn't work 🤪
 
5:20 PM
Well yes, but there's no accounting for SO...
 
I suppose the alternative would be to make ->{'@attributes'} actually work; maybe issuing a warning of "you realise that's not what we meant, yeah?"
 
@IMSoP creates post...
 
@cmb maybe; I much prefer writing foreach ( $document->something->blah->blah as $item ) { $ids[] = (int)$item['id']; } than whatever long list of method calls the DOM would need, though
 
@cmb +1 for killing web-qa : ')
 
cmb
@IMSoP It could be a private property; but it could even be public and used as alternative notation.
I'll do a review on github.com/php/php-src/pull/8823 soon, unless someone beats me to it.
 
5:36 PM
@cmb does "private property" even have a meaning for internal classes, especially ones with this much overloading going on? but yes, making it act as though it was a public property is what I meant by "make it actually work"
I'm not totally convinced though, because I'd like to surface more of the things you can do with the object, so we'd also need $foo->{'@name'} to be an alias for $foo->getName(), and so on for a whole series of methods
(this is all assuming I manage to put enough time aside to work on this, of course...)
 
cmb
@IMSoP ArrayObject uses (or at least) shows a private property (3v4l.org/LnGu5); so this might be more familiar.
I wouldn't want to add (much) more magic to SimpleXMLElement, though.
 
having it that verbose would get ugly quickly
 
cmb
I meant something like 3v4l.org/WsEH0 (if the property would be public). Nobody who is aware of the short notation would use the explicit one, but it might be something that helps newcomers to SimpleXML.
 
yeah, I get it; I'm just not convinced it's a good idea
here's what I mean about wanting to add extra bits: gist.github.com/IMSoP/d02c8f4302a5c9f7a686a585d416b6cf
plus maybe @name, @namespace when its relevant; maybe an explicit @children when the content is mixed
the current output just misses out a lot of the data that's available, so people think it's "not there"
 
cmb
5:53 PM
Ah, I see. @content and @name would make sense. Not sure about namespaces. And I'd avoid parsing mixed content with SimpleXML; it won't properly deal with that, if I'm not mistaken.
 
it deals with it absolutely fine
you've been fooled by the debug output
no problems at all: 3v4l.org/JMFoU
an "innertext" that would give you the "hello world!" in one string would be useful, but I don't think even the DOM has that built-in
ditto namespaces; yeah, they're fiddly things, and maybe could have been designed better, but that's not PHP's problem; they exist in a lot of real-world XML, and SimpleXML has perfectly good methods for using them; it's just lacking the debug information to point users at them
 
cmb
@IMSoP Ah, right. But tring to fix this is unlikely worth the time. For me, SimpleXML is for "data" XML (not "markup" XML).
 
oh, beg its pardon, it seems that's what the DOMNode::textContent magic property does
 
cmb
textContent: 3v4l.org/95vQK
 
yeah, just spotted that
 
cmb
6:01 PM
could also use nodeValue (3v4l.org/p6bQr)
 
the fix is literally to add a method on SimpleXMLElement that maps to the same code that powers that in the DOM
they're both built on exactly the same implementation
then it would be perfectly possible to process, say, DocBook, using SimpleXML, and grab the plain text of a <note> from the PHP manual
 
@RemiCollet Just now seeing this. Did I need to use the cleaned up news for the release today?
@Derick 8.1.8, 8.0.21, and 8.2.0alpha3 are all announced. Reminder that 8.1.8 is a security release, so you can mention that in the tweet :-)
 
IIRC, my biggest issues with SimpleXML were its poor namespace support and its complete lack of self-documentability. You had to just kinda guess what the right name/syntax was in any given situation and hope you were right.
 
cmb
@IMSoP for now you can work around with dom_import_simplexml() (3v4l.org/grVXH)
 
I know; that's why adding the method natively would be so trivial - they're just APIs over the same data
maybe it could be public function getText($recursive=false): string where the default mode is the direct text content, like current string cast; and passing true would use the algorithm from the DOM's textcontent
 
 
1 hour later…
8:25 PM
Voter turnout for Make the iterator family accept all iterables seems pretty low (9 and 10 total votes, respectively).
 
8:39 PM
How they're different at all is what confuses me. :-)
 
@Tiffany a perfectly normal country with a serious political system - twitter.com/Fritschner/status/1545077380527673344
4
 
@Crell The voting widget creating multiple forms is not obvious.
 
That is certainly true.
 
@Danack LOLOL! That is hilarious.
 
 
3 hours later…
11:38 PM
Mornings. Now to something completely different: Is it somewhat possible to create a weakref in PHP userspace for PHP versions below having weakref? I'm open for ideas, at the end of the day, it would be great if unset($obj) triggers __destruct() (which it doesn't if refcount(?) is larger than one).
 
@hakre there shouldn't be. As in the point of the RFC was to add something that couldn't be done in userland.
 
Okay, well, yes, this is why I ask, b/c not possible (also what for myself). However is there some practice/pattern/recommendation before wealref? Maybe calling __destruct() manually if exists? Any kind of pattern known?
I know that spl object hash is stable until one goes out of memory (there can be re-use), so propably a parenting object could have its hash until done.
It's just that afterwards there can be false positives. No idea though how often that happens (not concerned about crypto).
Or just spl object hash plus one (static global) tick-counter. But perhaps an object method called _unset() could do it as well so the rest is implementation detail.
 
11:56 PM
oh that was the wrong rfc linked..... the right one mentions two extensions. wiki.php.net/rfc/weakrefs
So I still doubt it's feasible in userland, otherwise they wouldn't exist.
 

« first day (4282 days earlier)      last day (649 days later) »