New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.13.1 (and earlier): PUM_Telemetry triggers PHP warnings in (CLI) cron #919
Comments
|
@lkraav strange, I've used cron recently and didn't see these. Not sure why they would be empty but I think some simple sanity checks there would be in order. |
🤷♂️ This is on production server, so all config screens have been visited over time, for sure - if whatever has needed initialization. I've sometimes also seen mistakes where new data objects storage routines only trigger on plugin activation, but not regular updates. |
|
@lkraav well either way simple fixes I believe |
|
@lkraav @danieliser I looked into this a bit. When I wrote the telemetry class, I thought our For example, we added the new Haven't figured out the other issue yet relating to the cookies foreach as I am not sure why the |
Since the opening sound setting was only recently introduced, some popups can exist that do not have that setting yet resulting in undefined index notices here. Issue #919
|
@lkraav @danieliser I installed a version of PM that is 3 years old (1.5.8) and created a popup and then switched to the recent version and fired the Telemetry method. I did get a similar notice on the @lkraav Can you confirm that some of the popups on the site were created at least more than 2 years ago? I'll go ahead and wrap the conditions and cookies in conditionals to test for that key too. |
|
@fpcorso since your pulling it all from settings (I think), just run $settings through So this would essentially prefill missing values at the start of the process and you can then safely expect those values to exist. |
Yep, can confirm. |
|
@danieliser Ah! There is actually already a better method for this. In our meta box, we use this to get settings with defaults which uses our
I should be able to use that line instead of my current one to resolve all of these. I'll test it. |
|
@fpcorso As long as it uses something existing it should work fine. That said the |
|
Copying my comments from Slack: Odd, I tried both Interesting....stepping through the debugger now and the defaults() method returns an array that doesn't have triggers, cookies, or conditions as keys so doing any parsing off that won't work then. @danieliser Whoa, the defaults() method only returns the defaults for checkbox types? https://github.com/PopupMaker/Popup-Maker/blob/master/classes/Admin/Popups.php#L1025 That defaults() method is what we use both creating the settings on the frontend and for the settings in the popup editor. I just checked in both places and can confirm the conditions key in my test popup are missing in both of those places too. |
|
@fpcorso - Hmm, I do believe the JS form API for popup settings though pulls default values directly from field declarations as each field has a Also not 100% sure always filling keys with defaults is wise:
Parsing for missing args at the time of usage is probably more preferable for a few reasons imho, primarily being that developers looking at code don't have to dig into other files/methods to find what is in the $settings array, they can see what they should expect right in the parse_args call, along with defaults if null is not sufficient. Looks like it was last tweaked 3 years ago. Would have to look at more of the commits around that time to get more context: c786730 But we can try patching it, just not sure what fallout there would be this far down the road, nor am I sure we would re-utilize much of this functionality post rewrite. |
|
@danieliser The JS popup settings uses So, even on the frontend, the keys are still missing. So, to resolve this, we have a few options:
|
|
@fpcorso per slack I think simplest is remove the if statement as it seems like a leftover. |
|
@lkraav This has been fixed in a recent commit in |
Describe the bug
Periodically cron spams us:
Site information
Popup Maker version: 1.13.1
WordPress version: 5.6
PHP version: 7.4
Expected behavior
Telemetry class should improve cron compatibility.
Current behavior
Probably some variables are not prepared for cron context.
Steps to reproduce
wp --quiet cron event run --due-nowErrors
See bug description.
Additional context
Tracebacks
The text was updated successfully, but these errors were encountered: