« first day (4352 days earlier)      last day (596 days later) » 

2:53 AM
hello...
if you guys don't mind, please help me out in this url: stackoverflow.com/questions/73716670/…
 
JRL
though i feel for your plight, i wouldn't want to or be able to help with specifics of wordpress' monstrosity of an application unfortunately
but devs rarely get to choose their frameworks or tools, so i hope someone else can
 
Yes.. thanks for your understanding. I tried and such.. but no luck to solve the problem
if someone understand what I stuck, please let me know.
 
JRL
youre not grouping by category
that's the best i can offer
it's sorting and ordering correctly
it's probably the line about the category that's the problem
 
so, I need to grouping by category first?
 
JRL
most likely?
it's what i would try
or i would rewrite the $previous_cat and $unique_cat stuff into something... better
something that doesn't try to process the data and display the data in the same loop most likely
especially if you need to do grouping after querying
 
3:02 AM
But, how about the relationship university_major? Actually, I have a link that told me they solve the problem like mine: support.advancedcustomfields.com/forums/topic/…
But, I try it out, query all of the major
not the selected one
I want to try again.. maybe I have something missing..
um... just in case.. if someone kind enough to help, I want to share my created plugin..
here you go..
sorry if my code a bit messy..
 
JRL
why not put it on github or something? google drive seems a bit... sketchy
 
I don't know how to use github. I'm sorry..
Actually I want to learn github, so maybe I can learn how to update the plugin
But, I'm swear that file is safe...
i'm using node.js
 
JRL
er, this is a PHP room, not node.js
 
um.. i mean, i'm using php too.. but have javascript file too..
the problem one is in single-university.php
wordpress is php based actually.. so, if I want to pass value into javascript, I need to use wp_localize_script();
using javascript to form validate and pagination...
 
to be specific, you should narrow your problem down to a simple section of code
 
3:19 AM
um.. for now my code like this:

$university_majors = get_field('university_majors');
$previous_category = '';

foreach($university_majors as $university_major){
$categories = get_the_terms($university_major->ID, 'major_categories');
$c_terms = array();

foreach($categories as $term){
$c_terms[] = $term->name;
}
$unique_cat = array_unique($c_terms);

?>

<?php if($previous_category !== $unique_cat[0]) { ?><strong><?php $previous_category = $unique_cat[0]; echo $unique_cat[0]; ?></strong><?php } ?>
 
JRL
yes, we know, it's in your link
 
right now, I'm trying again using this code: https://support.advancedcustomfields.com/forums/topic/duplicate-taxonomy-with-reverse-relationship/#post-30741

I will work to it..
Thank you in advance, developers..
actually, in office the IT team only myself.. So, I don't know where to discuss..
so please take it easy on me..
 
3:39 AM
if I loop the categories first.. I think that is wrong.. because um.. the result is query all of the posts, not the relationship selected one..

$tax_terms = get_terms('major_categories','hide_empty=0');

if($tax_terms){
foreach($tax_terms as $tax_term){
$query = new WP_QUERY(array(
'post_type' => 'majors',
'major_categories' => $tax_term->slug,
'post_status' => 'publish',
'post_per_page' => -1,
'caller_get_posts' => 1
));

if($query->have_posts()){
echo $tax_term->name;
echo '<br />';
}

}
}
 
4:07 AM
can I ask? what $panel that Laurel here write?
https://wordpress.stackexchange.com/questions/291976/acf-relationship-group-posts-by-parent-category-term-then-child
 
4:40 AM
a little more push... please help me.. here is the update code:
$university_majors = get_field('university_majors');
$post_type = 'majors';
$the_terms = get_terms(array(
'taxonomy' => 'major_categories',
'hide_empty' => false,
'parent' => 0
));

foreach($the_terms as $the_term){
$my_posts = new WP_QUERY(array(
'post_type' => $post_type,
'post_per_page' => -1,
'post__in' => $university_majors,
'tax_query' => array(
array(
'taxonomy' => 'major_categories',
'field' => 'slug',
'terms' => $the_term->slug
)
)
));

$ids = array();

if($my_posts->have_posts()){
while($my_posts->have_posts()){
I change university_majors relationship into post_id
I mean return format post ID
 
 
2 hours later…
6:47 AM
@Hendra if you know git, GitHub is pretty easy to learn
@Hendra understanding how to use one of the many code-hosting platforms that are based on git is highly recommended as a dev skill
 
Hello @Tiffany, teach me how.. I want to know too..
 
Show me a business that uses Google drive as a host for their code, and I'll show you a business that's managed poorly
Note: Google is also an important skill. Looking up "GitHub tutorials" yields several results
 
@IluTov More important: you have a working heart :-)
 
Unfortunately, snark and links are all I'm able to help with presently as I'm either tired or too busy. Sometimes both.
 
can i using github for update custom plugins?
what difference between gitlab i wonder
actually, I'm already fixed my code
$university_majors = get_field('university_majors');
$post_type = 'majors';
$the_terms = get_terms(array(
'taxonomy' => 'major_categories',
'hide_empty' => false,
'parent' => 0
));

foreach($the_terms as $the_term){
$my_posts = new WP_QUERY(array(
'post_type' => $post_type,
'post_per_page' => -1,
'post__in' => $university_majors,
'tax_query' => array(
array(
'taxonomy' => 'major_categories',
'field' => 'slug',
'terms' => $the_term->slug
)
)
));

if($my_posts->have_posts()){
echo '<h2>'. $the_term->name . '</h2>';
here is the fixed code..
 
6:59 AM
Not much difference. GitHub is owned by Microsoft. I guess gitlab is more focused on private code hosting
 
7:34 AM
Hey guys, I've quick question
I'm making an xhr request with jquery ajax and I have a button to cancel the ongoing xhr request.
When I send xhr and then immediately click on cancel button to abort xhr request, it successfully aborts the request but the server still handles that aborted request.
Is this a bad thing which I can solve/overcome or is it supposed to work like that?
 
I'd ignore it. You can look at php.net/manual/en/function.ignore-user-abort but you'll quickly learn too many TCP details without finding a satisfying answer
 
ignore-user-abort is not something I would rely on.
 
Uhm, so what would you do in such case?
Or maybe it depends on the context of the transaction, like if's quite important and somebody makes that request accidentally or decided to take it back at the last second maybe we should implement that functionality.
What do you think?
 
7:50 AM
@MuhammedÇağlarTUFAN then send a separate cancel request or configure all possible cdns, proxies, firewalls; your webserver, application server and application perfectly. See geeksforgeeks.org/tcp-connection-termination
 
@Sjon I see, thanks for answers and your time
 
8:02 AM
@MuhammedÇağlarTUFAN you're welcome
 
8:35 AM
@RemiCollet I had already done github.com/derickr/vld/issues/79, but forgot to commit/push it.
 
8:48 AM
@Derick ty
 
I haven't added support for new or changed opcodes yet though
 
btw, extension state seems quite correct for 8.2 github.com/remicollet/remirepo/issues/206 :)
 
cmb
@RemiCollet I guess I'll have to release new dbase and xmlrpc packages.
Thanks for the xmlrpc fix!
 
well, it's only tests...
 
cmb
Yeah. I'll probably release dbase only; xmlrpc is better not used at all.
 
 
2 hours later…
10:39 AM
Small question: What does gettype($foo) return if $foo is a function?
 
@icecub why don't you try it?
 
@Danack Because I was reading the docs and it doesn't list anything for functions except maybe 'object' or 'resource'. Hence it got me confused
 
Ah alright, thanks :)
 
@RemiCollet ah yes a reminder that I should work on ext/csv
 
11:09 AM
Morning all
 
 
3 hours later…
2:32 PM
@TimWolla I realise the following is not entirely helpful but....I don't think just changing the warning level for unserialization problems is the right way to go. There is value in providing more information about why unserialization failed, either through an exception or possibly some other mechanism, but just fiddling with error levels doesn't sound great.
 
@Danack My proposal with the wrapper exception would allow for that.
Because the outer Exception is well-defined, the inner exception can be changed at-will to provide the necessary context.
 
And there needs to be a clear path of deprecating the current behaviour that people are alerted to (rather than having to read upgrade notes), so that they know they need to change their code from:
function getUserPreferences($data) {
  $user_preferences = @unserialize($data);
  if ($user_preferences === false) {
    $user_preferences = get_default_preferences();
  }
  return $user_preferences;
}
to something like:
function getUserPreferences($data) {
  try {
	return unserialize($data);
  }
  catch (UnserializationFailedException $ufe) {
	return get_default_preferences();
  }
}
but I'm not having great ideas of how that could be done 'nicely'.
 
The @ suppresses the deprecation. So really the only option is "oh, the Exception isn't caught and bubbles up into the global exception handler and thus makes Sentry noisy".
 
yeah. but that's a huge BC break that would only be found in production. That's 'ungood'.
/for the record, I have never used PHP's serialization/unserialization because of stuff like this....
 
@Danack It can be detected by static analysis. I'd say if the catch block is outside of the function that calls unserialize(), then you have no real chance of usefully handling the exception. So … write a PHP CodeSniffer sniff that detects calls to unserialize() without a catch block surrounding it.
 
2:41 PM
> It can be detected by ~~~static analysis~~~ people giving a crap if their program is correct or not.
 
I'm amused by your markdown fighting.
 
A well known and worthy foe.
Unfortunately, proposing BC breaks that are easily detectable by static analysis tools, but hard to detect otherwise, is a controversial topic in internals....
fu markdown
 
You technically don't even need a full-blown static analysis tool. Literally grep '@unserialize' finds the places where you attempt to suppress errors (i.e. where you care about unserialize possibly failing).
But again, the @ is already broken in the face of __unserialize().
And you already have incompatibilies like these: 3v4l.org/VArV6
 
Yeah, the current situation is also 'not good', but the upgrade path to a more sane unserialise function almost certainly needs to be less controversial.
 
Trying to replace a NodeJS server app with a PHP version of it. Just need a little bit of help with a small issue. In Node, you can do "var Selection = require('./selection');", where Selection is a class that can instantiated or used like a static class: Selection.property(). In PHP you can't instantiate a class and use it as a static class afaik. It's either one or the other. How would I solve this so I can call some of the classes methods without needing to instantiate it?
Sorry if that's poorly explained btw. I'm really not used to encountering issues like this. Normally I'd just instantiate it, but that requires parameter data that isn't available to me yet at that point
 
cmb
3:02 PM
There are no static classes in PHP. A class can have static members and non-static members.
 
@cmb Right.. Should've known that. Thanks a lot! That's all I needed
 
3:40 PM
@Danack Are you personally concerned about the "wrap exception", the "E_WARNING to Exception" or both?
They both technically change the behavior (literally every change changes the behavior as Girgias realized in SPL), but with regard to actual "breaks BC" I believe they are quite different.
 
@cmb Enum elements are technically static classes... but not possible to create in user land, not?
 
cmb
@Derick Enums may have non-static methods. And enum cases are objects, AFAIK.
 
3:56 PM
So not exactly static classes, but similar in that you cannot instantiate a new, unique instance at runtime.
 
Yes, my understanding is they are singleton objects.
 
Each enum case, yes.
MysqlDataType is by far the most complex enum class I've written.
Largely it's a container for static methods, but there's a few instance methods. I may be stretching what is appropriate for an enum, I haven't decided yet.
 
yeah... that's all I meant really :D
 
4:47 PM
y'all know about these XFAIL date/time tests? IT IS A MESS, and many of them are wrong
 
@cmb The RFC is fine, the tests are not
 
cmb
Aren't some of these tests referring to that RFC?
 
@cmb Sounds like fun to do, but is not going to be trivial
 
cmb
Dealing with all these "standards" wouldn't be fun for me.
 
4:56 PM
the exif function itself works pretty well already though
I bet "XMP" headers wasn't something that existed when these markers were added
 
cmb
@Derick if you ignore all the "subtle" issues like github.com/php/php-src/issues/9397
Also there is only support for JPEG and TIFF so far.
 
"but is not going to be trivial"
 
5:12 PM
There are 45 PHP Qs left in the current burnination if someone would care to take a look at them.
 
 
1 hour later…
JRL
6:39 PM
looks like you and I both had opinions to share on that "OOP" thread @Crell, lol
while PHP being shared-nothing means that persistent objects don't represent a benefit of OOP in PHP, nearly everything a website does is basically a state machine, and nearly every goal of having a website involves optimizing one of these state machines for certain kinds of transitions
and I'd argue that OOP is nearly the perfect way to represent state machines in PHP
so while PHP doesn't see the benefit of OOP that languages such as C# might, it also much more commonly is implementing business logic that is best represented by state machines with defined transitions, and thus OOP
 
 
1 hour later…
7:48 PM
See, I see PHP's use case as the quintessential functional use case. Message object comes in, message object goes out. No state is preserved. (Modulo DB, but in the program.)
 
JRL
on a single request sure, but PHP applications are almost always built with a multi-request expectation
no one builds a PHP website expecting every new request to be a new session, for instance
to be clear, i actually agree with you in large part
but applications involving any amount of business logic for the web almost always involve state machines even if the programmer doesn't know that or know what those are
the core framework handling fits functional programming very well IMO
 
 
2 hours later…
JRL
9:39 PM
does anyone who has been around here longer have a read on the broad opinions about controlled casting of objects to scalars? for instance, to bools.
 
9:53 PM
My experience with Rust suggests that PHP style casts, which must succeed, are a bad idea 👎
Conversions between types are often fallible. If you can have fallible and infallible conversions, then great, but if you can only have one, pick fallible.
 
JRL
@LeviMorrison can __toString() not throw an exception???
i wasn't aware of that, though i've never tried
oh, i think you're talking about the casts the engine normally does, which always result in the requested type
 
@JRL There was a time where that was illegal indeed.
 
JRL
@TimWolla how did that work? it un-exceptioned the code?
or was it compile time?
 
@JRL Fatal Error: 3v4l.org/8r8Zm.
 
JRL
huh. that looks like an error that occurs before code evaluation. i wonder how expensive that check was.
 
10:03 PM
No, that's just the engine not knowing where the error happens.
 
JRL
before the VM runs that is
 
@JRL Historically no, but yes, it can.
 
My understanding is that exceptions in __toString() would greatly mess up the internal state back then, that's why they were illegal and completely aborted execution right there.
 
JRL
i see
 
Still, I don't like exceptions for casting. It feels wrong. I guess I'd have to audit how many of my conversions I expect to fail.
 
10:05 PM
Because an implicit string cast can happen as part of almost every operation and code was not prepared for that to throw.
 
JRL
right. casts can happen in unexpected places that code is not prepared for exceptions.
hmmm. so @LeviMorrison, assuming that controlled casts could indeed be fallible, what would you intuitively expect the engine to do there? fall back to default casting behavior? throw an error? return the original type instead (in this case an object instance)?
 
return false, obviously ;-)
 
JRL
ha
and then for toBool(), to return null, obviously
just to make sure we build in something that is a proper WTF
 
@JRL No, also false. But you can use cast_error_last() to find out if it failed.
 
JRL
omg
clearly i have not trained the proper amoutn of evil instincts for engine work yet
 
10:49 PM
@JRL I don't think the engine should do anything, really. The user should be able control a failed conversion.
I guess to a degree, an exception would allow that.
For instance, just this week I was experimenting with using Rust and I needed to know if a zval contains an integer, so I did:
impl TryFrom<&mut zval> for zend_long {
    type Error = u8;

    fn try_from(zval: &mut zval) -> Result<Self, Self::Error> {
        let r#type = unsafe { zval.u1.v.type_ };
        if r#type as u32 == IS_LONG {
            Ok(unsafe { zval.value.lval })
        } else {
            Err(r#type)
        }
    }
}
This allows me to get a Result<zend_long, u8> where that u8 is the zval type in the case of a failed conversion, e.g. IS_NULL, IS_INT, IS_UNDEF, IS_ARRAY, etc.
 
JRL
wouldn't that control happen inside of the user-defined type conversion function though?
 
Every caller gets to decide what to do with the error, and of course there's short-hand notation to pass the buck to their caller for common cases. The main differences with exceptions are that 1) the user must do something meaning they can't implicitly ignore it, and 2) I don't have to deal with other exceptions which might have been thrown.
 
JRL
like if it gets through the conversion function, the only situation in which it should fail is if the type is uncastable period i would think
 
No, it's perfectly reasonable for the zval to not contain an int. It might have an object in there, or an array.
 
JRL
sure, but userland can't directly inspect or interact with the zval
 
10:59 PM
You are missing the point. I'm saying that conversions from A to B need to have some concept of "I failed, here's maybe some more info".
And, that's it's perfectly reasonable to have a failure, meaning it's not really an exceptional thing.
 
JRL
oh im all for that, i get it. im just wondering/thinking about what a good way to make that handleable in userland might be.
i guess there would have to be a whole model for casting handlers in PHP itself to really do that properly
 
What I'm saying, is that casts are not a good model.
 
JRL
ooohhhh... okay
so rather than making casts controllable, you'd prefer changing the model
 
Yeah, if a better one can be found for PHP.
 
JRL
that's a much heavier lift >_>
 
11:02 PM
We don't have generics nor a very powerful compile time phase so... it's tough.
 
JRL
i would think that would necessarily involve exposing parts of the zval structure directly to userland
but, that sort of language design is something im not super proficient at, so i also expect im wrong
 

« first day (4352 days earlier)      last day (596 days later) »