PHP Fatal error: Call to a member function setDateRemindedBefore() on null

Hello,

I am receiving the following error messages when trying to reset the expiry date in the subscription manager.

[05-Nov-2019 10:16:33 America/New_York] PHP Fatal error: Call to a member function setDateRemindedAfter() on null in /home/radjr1/domains/wmpllc.org/public_html/ojs/classes/subscription/SubscriptionAction.inc.php on line 406
[05-Nov-2019 10:17:01 America/New_York] PHP Fatal error: Call to a member function setDateRemindedBefore() on null in /home/radjr1/domains/wmpllc.org/public_html/ojs/classes/subscription/SubscriptionAction.inc.php on line 403

Don’t know if it is tied to these errors in the log file.

[03-Nov-2019 09:55:42 America/New_York] NOTICE: Use of undefined constant matches - assumed ‘matches’ (/home/radjr1/domains/wmpllc.org/public_html/ojs/lib/pkp/classes/core/PKPString.inc.php:723)
[03-Nov-2019 09:55:46 America/New_York] NOTICE: Use of undefined constant matches - assumed ‘matches’ (/home/radjr1/domains/wmpllc.org/public_html/ojs/lib/pkp/classes/core/PKPString.inc.php:723)

Any thoughts? I am really lost on this! Thanks.

The “constant matches” error can be fixed with this change:

This is one of a few fixes missed in the the OJS 2.4.8-5 release:

This is probably unrelated to the “PHP Fatal” error. There it appears that the subscription id passed in on the URL is not found correctly:

The code appears to be returning successfully in this function:

But failing when getSubscription() is called:

This method is implemented in the subclass. Is it an institutional subscription, or an individual subscription?

Thank you. It was an institutional sub. I just checked and it works with individuals.

I will see how to make the changes listed below. Thank you. I really thought I was losing my marbles…

Are their other “fixes” that were missed on 2.4.8.5 that i should incorporate?

Again many thanks!

Richard A. DeVito Jr.

In addition to the changes to lib/pkp which I mentioned earlier, there are also some accepted changes to stable-2_4_8 which did not make it into 2.4.8-5:

The most plausible cause for the institutional subscription failure will be data (not) pulled by this SQL:

If you have SQL access to the database, the next step would be to identify why this query is returning no results when using the subscription id on the URL (placed where the ? is).

Can you share the records from subscriptions and institutional_subscriptions for that subscription_id, and verify that the matching subscription_types type_id is flagged as institutional?

INSERT INTO subscriptions (subscription_id, journal_id, user_id, type_id, date_start, date_end, status, membership, reference_number, notes, date_reminded_before, date_reminded_after) VALUES
(409, 1, 2174, 67, ‘2017-01-01’, ‘2019-01-01 23:59:59’, 1, NULL, ‘OM2092’, NULL, ‘2018-12-19 10:30:53’, ‘2019-01-09 10:34:42’);

INSERT INTO institutional_subscriptions (institutional_subscription_id, subscription_id, institution_name, mailing_address, domain) VALUES
(91, 409, ‘Columbia University’, ‘Health Science Lib\r\nPeriodicals\r\n701 W 168th St\r\nNew York, NY 10032’, ‘’);

INSERT INTO subscription_types (type_id, journal_id, cost, currency_code_alpha, non_expiring, duration, format, institutional, membership, disable_public_display, seq) VALUES
(67, 1, 1207, ‘USD’, 0, 12, 17, 1, 0, 0, 22);

Seems it is flagged as institutional. Thanks. I don’t get how to submit the appropriate SQL for per your request. Sorry.

Yes, the data seems sound. Do you know if this fails for all institutional subscriptions, or just for this one?

Yes, all. Thanks!

Richard A. DeVito Jr.
Publisher
Weston Medical Publishing, LLC, 470 Boston Post Road, Suite 301, Weston, MA 02493 USA
radjr@pnpco.com - 781-899-2702 ext. 107 - 781-899-4900 fax
Join us at the 2020 International Conference on Opioids, May 30-June 1, 2020
www.opioidconference.org http://www.opioidconference.org/

I’m not sure when, if ever, this would have worked. The template needs the $subscription to introspect whether it is an individual or institutional subscription:

But the form doesn’t set that variable for the template:

So, the institutional form will always create the reset links as if they were individual subscriptions. (If you hover over the link it will say “…/subscriptionManager/resetDateReminded/individual/…”.)

Perhaps this worked prior to this change in 2014?

If you copy and paste the links, replacing “individual” with “institutional”, they should work for your purposes. I’d need to think for a bit to come up with a lightweight fix for the actual code.

I think this change will fix it consistently with low risk of unintended consequences:

diff --git a/classes/subscription/form/SubscriptionForm.inc.php b/classes/subscription/form/SubscriptionForm.inc.php
index f958601..d202f89 100644
--- a/classes/subscription/form/SubscriptionForm.inc.php
+++ b/classes/subscription/form/SubscriptionForm.inc.php
@@ -86,6 +86,7 @@ class SubscriptionForm extends Form {

                if (isset($this->subscription)) {
                        $subscriptionId = $this->subscription->getId();
+                       $templateMgr->assign('subscription', $this->subscription);
                        $templateMgr->assign('dateRemindedBefore', $this->subscription->getDateRemindedBefore());
                        $templateMgr->assign('dateRemindedAfter', $this->subscription->getDateRemindedAfter());
                } else {

How did this work in our 2.4.8.4 install that was updated from an original 2.4.2 install? Also how do I make the change below? I don’t get the diff? Thanks.

Confirmed that this works where I replace institutional in place of individual

https://www.wmpllc.org/ojs/index.php/jom/subscriptionManager/editSubscription/institutional/409

I don’t see a “resetDateReminded” option in OJS 2.4.2-0, and OJS 2.4.8-4 looks like it would suffer from the same bug. Are you sure you’ve used this specific feature of the form in those versions?

The diff essentially adds just line with the + in front of it:

$templateMgr->assign('subscription', $this->subscription);

It should go within the condition:

if (isset($this->subscription)) {

Boss Lady (my wife) says that she has used if for a long time and it always set it to the current date in the date field to the left.

IT seems that all it is supposed to do is to clear the date that is to the left. My wife swears that it would put the current date into the field to the left but I think it should clear so that the scheduled task will send the emails. Please confirm. P.S. the change above works! Thanks Clinton!!!

I’m not immediately familiar with the functionality here, but it seems reasonable that removing the reminder date would trigger a new reminder, and the code is structured to remove the reminder date when the link is clicked.

Thanks. What is interesting is that this probably never worked and/or just reset the data to the current date in the system. Is there an SQA team that validates functionality for each release against a known specification? (I had a team of SQA engineers who would validate our software and hardware in a previous life.) Maybe this is already done via alpha and beta sites?

We have some automated test coverage for each build, and in 3.x we have begun implementing formal code freezes with functional and translation reviews. The coverage of subscription functionality in 2.x would be weaker than average, as many of the core development partners (for example, my home of the University of Pittsburgh) are more invested in open access, so there are fewer alpha/beta partners for subscriptions. Additional eyes would be welcome if you have some suggestions for QA volunteers.