Skip to content
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

“Deprecated: ltrim()…” warnings on manage subscription user page #806

Open
pol76 opened this issue Oct 9, 2024 · 7 comments
Open

Comments

@pol76
Copy link
Contributor

pol76 commented Oct 9, 2024

Testing on new WordPress 6.6.2 install with PHP 8.2. No other plugins activated. When I purchase a subscription from a test user with no administrative privileges and then go to the Manage Subscription page, e.g. /gp-subscriptions/?subscription=2 , there are multiple PHP deprecated warnings regarding passing null to ltrim or preg_replace:

It seems to be coming from WPInv_Subscriptions_List_Table::generate_item_markup on line 394 in admin/class-wpinv-subscriptions-list-table.php which tries to get the link to the edit page for an item or invoice and then passes that to esc_url without checking if it’s null.

see https://wordpress.org/support/topic/deprecated-ltrim-warnings-on-manage-subscription-user-page/

@kprajapatii
Copy link
Collaborator

This has been fixed and pushed already.

@aayla-secura
Copy link

aayla-secura commented Oct 10, 2024

As per my comment in the Wordpress support topic (apologies for doubling up, I'll be using Github only for bug reports from now on):

I applied the patch and it did not fix the issue for me. I even wiped my test installation and started clean, installed the plugin, applied the patch, verified the file change. It's still showing those same warnings.

@kprajapatii
Copy link
Collaborator

@aayla-secura Are you using only GetPaid plugin or using GeoDirectory Pricing Manager plugin? Please update the plugin Pricing Manager if you are using it.

If you still see issue then open a topic at https://wpgeodirectory.com/support/ so we can follow up quickly.

Thanks,
Kiran

@aayla-secura
Copy link

@kprajapatii No, I'm not using this plugin. The warnings are coming from passing the result of get_edit_post_link to esc_url without checking if it's null (which it would be null if the user is not an administrator). It happens in two separate places (possibly more, but what I'm seeing on the Subscriptions page is coming from two places).

Here's a patch that fixes it. I tested it now:

diff -U0 -r invoicing/includes/admin/class-wpinv-subscriptions-list-table.php invoicing.edit/includes/admin/class-wpinv-subscriptions-list-table.php
--- invoicing/includes/admin/class-wpinv-subscriptions-list-table.php   2024-08-08 15:00:40.000000000 +0300
+++ invoicing.edit/includes/admin/class-wpinv-subscriptions-list-table.php      2024-10-10 16:04:10.528597776 +0300
@@ -394 +394 @@
-                       $link = esc_url( $link );
+                       $link = $link === null ? '' : esc_url( $link );
diff -U0 -r invoicing/includes/admin/subscriptions.php invoicing.edit/includes/admin/subscriptions.php
--- invoicing/includes/admin/subscriptions.php  2024-06-11 12:17:00.000000000 +0300
+++ invoicing.edit/includes/admin/subscriptions.php     2024-10-10 16:13:07.441204004 +0300
@@ -604 +603,0 @@
-                                                                               $link    = esc_url( get_edit_post_link( $payment->get_id() ) );
@@ -608 +607,3 @@
-                                                                               }
+                                        } else {
+                                                                               $link    = esc_url( get_edit_post_link( $payment->get_id() ) );
+                                        }

I can create a pull request if you prefer.

@kprajapatii
Copy link
Collaborator

@aayla-secura On my test site no longer getting this error, so wanted to know in which causes the error occurred.

I can update patch from my side.

Thanks,

@aayla-secura
Copy link

@kprajapatii Strange, though it's possible I'm seeing it because I've enabled displaying of warnings and errors in the test install. 🤷

@kprajapatii
Copy link
Collaborator

Pushed f5fd14c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants