Fatal error after update to 10.0.14

Post

Posted
Rating:
#4288 (In Topic #885)
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’

From v10.0.10

Fatal error: Call to undefined function cns_get_custom_fields_member() in /home3/joe2209/bosslife.org/sources_custom/symbols.php on line 2250

Here's the function relevant to line 2250 from symbols.php of version 10.0.14: (working file)

Code (PHP)

function ecv_CPF_VALUE($lang, $escaped, $param)
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        $_value = '';

        if (is_numeric($param[0])) {
            require_code('cns_members');
            $custom_fields = cns_get_all_custom_fields_match_member(isset($param[1]) ? intval($param[1]) : get_member());
            foreach ($custom_fields as $custom_field) {
                if ($custom_field['FIELD_ID'] == $param[0]) {
                    $_value = $custom_field['RAW'];
                }
            }
        } elseif ((substr($param[0], 0, 2) == 'm_') && (stripos($param[0], 'hash') === false) && (stripos($param[0], 'salt') === false)) {
            $_value = $GLOBALS['FORUM_DRIVER']->get_member_row_field(isset($param[1]) ? intval($param[1]) : get_member(), $param[0]);
        } else {
            if (preg_match('#^[a-z\_\d]*$#', $param[0]) != 0) {
                $_value = get_cms_cpf($param[0], isset($param[1]) ? intval($param[1]) : null);
            } else {
                require_code('cns_members');
                $cpf_id = find_cpf_field_id($param[0]);
                if (!is_null($cpf_id)) {
                    require_code('cns_members');
                    $custom_fields = cns_get_all_custom_fields_match_member(isset($param[1]) ? intval($param[1]) : get_member());
                    foreach ($custom_fields as $custom_field) {
                        if ($custom_field['FIELD_ID'] == strval($cpf_id)) {
                            $_value = $custom_field['RAW'];
                        }
                    }
                }
            }
        }

        if (!is_string($_value)) {
            $value = is_null($_value) ? '' : strval($_value);
        } else {
            $value = $_value;
        }
    }

    if ($escaped !== array()) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

Here's the function relevant to line 2250 from symbols.php of version 10.0.10 (non-working file):

Code (PHP)

function ecv_CPF_VALUE($lang, $escaped, $param)
{
    $value = '';
    if ($GLOBALS['XSS_DETECT']) {
        ocp_mark_as_escaped($value);
    }

    if (isset($param[0])) {
        $_value = '';

        if (is_numeric($param[0])) {
            require_code('cns_members');
            $fields = cns_get_custom_fields_member(isset($param[1]) ? intval($param[1]) : get_member());
            if (array_key_exists(intval($param[0]), $fields)) {
                $_value = $fields[intval($param[0])];
            }
        } elseif ((substr($param[0], 0, 2) == 'm_') && (stripos($param[0], 'hash') === false) && (stripos($param[0], 'salt') === false)) {
            $_value = $GLOBALS['FORUM_DRIVER']->get_member_row_field(isset($param[1]) ? intval($param[1]) : get_member(), $param[0]);
        } else {
            if (preg_match('#^[a-z\_\d]*$#', $param[0]) != 0) {
                $_value = get_cms_cpf($param[0], isset($param[1]) ? intval($param[1]) : null);
            } else {
                require_code('cns_members');
                $cpf_id = find_cpf_field_id($param[0]);
                if (!is_null($cpf_id)) {
                    $fields = cns_get_custom_fields_member(isset($param[1]) ? intval($param[1]) : get_member());
                    if (array_key_exists($cpf_id, $fields)) {
                        $_value = $fields[$cpf_id];
                    }
                }
            }
        }

        if (!is_string($_value)) {
            $value = is_null($_value) ? '' : strval($_value);
        } else {
            $value = $_value;
        }
    }

    if ($escaped !== array()) {
        apply_tempcode_escaping($escaped, $value);
    }
    return $value;
}

Last edit: by Joe

Online now: No Back to the top

Post

Posted
Rating:
#4289
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
On a side note, I'm not sure why it's different or even why I have a custom version; most likely to fix a bug or two that I reported recently.
Online now: No Back to the top

Post

Posted
Rating:
#4291
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Oh boy, it gets worse. Not sure I like upgrading anymore. :P

So I think the reason I had a custom symbols.php is because I actually added a symbol way back when, to check if a specific named cookie exists. Maybe a change made in v10.0.14's symbols.php was causing this issue. Anyways, I just copied over my custom symbol to the new symbols.php and this has fixed this error but it seems I have another:

3: TypeError: $(…).inputDate is not a function
https://bosslife.org/themes/start/templates_cached/EN/global_ssl.js?1523290836 line 742 > eval

This occurs when trying to edit my profile. If I dismiss the error and try to change a CPF value, the change is not saved.

This issue is also affecting fractional editable areas of my site (for editing these CPFs). I assume the reason why is related to this issue.

