 Music's all upbeat today At least I've got the music working, which is making me very happy Welcome to the live stream folks Last week my music wasn't working it's working this week, so that makes me happy. I Don't know what it was. I just Disabled the two things and then re-enabled them and it's all working now. So that that makes me happy I'm just going to check on the meetup group see if anybody needs anything there I didn't do the best job of setting up my meetup this week, so I don't know how many Folks will be joining us today. Yeah, there's only 12 RSVPs. I Need to do a better job of setting up these new meetup events for future live streams But anyway Alright So last week I had some fun and games with XD bug if you remember and Then literally half an hour after I finished the stream. I Did what I always do which is go googling. I'm not googling go searching in the code for XD bug And what I found Was that there is a dot e and v file? Sitting in the roots of the project So that led me down to a path that I discovered that the WordPress Core code base is not using WP and V under the hood. I thought it was It's using Docker But it seems to be a custom Docker setup specific to the WordPress core code base, which is fine But it doesn't use WP and V and it doesn't use all the settings that WP and V enables so I did a little bit of googling and I discovered this ENV file and essentially there is the ENV configuration variable to enable XD bug so XD bug is installed on the On the Docker instance, I guess And it just needs to be set to true So the two ways you can do that is you can either set that variable there to true or you can set it as a local environment variable Now I Did have a you see if I can find it quickly I'm on a Mac so Create Environment variable And if this is the one I was looking at this one, I think Basically the way you do that is you can either put it in a bash profile file Or you can just run a command on the command line to set up the environment variable If you're on a Linux environment, you'll be able to do a similar thing If you're on a Windows environment, I haven't worked with Windows for a number of years But I'm sure it's possible to do it on Windows as well So if you go Windows environment variables Set a path in environment variable in Windows, it's probably going to be in the settings somewhere Advanced system settings environment variables button and you can set it there So that's how you would do it in Windows But essentially in a Mac, it's actually quite easy to do You go to the command line There's a command called env that you can run which will show you all your currently Your current local variables So I have things like home view home brew prefixes set up and paths and current users and all that kind of nonsense And then you can run a command called Like that called but a command like this we say export local phpd bike equals true So if I run that and run env again, then I will see there is the local phpxd bike equals true and Now when I npm install and build dev and all of that I'm gonna skip all of that. I've done that all before this session now if I run npm run env start inside of this environment, so let's go development projects Wordpress develop And let's run that command now it should all just work So I'm a little bit annoyed that took me like an hour to not get this right last week But that is the long and the short of it It's not it's not very well documented in the read me So if you do a search for Xt bug in the read me it doesn't exist there I Found it because I did a search in the code base So I did a whole search in the code base for Xt bug And that's where I stumbled across the env files. I Was hoping so in in Laravel you can set up a dot env dot local file And you can then override variables in that file and I was hoping I was able to do that But that doesn't seem to be possible So the way to do it is to set it up as an environment variable It looks like so this is something I might do if I have some spare time in the future if you're interested in all of this It looks like it's using a package called dot env which is a JavaScript package npm package which does support running Additional files, let me just find it here multiple environments, so you use the env file path when you run your Docker commands or something And so you'd be able to specify Dot env data today, maybe you can check if one exists or not and then run it So I'm hoping to maybe see if I can contribute that to the developer environment for For the core code base because that would be cool I think to be able to override some of those settings and then maybe even document some of those settings Because there's a whole bunch that's being set up here that you could you could make overriding But that's for another day. I'm not gonna worry about that today But essentially now that I've got my WordPress developer running if I go to my info file Which I've already got left over from last time you will see there is xdbug. Yay And it's all set up and configured and if I switch to let's go into the settings file for example and let's add a A Breakpoint somewhere And then I'm using the I've recently switched to Firefox for my browser out of interest so I'm using the Firefox debugging extension Should I see what it's called xdbug helper is what it's called for Firefox there's one for Chrome as well So I have that enabled currently And if I run this Everything should start working. Oh wait, I probably haven't I haven't enabled. No, I haven't start listening for PHP debug connections. I haven't set that up So let's do this again Yay debugging. I love it So this is the PHP storm debugging interface you have the debugger you have the console you have the output The debugger shows the files that are being loaded. It shows variables that have been set global variables You can add things to the watch list all that kind of thing. You can step through the code Very very helpful finding problems and figuring out problems So that's where we're going to continue today before we do that though I just wanted to mention that if you're not using PHP storm Which I know a lot of folks are doing it is possible to set up XD bug in VS code for example So there's a I'm going to do a search for a more of an open source C blog So dev community has one dev.to and essentially it is a Find it here. It is the PHP debug plugin for VS code You install that I'm actually going to spin up my VS code instance because I do use VS code and I'm Presenting videos and things and I'll show you So I do have that extension installed here. There's the PHP debug extension and then in the Settings, I think it is. No, it's not in the settings Settings.json, I think it is Have I got it here and I've configured this at some point No, maybe I'm wrong. Let me go back to the doc See what they say here. Oh, yes, you You create the launch.json file which I think it's added in your current project and then you say run and debug create the file You set up the various things Kind of looks like this. So this you'll see you'll recognize this, you know path mappings and all that kind of stuff This you will see in the WP and V file as well And then you run you click on start debugging And off you go and you can debug in VS code. So it is possible I am planning a lesson on doing this India VS code one day a video lesson for learn WordPress But it'll only be when I get run to the advanced developer learning pathways But there is some there is some good documentation out there on how to do it And it definitely is possible Okay So now that we have debugging enabled I Can start debugging this issue So I'm going to quickly log in here with my password manager. That's how I don't share any passwords with anybody And Here's the issue that I was working on Looks like nobody started working on it yet. So that's great And we determined that when we register the rest API in it permission call back Doing it wrong is not being fired properly, which is exactly what we discovered the very first session So I'm going to set up this this workspace again now and then I'm going to Dive into the register rest route function and see exactly what's going on So first step is to create the plug-in the test plug-in for us for ourselves So I'm just going to create that here in the In the local source. I can always delete the plug-in later. Oh wait, is that still my example plug-in? Hey, it's still there cool So let's Yeah, that's all still there. That's cool Let's make sure this all still works. So let's put some debugging in there. I'll set a breakpoint there And let's check That oh the other thing I probably need to do So I probably need to make sure I have the latest version of the code just in case something's changed this So I always do this before I Know I don't want my one. I want no, I don't want that one. I want my one And I want to sync the fork and then I'm going to just stop the local dev environment Do a pull, do a rebuild and start it up again And then Is it again build dev and then start in pym run build dev Pym run build Do sip of coffee while we wait move my camera slightly Down that up. No Better there we go I have a standing desk and When I stand up my camera is in a slightly different spot to when I sit down So I keep moving it around And I was standing this morning and so I moved it and I'm not happy about that. I need to find a better solution for this so I don't know maybe a new camera or A different camera, I don't know But it'll do for now All right, that's all done. So let's start the development environment Then let's check that the plug-in is installed Really wasn't expecting so many things to have to download now Anywho, so let's check that the plug-in is installed Oh Still got a break point. Okay, at least it's working and now it's indexing all the updates All right, come on. How long does it take to log into Dudley the admin by my local server This is one of the other reasons I don't like docker tends to be really slow on my machine Or any machine that I work on anyway, that's a problem for another day. Okay, let's check the plug-in Did you do? Yeah plug-in is there So now let's test out the let's just disable that plug-in for now. Actually, I'm gonna leave the break point I'm going that's not a break point Why did it do that way? Weird I'm going to stop listening for connections and I'm gonna just test this Rest API endpoint first So let's do this static pj Son Plug-in or items and I guess I think it was that yeah, there we go. That's my nice. I didn't agree. Cool Okay, so let's put a break point in there One thing about setting break points that I always get caught by is to never set them on your function declaration That that's why it's showing me a square set them on code that will be executed Not on a function declaration because it generally it doesn't break on the function declaration It sets it where the code is going to be executed So let's actually make this a little bit the Bose Didn't set that data very well correctly and then we can return data and then that will Give us two lines of code to at least work with All right, and then we can put the break point on the data and then we can and then at least it's something Okay, cool, let's see it's enabled debugging is that enabled Wonder whenever it can't be enabled on rest API endpoints. That's Largely annoying. That's frustrating Okay, doesn't matter Because we can tip that to break point here and then that's where the permission callback should be happening anyway So let's do that and then let's just refresh The home page, for example, oh wait, it might not trigger because it's on rest API in it I knew it on a rest API. Why is it not working? Okay, let me try this in Brave Maybe the Firefox extension is just being Pretty sure I got a working Yeah, we can enable debugging there. So let's do that. Oh I wonder if that was the problem Anyway, there we go. Okay. So that's all doing what we wanted to do. That's cool So let's run through that and then let's go back and enable the debug break point there Let's just test this in here. Ah, it did work. I think the extension is broken or something Okay, so we are here now and now we want to dive into this So we want to step into register rest route bomb. Okay, we're there. So now we're registering the rest route If empty, it's not empty. So it's not gonna Sorry about that Okay So right about where? Permission callback because we should start having trouble. So let's just step over. That's fine. That's all fine It's fine. Okay. So now we're getting here hmm Args is an empty array. See that there Args just has one One item. No, it's not empty. It does. Oh, no, it does have it looked like it was empty there So Args has let's add a watch to Args Okay, so now we're watching arguments, right, so let's watch that So Args has an array of one item that item is get that's the callback function And then we're gonna go by arg group So let's step Into that. Okay. So our group is there. It doesn't have the permissions callback. So we should get to that point Yeah Let's add our group to the watch There's our group there This this I don't know about you all if you can hear the music, but it's definitely getting me into a debugging mode It's very funky and upbeat Okay, let's step over that Okay, our group still doesn't have a permissions callback Okay, here we go If not is set our group permissions callback. So now we should if we step into this We should get to the doing it wrong. Okay, so that does seem to be working Function name So we should go into the doing it wrong now. So these are translation functions Because of all of this, so let's step over that Okay, do action doing it wrong and run function name register rest root version the rest API root definition For example plating all items is missing the required permissions callback For rest API's roots. So that's looks like it's doing so it's looking into the doing it wrong run With the function name the message in the version Hmm, okay. Oh So that's over that's just doing an action. So that's fine. Okay. So here we go if WD bug which is true and apply filters hook name doing it wrong trigger error Yeah, I thought is doing it wrong trigger. I wonder if that's the problem Let's see. Yeah jumped right over all of that Doing it wrong trigger error. I bet you that's the problem. Okay I'm going to set a break point there. So this is inside of the doing it wrong function Fulters whether to trigger an error for doing it wrong calls. Okay, so my guess is that this is Returning to the wrong trigger error. So look at that Fulters whether to trigger an error for doing it wrong calls. I wonder Let's see if something is hooked into that for the rest API that Registers the rest filters if it's serving race request deprecated report reporting So it looks like this is done on purpose possibly doing it wrong trigger error is set to false So theoretically if I remove that code right now It should trigger the error and it should log it to the log. I Wonder if it's being disabled because you don't want errors to show up When a rest API call is being made But then the scene I'm thinking and proper type rubber ducking to myself. You see If WD bug and that that returns false that was true that returns false. So it becomes false I'm gonna have to think about this for a bit Okay, so let's test out this theory. Let's see if we're righteous. So let us Comment out that code for now You could flood the logs well exactly That's what I'm saying. That's why whenever I see something like this. I don't assume that it's done incorrectly on purpose This is a very valid point. So if somebody's hitting a rest API end point I Want to say it's Andrew or Ashley contract which I think it's Ashley from Remembering correctly is mentioning that if somebody's hitting a rest API endpoint and you're triggering that that error then you're gonna have that issue The thing is though What should happen is when the route is registered and the permission callback is missing It should trigger the error. The problem is registering the route He's happening on the rest API in it So it's only going to be fired when the rest API request is made So you could again, it's gonna again call Andrew. Thank you. Andrew. Sorry I Connected so many people that I forget names. I do apologize So that's interesting It's definitely wrong that the permission not setting the permission callback doesn't register an error But I understand why This has been out. Let's test if this does work. This is if this does Hack fix the problem. I'm going to turn off debugging for a second and I'm gonna check that I've got Yes, if I want to sit I Think I've got debugging enabled So I think isn't the E and E file actually What's your I? Think it's enabled by default Yeah, debug is true debug log is true debug display is true. So it should show the error So let's turn that off and let's refresh the request. Okay, that timed out because I took too long Let's go back. Yeah, that's fine Okay, so it's definitely triggering the error now But as as Andrew points out that's gonna happen every time. So this is interesting We almost need to see Is serving rest request This sort of goes up higher up in the chain because Is serving rest request determines whether the wordpress is currently serving a request? This code is not serving the request But it sets up things to serve the request so The my problem here is none of these None of these will be firing them This is an interesting problem to have I Apologize if I pronounce your name your nickname incorrectly, but Salik. I think Salik who Nangara says hi, we're gonna find last week's recording. Yes, I can share that with you It is on the WordPress YouTube channel. So YouTube.com WordPress and If you go to the playlists and if you click on the Where is it now? It's online workshops playlist Think anyway, it'll be in it'll be in one of the recent videos. Here it is. I'll find this one So there's last week's video where I messed it all up completely Salia, sorry, I apologize. I terrible at pronouncing names. I can't paste it There's There's the link and then it's part of a playlist or at least it should be part of a playlist But I can't remember what their playlist is called now And if it's learn WordPress and see a word press Tutorial learn WordPress online workshop. There we go. So there's the full playlist and it's supposed to be the latest Video in that playlist There it is down the bottom there. Oh, that's part two part three is not there yet. Anyway, that's the link. You can find it there It'll be around there somewhere. I usually add it to the meetup group, but I think I forgot Apologize Okay, so this is interesting Because Looks like the documentation from reaches to this route. I find where I disabled that plug-in code. I can't find it now Though we either need to somehow wonder so the one way you could fix this and I've seen this kind of thing before As if we did something like this, I don't know if it's gonna work though Let's try so if we go in here now, I'm gonna have to find where that was happening now What you could do is you could In the in the register rest route down here where the callback story is happening There You could Do something Like this Third filter, I don't know if this will work though and you could return true and then After this is run You could Go back to return false. I don't know whether this is gonna work. This is possibly an option Let's see. Yeah, that does trigger the error It's not ideal that it's triggered this way But it will at least trigger the error if debug logging is on Hey, p. Georgie v So that's one option Don't know if that's a solid option, but it will fix that problem specifically you probably don't even need You probably should do this and if I like that solution though It feels dirty Okay so I think what I'm going to do here is I'm going to Comment on this ticket and then I'm going to share the ticket in the rest API channel And I'm going to ask folks for feedback because it really should trigger the error If the debug log is enabled It'll be interesting to figure out what happened before five point eight But if I had to guess it was probably the Check disabling those things so okay How to compile this note right, so I'm going to I'm gonna watch the stick it first of all so I get any updates to it and then I'm going to do the following In testing this ticket out today discovered why this is happening Let's go to this is with breast develop functions of PHP what I like to do when I log these things is I like to Include a link to the actual file so that folks can see what's what's going on As she says apply filter for the high callback essentially what we did. Yeah, that was my idea as well So I'm glad somebody agrees with me So if we go to W includes Functions, I love how old school this is all of these files just inside the includes folder And then we go looking for doing it wrong finding doing it wrongs Here we go So he's got down to inside of the doing it wrongs. I'm going to copy this permalink but Inside the doing it wrong function definition definition The following check is done before triggering the error and then what I like to do is I like to Link to the file. I don't know how URLs work in wiki formatting, but I think that's wrong. I Think is that work? She was marked down formatting Let's do links. How do we do links links links? There we go. Oh Doesn't seem to Okay, still works. Okay, so let's copy the code art Okay Yeah Yeah, yeah, yeah, okay then in the No, that's the one that I want I was on that I added I Want the first one? No last Don't run that don't run don't run there then in the W includes rest API file Please rest API. Okay don't include What is that on? 214 in the rest API default filters function in the rest API defaults is function this look in the rest API defaults is function this doing a trigger error hook as the turn false callback See and then it's linked to it And then we can say something like this is probably to prevent either displaying any errors or Overloading the log files if some third party or bot were to spam any rest API request on a word site because the register rest route Because the register rest route function should Only be called And a quote should only be used after used after the rest API and it hook this means possibly any Get wrong function calls Any doing it wrong calls in the context of a rest API request Will not be run however as Okay V okay V points out this is not ideal when Registering a rest route as it means a developer could in advertently register a public route Without specifying a permissions Callback I do try to be as verbose as possible When I am Posting my findings Then I'm going to say one way this could be fixed is to Hey, this could be fixed is to add the following Just before from call related to the Mission callback check here is to so probably needs to be set back to turn through I think Okay, in testing out the six days ago. This is happening inside the Doing it wrong function definition the following check is done before triggering the error To do if the rest API in the rest API default function This doing it wrong Hook has the return false callback line to it This is ready to prevent either displaying Either this is probably to prevent either displaying any errors or overlaying log files This is to prevent either if some third party or part or to spam any rest API because Because the register rest route function Should only be used after Before the only be used after The rest API hook this means possibly any Doing a drone calls in the context of reserve request will not be run. This means any other possibly that's basically what's happening However, as every points out, this is not ideal when registering a rest route Does it means a developer could inadvertently register a public route without specifying over missions callback? One way this could be fixed is to add a code below just before The doing it wrong call Related to the missions callback here that will today return true. It also probably needs to be set back to return false Don't false. Oh, yeah, I saw that. Yeah, remove the before text. I saw that Andrew Return false afterwards. Okay, and I'll read through it again You're testing this to get out today. I just got us happening inside the doing the wrong function definition The following check is done before triggering the error In the rest API default for the functions this doing a drone trigger error hook has the return false callback applied to it They just make sure these work Yeah, this is probably to prevent either displaying any errors or overloading the log files If some third party or part which is spam any rest API question, which was site Because the register rest route function should only be used after though. Why didn't that one work? Many be used after a product is also using the wrong ticks Go Good, this means anything a drone calls in the context of reserve request rest will not be run with any of the common However, as I could point out, this is not ideal when registering a rest routers It means a developer could inversely register public route without specifying a permissions callback One way this could be fixed is to add the code below just before the doing it wrong call related to the permissions callback check here It probably also needs to be set back to return false The other way to do it would be to require debug log to be said to true not debug That would just spam the log files She's not the end of the world Don't know I'm gonna leave that for now. Probably need to do it. Okay, so I'm gonna leave that for now I'm going to Met the changes So there's the note and then I'm going to share this in the rest API channel and Ask folks to comment So I'm not going to change this to general if you remember the very first session we spoke about this Suggested changing this to general. It looks like it is kind of related to the rest API. So I'm gonna leave it in rest API for now Core rest API channel and I'm going to high folks and looks at the the the comment that I was leaving there last week slowly high folks. I was Testing this issue today From what I can see the problem is related To disabling Any doing it wrong functions in the scope of a rest API request which makes sense however as The original as the OP points out It's not ideal when registering a rest route I would love to get I would appreciate Any feedback on my suggested fix here Suggestion fix just did fix here Or any other Alternative suggestions To implement a fix And I'm always super polite. Thanks a lot. So folks was testing this a shot today when I can see the problem is Related to disabling any doing it wrong functions in the scope of a rest API request, which makes sense However, as the OP points out, it's not ideal when registering a rest route. So that's not ideal I would appreciate any feedback on my suggested fix here or any other alternative suggestions to implement a fix You might have That's where I'm going to leave it All right So we figured out why it's happening we figured out that there's a reason that it's happening And we've left some notes That's where I'm going to leave it for today I Could go off and look for other issues now. That's definitely a possibility My brain is full right now around this issue So I'm going to leave it there. I'm going to see if I get any feedback between now and next week If I don't get any feedback to now next week, I'm probably going to just move on and Find something else But sometimes this is a lot of what I should probably I should probably reset some things. Yeah I should probably not leave all this code where I had it So let's just make sure that's all fine didn't make any changes. Oh, this was my example code that I can see like that Said things didn't make any changes in settings Or was I saying I've forgotten Yes, if if I don't get any feedback by next week, I will probably just move on from this issue leave for another week If I still don't get any feedback, I might start pinging some folks I know that there's WordCamp Asia coming up so folks might be busy there. That's why I'll leave it for two weeks generally it's recommended to To leave comments open for about two weeks because You know folks busy folks are working whatever the case may be but if if If I don't get a response, then I'll probably start pinging some people that I know that are working on the rest API Personally so there is Timothy Jacobs Ryan McHugh Rachel Baker Okay, I'm white and Jonathan Harris or Johnny Harris I'll probably start pinging them and just say hey if you got a moment might check this out. Let me know what you think That's usually what I do I have met a number of these folks in person so it's a little bit easier to ping them directly It's not always something that everybody can do but I'll probably leave it for a couple of weeks first before I do that But sometimes that is what is involved in testing an issue. Sometimes you don't find it easy fix or an easy solution That's why I haven't submitted a patch for this one yet I Want to see what folks come back with But yes, that's why I'm going to call it today. Thank you all for joining me. That was quite fun I enjoyed that we actually did something today If by next week, I don't have where we next week next week is the 21st of February No, we're campages in March. What am I talking about? If by next week, we don't have a solution for this one I'm going to go see if I can find another issue to work on we'll debug that we'll see what we can figure out I'll try and look for one that's a little bit easier to solve Maybe a good first issue. Maybe not rest API related. Maybe something else just to find something. It's a bit easier to work on Well, the easy ones do get picked up pretty quickly because they can get fixed pretty quickly so that's where we'll continue next week and Then the week after that so I did say that these live streams will be mostly related to Contributing to WordPress But WordPress 6.5 is coming soon It'll be released on March the 26th A Rarer to do today. I can't find the person lucky for now the release candidate will be soon So it's beta one this week, which means beta three will be in about two three weeks time Let's see if we can find really schedule WordPress 6.5 release Here we go. No, that's what I'm looking for. This is the same post. I was just looking at Here we go, it's a point five develop and cycle Here we go, so beta so next week beta two will be out and Then the following week beta three will be out and Beta three is usually around the time I start testing the new release to see what's new what's coming so you see beta three comes out in 27th So the 28th of February I think what I will probably do is a dive into The developer features coming to WordPress and 6.5. So that'll be the plan for two weeks time so next week we'll carry on with Checking if there's some feedback on this issue and maybe looking for another small issue We can work on and then the following week 28th of February will do a live stream on WordPress 6.5 And then depending on how much time there is for the for that one Maybe the following week will do another live stream about 6.5 changes because there's a lot coming this interactivity API. There's all kinds of stuff So we'll do some testing we'll do some checking out a new things so that'll be the plan for sort of the next few weeks Okay Awesome. Thank you all for joining me. I hope that this was in some way enlightening and that you learned something As always if you have any questions around any of these sessions, you're welcome to connect with me in the making WordPress Slack You can find me. My name is just Jonathan. There I am So you can find me there. You can message me anytime All of the live streams are on the WordPress YouTube channel So go look for them there And if you're interested in all these things, I'll see you all again next week. Okay Bye bye