« first day (4499 days earlier)      last day (438 days later) » 

12:53 AM
@Dharman Mayeb I can help
 
Do you have the access to the machine? Can you check what would be required to upgrade? I think upgrading PHP and dokuwiki is enough.
 
I do.
I was fixing their mail server earlier today.
But... I worry about upgrading dokuwiki
Can we chat tomorrow? I'm about to go to bed (it's 1am) and I've been out with friends.
 
I am going to bed too, same timezone
I will ping you tomorrow
 
eggcellent
 
 
5 hours later…
6:10 AM
$arr = [0 => true];
unset($arr[0]);
var_dump($arr); // empty array
$arr[] = 'bar';
var_dump($arr); // one element index 1
Interesting how an empty array looking innocently starts indexing the first new element with 1.
 
6:39 AM
morns
 
 
3 hours later…
9:58 AM
posted on February 09, 2023

 
10:18 AM
Mornin o/

I'm thinking about making an RFC for `using` statement in PHP ( see https://ara-lang.io/statements/using.html ), before I start writing the RFC, does anyone have any notes?

The only problem I see: if we make parenthesis required around assignments ( to keep consistency with all other statements ), that means `using` won't be able available as a function name anymore, as it requires lookahead in order to differentiate from a function call ( e.g `using ( $a = foo(), $b = bar() ) { }` requires us to lookahead for `{` to tell if's a function call or a using statement ), so should we
 
10:58 AM
I'd say that making 'using' a keyword is fine. I can't think of anything a function of that name would do and GitHub's code search for " using(" language:PHP seems to agree.
But this could be a secondary vote in the RFC.
Alternatively, use might be an option? That already exists.
 
11:15 AM
Why this approach rather than RAII and freeing on destruct?
 
11:26 AM
I find it mostly useful to deal with possibly-null values:

if (($foo = $this->fooOrNull())) {
// $foo may legally be accessed here.
}

// $foo may no longer be accessed here, but is technically available.
 
technicalities with scope are an area where PHP has historically done... not well e.g variables trailing after loops
 
 
1 hour later…
12:40 PM
not just that, but also, imagine you have a function or a file with 100 lines of code, you create a database connection on line 4, use it in line 5 and 6, but the rest of the code doesn't use it, the database connection will still be open, as that variable is still in scope, it doesn't get destroyed until later on, with using, it's removed immediately after usage.

e.g:

```
using $connection = establish() {
$data = $connection->query($sql);
}

/// continue with $data, $connection has been destroyed.
 
because I'm tired of seeing people assigning things in if statement condition :P

but the main problem is PHP doesn't drop things immediately when there's no use for them anymore, e.g: https://3v4l.org/Qs1EL, while in https://3v4l.org/d7MO8, hello would be the last thing outputted.
 
1:37 PM
@TimWolla they're finally catching up to gitlab
 
Morning
 
2:19 PM
@azjezz Why is that a problem? Or, what kind of risk is involved in having a database connection being open for some ms extra?
 
Ohai all o/
 
\o
@PeeHaa Glad you're ok! =)
Apparently far away from you guys.
 
@OlleHärstedt It can be ms, or hours, depending on what is below that code.
 
@azjezz Is that like the defer thing that was proposed for C23?
 
2:34 PM
don't think so, some links:
python: https://docs.python.org/3/reference/compound_stmts.html#the-with-statement
c#: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement
hack: https://docs.hhvm.com/hack/statements/using

also note: unlike Hack or C#, we don't have a special interface for objects that are disposable, we just call dtor, and if the RC of a variable is over 1 ( i.e something took a reference to one of the assignments inside the block ) an exception is thrown, so this throws:
 
@StatikStasis Yeah we all good. At least until the next big one close by again :P
 
2:49 PM
D:
 
2:59 PM
@PeeHaa Started streaming Hogwarts Legacy last night. It is beautiful.
 
Wes
hey! been reading that turkeys government blocked access to twitter in an attempt to hide the real death toll. "quick response" from the army was actually 36 hours late. that's so effed up if its true
 
Multiple reasons
 
 
1 hour later…
4:35 PM
howdy, does someone know a .env file parser that is simple enough to parse .env files as with docker run --env-file? e.g. vlucas/phpdotenv and symfony/dotenv have opted not to and I'm bit puzzled as I thought this should exist.
 
4:59 PM
@azjezz Yes, but what's the impact and probability in general?
 
@PeeHaa Glad to see you safe mate
 
5:36 PM
Does anyone know how reference/datetime/timezones.xml is generated in doc-en ?
> <!-- AUTO GENERATED, DO NOT TRANSLATE OR MODIFY BY HAND -->
 
@azjezz agree, I like the idea, also think that Hack documentation explains it very well because I understood it. I'd say make using() unusable function name and if there are any objections think of placing an RFC that introduces a way to escape T_STRING literals to be recognized as different tokens. I think in one of the languages it is done by \using but int PHP it should be different char.
 
@MarkR <3
 
6:00 PM
@Danack Yes, I do.
@Danack doc-base/scripts/gen-phpdoc-tz-list.php
 
@Derick ta
 
I run that every time I update the tzdb
so... don't mess with it ;-)
 
@Derick for context - github.com/php/doc-en/pull/2277
 
bogus report
both Kiev and Kyiv are in the documentation
He needs to update his timezonedb
 
I'll update the script to include a note about how to regenerate that file, and also why people probably shouldn't touch it...
 
6:35 PM
Just imagine how much you could troll devs by adding random notes everywhere saying <!-- AUTO GENERATED, DO NOT TRANSLATE OR MODIFY BY HAND -->
 
 
2 hours later…
8:33 PM
Any idea why doing a fetch_assoc() on an empty mysqli result set throws the error "Cannot use temporary expression in write context"? There appears to be no one specific cause of that error in searching around. The query is not failing either
 
assign the data from mysqli result first to a variable and do fetch_assoc() on that variable, does that work then?
 
@Machavity You really shouldn't be instantiating new mysqli_result on its own
but it shouldn't allow anyway. You will get an error saying that mysqli_result is closed
 
I'm not? I'm doing a prepared statement. Then again, I'm not sure what triggered this
 
A prepared statement? Then you are more likely playing with references.
 
Yeah, but the query succeeds. I get a mysqli_stmt object and then run get_result to get the mysqli_result.
 
8:41 PM
```
$s = $mysqli->prepare("SELECT ?");
const a = [];
$s->bind_param('s', a[]);
```
This would produce an error like you said
 
Ah, there is a constant array involved
 
Can you share the line that is mentioned in the error message?
 
The problem is that you are using mysqli instead of pdo :P
 
That too
But any write to a const array would throw this error. e.g. const a = [];a[] = 1;
 
If I didn't have to rewrite the codebase I would use Peehaa's Dumb Objects :P
Initially it blew up here $prep->bind_param('is', $this->user_id, self::TOKEN_TYPE[$token_type]);
 
8:45 PM
I wouldn't use either one of them in my projects. I would go for DBAL straight away.
 
JRL
use bind_value instead?
 
There is no bind_value
 
JRL
er... oh. not PDO
 
@Machavity :D
 
I moved that into a variable (bind_param is finnicky about that) but then it blows up on if($row = $result->fetch_assoc()) (where the prior line is $result = $prep->get_result();)
 
8:47 PM
@Machavity Can you use execute() and pass it as an array?
If not, then you can use a level of indirection with $prep->bind_param('is', ...[$this->user_id, self::TOKEN_TYPE[$token_type]]);
@Machavity This shouldn't produce this error.
 
JRL
wow
mysqli really doesn't have a bind value?
 
It has only bind-in-execute since PHP 8.1
 
In other news, twitter is going great: twitter.com/oneunderscore__/status/1623777351338270720
 
JRL
is there a technical reason?
 
It stopped blowing up there just by doing $token = self::TOKEN_TYPE[$token_type]; (bind_param complains if it can't be passed by reference)
 
8:51 PM
@JRL no
 
@JRL I have asked for one many times. But nobody knows how mysqli works. Apparently it's magic
 
JRL
im pretty unfamiliar with the db wrapper and driver side of things
 
Well, I tried to fix things up in 8.1 and 8.2. I hope it got a bit better
Suprisingly I cannot find a quesiton on Stack Overflow mentioning this particular issue with bind_param. It might be a good idea to post a new quesiton
 
JRL
i just found it surprising that there was no way to fill a prepared statement without using pass-by-reference
i only ever use PDO :/
 
you can use spread operator or bind-in-execute
 
JRL
8:56 PM
ahhh.... okay, not i get what you're saying
now*
 
and in PHP 8.2 things just got a lot easier for mysqli with mysqli_execute_query()
 
Yeah, in the uncommon cases I need a conditional bind I just jump through hoops to shove it in an array and use the spread
It doesn't solve the crazy long bind type string tho ssidissidiiisiisiiissssiisisss
 
wow lol
why not use s for all of them though??
str_repeat('s', $count) to the rescue
 
I made that up, although I do have one that was like 20 long
 
@Dharman sometimes these things affect queries ... mostly not but sometimes
 
8:59 PM
too rarely to care
 
Until it bites you :-P
 
JRL
my first ever interaction with internals was about DB stuff, lol
i reported a segfault in PDO when you tried to clone the connection object
which i agreed you should never do, i didn't realize i was cloning it at first. but it shouldn't have been segfaulting
i think joe solved it by having the clone handler for PDO throw? it was something like that.
 
"We made it segfault to teach you a lesson. We hope you've learned your lesson"
 
JRL
point is, DB stuff bites you when you least expect it
@Machavity that was actually about some of the responses i got from other PHP devs, lol
"why would you clone the db object? that shouldn't work" "Look, I don't want it to work, I just want it to not segfault"
 
@Derick So why are you having concerns about the upgrade?
 
9:06 PM
Agreed. DB connectors can be a pain. Someone fired up a stupid-old tool last week and, because it creates insane numbers of temp tables, ate up like 99% of the write capacity on the DB. Had to whip up a whole new report so they'd never do that again
 
9:23 PM
And I found it. Wasn't failing where I thought it was. Vague bug to track down and the catch tracing wasn't useful.
Ultimately, I had another instance of trying to bind a constant array. it just wasn't telling me that was what it didn't like
 
10:06 PM
Lolol ondrey sury @ "bug bounty"
 
I don't even know which system they are talking about
They probably mean the accounts people.php.net
 
10:31 PM
@JRL I mean, sometime I see bug reports and I'm like... why are you doing this in the first place
But PHP has a semantics problem so eh
 
JRL
in that case i was accidentally cloning it, lol
i had a config object that auto-cloned on get for any objects
 
Oh I mean, I don't blame you, I'm blaming the language and the fact it's so scuffed
 
JRL
put the db conn into it forgetting that
 
I'm not looking forward to when I decide to tackle the "multiplication is assumed to be commutative" thing again and needing to argue with Dmitry
 
JRL
lol
im pretty done having any math arguments with internals/voters
 
10:34 PM
you tell me
 
JRL
voters don't want PHP to be good at math
fine
i won't try
the math/code is hard enough, not going to deal with people who don't understand the math arguing about it
 
Like I don't get Dmitry sometimes, he spends so much time writing a JIT compiler, he's know in the process of creating a new IR, but doesn't want to support useful math cases ... that's the thing a JIT is the best for ;-;
 
Until it supports inlining, I don't care one iota about its performance.
 
JRL
some of the commutativity assumptions in PHP are... surprising, i'll say
 
That sounds like an "Optimizer" problem not a JIT, but yeah we should be trying to work more on "Opcache/Optimizer working with multiple files/linker" than yet another jit
 
JRL
10:37 PM
all comparisons in PHP are evaluated left to right... except >, which is evaluated right to left
because the AST is reordered into <
 
@JRL Some behaviour in PHP is surprising FTFY
 
@Girgias Any optimizer, native code or not, needs to support inlining, or it's never going to be good.
 
Offset access is inconsistent between containers
 
JRL
so for some reason if you had this code: $obj1->executeFirst() > $obj2->executeSecond(), i'm fairly certain the methods would execute in the opposite order
 
@LeviMorrison Oh I agree, and we should be spending time on that, I'm too dumb for that tho :D
 
JRL
10:40 PM
actually, i can test that
 
I don't understand computers :D
 
I think I could do it, but only if it was my job. No way could I contribute that as a volunteer.
 
But, I think PHP would be easier to optimize if there weren't so many god damn inconsistencies
 
Yes, exactly. Like $foo["1234"] becoming $foo[1234]... but only sometimes.
Although that one is a problem in the optimizer specifically ^_^
 
I mean that one is... at least consistent in that if $v = (string)(int) then it gets converted to int
Actually... no
Because null
The only 2 places where null gets converted to a string if the value is of type string|int are array keys and exit() AFAIK
 
JRL
10:44 PM
okay, so at least the method execution that i outlined is not right to left
i think those resolve before it reorders
that's heartening at least
 
@Dharman Sorry?
 
@Derick I was refering to this
 
Oh. Yeah. I don't know the code. I don't know how their plugins work. I know nothing about it :-)
Also, it's late again now.
 
10:54 PM
Yeah, no rush.
but I am just curious how to push things forward
can I review the changes somehow?
can we test it? does PHP even have a test env or is it all prod?
 
haha
tbh, I don't know... but I think it's mostly yolo
What does need updating? You said PHP?
what is it on now?
 
yes, PHP and dokuwiki
PHP is on 7.0
 
yes, that does need updating
does the latest dokuwiki work on 8.2?
got to run - find me tomorrow morning after 10?
 
not sure about 8.2
I am at work during the day
> Dokuwiki is compatible with PHP 8.0 and 8.1.
 
 
1 hour later…

« first day (4499 days earlier)      last day (438 days later) »