Last edit: by Joe

Online now: No Back to the top

Post

Posted
Rating:
#4292
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
UPDATE:

I think it's something to do with FORM_SCREEN_INPUT_DATE.tpl

I looked on Github and found that these lines were deleted:

(line 21) $('#{NAME;/}').inputDate({});
(line 22) $('#{NAME;/}_time').inputTime({});

And these were added in v10.0.14:
(line 21) if (!Modernizr.inputtypes.date) $('#{NAME;/}').inputDate({});
(line 22) if (!Modernizr.inputtypes.time) $('#{NAME;/}_time').inputTime({});

Upon inspection of my FORM_SCREEN_INPUT_DATE.tpl file, I noticed these changes were not made during my upgrade. I made the changes manually and now I'm getting this error when attempting to edit my profile:

4: SyntaxError: expected expression, got keyword 'if'
https://bosslife.org/themes/start/templates_cached/EN/global_ssl.js?1523311610


UPDATE 2:
I reverted FORM_SCREEN_INPUT_DATE.tpl to a backup I had of v10.0.10, which contained this:

{+START,SET,comment}
   Uncomment if you want to force jQuery-UI inputs even when there is native browser input support
   <span>// <![CDATA[
      add_event_listener_abstract(window,'load',function() {
         $('#{NAME;/}').inputDate({});
         $('#{NAME;/}_time').inputTime({});
      });
   //]]></span>
{+END}

This stopped the error from popping up, but I'm still having issues saving CPFs.


UPDATE 3:
Ok, this is weird… looking at the deletions and additions on GitHub for v10.0.14, I'm noticing that none of these changes were made to my installation. As far as I can tell, none of the files appear to have been modified by the upgrader. But this must not be true as the upgrade is what caused the issue, so something somewhere changed, I just don't know what. I'm totally confused as to what's going on. I've racked my brain on this one.

Last edit: by Joe

Online now: No Back to the top

Post

Posted
Rating:
#4293
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Hi Joe,

I'll tackle this in parts, as there's a lot here. So first let us talk about overrides…

Overriding is always a risk, and things get technical. Where possible we make it so that things can be done with either minimal overrides or hooks.

You likely don't know this yet: when you override a Composr include that just consists of functions, you can just declare the new function in the override, leaving out anything else. Composr automatically merges with the original.

Also it is possible to implement symbols as hooks. sources/hooks/systems/symbols.

Why did things break? We had to change the cns_get_custom_fields_member stuff a bit, I can't quite remember why though to be honest– there was something subtly wrong about how it was structured.

Last edit: by Chris Graham



Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#4294
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
A quick note about upgrading-

It may be wise to test an upgrade on a site where you have overrides, or where it's been a while since the last upgrade, on a clone of your live site. Then you can make sure things are going to go smoothly when you upgrade the real site.

There's a tutorial somewhere about clone sites.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#4295
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Upon inspection of my FORM_SCREEN_INPUT_DATE.tpl file, I noticed these changes were not made during my upgrade. I made the changes manually and now I'm getting this error when attempting to edit my profile:

These are coming in the next release. There's been some back-and-forth bugginess around date input I'm afraid.

4: SyntaxError: expected expression, got keyword 'if'

I think this may have been caused by an intra-release bug in cms_calendar.php, if you were using that module at the time and uploaded a change to it. It's weird your error message says global.js though, so maybe not - maybe some problem caused when uploading global.js only partially or it corrupting during upload. Anyway, you say it's gone, so I'll leave it there unless it comes back.

This stopped the error from popping up, but I'm still having issues saving CPFs.

This may actually be an unrelated bug affecting some users in the latest release. Try grabbing these files from github:
  • sources/forum/cns.php
  • sources/cns_topicview.php
  • sources/cns_members.php

Sorry for the inconvenience there. There was a lot of time between the last and most recent patch release, so while a lot was fixed, there were the couple of regressions we've discussed here (date input and CPF saving issues).


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#4296
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Ok, we're operational again. Thanks Chris!

These are coming in the next release. There's been some back-and-forth bugginess around date input I'm afraid.

So I assume the contents of FORM_SCREEN_INPUT_DATE.tpl should remain as:

{+START,SET,comment}
   Uncomment if you want to force jQuery-UI inputs even when there is native browser input support
   <span>// <![CDATA[
      add_event_listener_abstract(window,'load',function() {
         $('#{NAME;/}').inputDate({});
         $('#{NAME;/}_time').inputTime({});
      });
   //]]></span>
{+END}

…until the next release, correct?
Online now: No Back to the top

Post

Posted
Rating:
#4297
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
You could try the latest themes/default/templates/FORM_SCREEN_INPUT_DATE.tpl and themes/default/templates/FORM_SCREEN_INPUT_TIME.tpl again, they should work.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top
1 guest and 0 members have just viewed this.
Back to Top