BiologicalRecordsCentre / SPRING

Repository for tracking issues for the SPRING (EU Pollinator Monitoring) project
GNU General Public License v3.0
0 stars 0 forks source link

UKPoMS/SPRING/FIT Count PHP 8.1 investigation notes #98

Closed andrewvanbreda closed 1 year ago

andrewvanbreda commented 1 year ago

On request from Biren, notes regarding investigation into the compatibility of the UKPoMS/SPRING/FIT Count with PHP 8.1 (which is required for continued compatibility with the Pantheon hosting system)

For simplicity this issue covers all 3 sites.

andrewvanbreda commented 1 year ago

@BirenRathod I have tested the sites a fair bit (as much as I can on my own without be going overboard about it). I have also checked the existing logs. I am not see deprecation warnings. The only thing I saw of concern (not related to PHP 8.1) was again there seems to be a lot of "page not found" logging errors. On UKPoMS this seems to be particular extreme with many per minute. I assume these are bots trying their luck?

Anyway, that is just some info for you to do as you wish.

So my conclusions are:

  1. Although I have not detected any practical deprecation warnings, I notice that there are two SPRING specific files with strcasecmp() and json_decode() in them (as noted in this issue https://github.com/Indicia-Team/warehouse/issues/431) I will need to update these. If you could let me know when you need this done by it would be helpful.

  2. The other question is I am assuming someone else will be updating the rest of iForm etc? for the deprecation problems. Has someone else been assigned to do that task? We need to make sure that old forms in the repository are also updated if they are in use. For instance, SPRING forms inherit the original EBMS forms (which Gary may or may not be using anymore for EBMS, think there are some new versions), so need to make sure someone is updating all the active forms on projects.

BirenRathod commented 1 year ago

@andrewvanbreda thanks for looking into this.

Those 'page not found' logging error are not perticularly to worry about as you mentioned they are from bot.

  1. will this be a porblem for current PHP if you make those changes for php 8.1?
  2. As long as, I'm aware @johnvanbreda has already done some changes on iform. Not sure about EBMs at present but will get confirmation from @DavidRoy about it.
BirenRathod commented 1 year ago

@andrewvanbreda Below is the branch created by @johnvanbreda. https://github.com/Indicia-Team/warehouse/tree/feature-php81

andrewvanbreda commented 1 year ago

@BirenRathod This is a good question, and must be considered as I make the alterations. If I break the current PHP, it means I have done something wrong. Thanks for thought, as may have forgotten that (although I would of tested it).

johnvanbreda commented 1 year ago

The above feature branch is already merged into develop and can be deleted. I've made changes where I've seen problems, but have not yet been able to do a thorough test of everything on PHP 8.1.

andrewvanbreda commented 1 year ago

@johnvanbreda @BirenRathod OK, well let me know if you need me to change anything that isn't specific code for one of my projects (i.e. stuff that is in Pantheon but not the main indicia-team github). Also let me know if you need me to do any specific testing beyond my sites

andrewvanbreda commented 1 year ago

Hi @BirenRathod I tested those elements of code, and think most are ok as they won't pass in null params. I have made a few small changes which are now deployed to the project specific EU PoMS prebuilt forms which are now live. So what will need to happen is once all those iForm changes are done, I will update the sites' indicia_features/iform modules and give them a test.

andrewvanbreda commented 1 year ago

@BirenRathod Have just deployed the required changes to SPRING live (in aaddition to FIT COunt, Plant Portal, NPMS already being live). So just need to deploy UKPoMS, then do EBMS/UKBMS which is more work as noted.

andrewvanbreda commented 1 year ago

Hi @johnvanbreda I have a problem with my PHP 8.1 testing on UKPoMS. Well ,the problem is actually with calling a javascript function using indiciaFns.

The page is this (not sure you can see this?) https://avb-php-ceh-ukpoms.pantheonsite.io/fit-count-target-flower-checking

In an an extensions js file (poms_extensions.js) there is a function that looks a bit like this

indiciaFns.submit_corrected_sample_media_name = function(sample_id, corrected_species_sample_attr_val_id) { etc etc }

It is called from submit link on a grid row using action list item calling javascript in this line indiciaFns.submit_corrected_sample_media_name({id},{corrected_species_sav_id});

However clicking this there is no reaction at all, logging seems to show it isn't even being called.

The site is a Pantheon multi-dev environment, using PHP 8.1 and has had an iForm/client_helpers/media/indicia features update. Any thoughts what might be happening here?

johnvanbreda commented 1 year ago

@andrewvanbreda I can't see that page - can you sort out a login for me to try please?

johnvanbreda commented 1 year ago

The Submit button does call indiciaFns.submit_corrected_sample_media_name when I try it on Windows using Edge or macOS Ventura Safari. I can put a breakpoint inside the function which does get triggered. There is a request to ajaxproxy which fails though with the following error:

{error:"iform_ajaxproxy Error: Current defined methods are: sample, location, loc-sample, loc-smp-occ, smp-occ, '.
            'media, occurrence, occ-comment, smp-comment, determination, notification, user-trust, person_attribute_value"}

This seems like it just needs a tweak to add support for the sample_attribute_values table to the Ajax_proxy module's controller, not that there is a PHP version problem.

andrewvanbreda commented 1 year ago

Hi @johnvanbreda Thanks for the info, I understand what has happened now. I had a not to commit that, and didn't round to it. I can fix this.

andrewvanbreda commented 1 year ago

@BirenRathod SRPING is now ready to merge apart from some kind of permission problem.

There is an error appearing in the logs sometimes Warning: mkdir(): Permission denied in iform_load_helpers() (line 1115 of /code/web/modules/custom/iform/iform.module)

The line of code site in this part of the code

// interim_image_folder if (!isset(helper_base::$interim_image_folder)) { // Always create path into public files folder. $filePath = hostsite_get_public_file_path(); helper_base::$interim_image_folder = "$filePath/indicia/upload/"; if (!is_dir(helper_base::$interim_image_folder)) { mkdir(helper_base::$interim_image_folder, 0777, true); } }

The site is here https://avb-php-eu-pollinator.pantheonsite.io/

The problem was occurring on this page https://avb-php-eu-pollinator.pantheonsite.io/species-data-entry (although this page is designed to be used by species experts, with existing samples which limits being able to fiddle with it)

I need to know what is causing this so I can determine if it needs fixing before merge to live, or whether it is a problem that won't occur on live.

johnvanbreda commented 1 year ago

It looks like the PHP process doesn't have permissions to create a folder to place temporarily uploaded photos into. @andrewvanbreda you could try using FTP to manually create a folder in files/indicia called upload and see if that helps?

BirenRathod commented 1 year ago

@johnvanbreda & @andrewvanbreda I just checked the folder exists.

andrewvanbreda commented 1 year ago

@johnvanbreda @BirenRathod OK thanks for thoughts. I realised last night, because my test environment was recreated, it doesn't have latest iForm on it. So let me try that first, and then I will see if I can resolve this.

andrewvanbreda commented 1 year ago

@johnvanbreda @BirenRathod I ended up in a rush yesterday after pollinaotr monitoring went down to pu the PHP 8 chnages live. Then I noticed something, I wasn't getting this problem on live. I also was working on UKPoMS this morning and got same problem, but noticed this.

  1. It didn't actually affect image upload.
  2. The messages seemed to vanish forever once I had done my first image upload.

I think also the message wasn't displaying under PHP 7, although I am less sure of that.

Anyway, am not going to do anymore to resolve this unless you think could be code problem, as the problem vanished.

DavidRoy commented 1 year ago

@andrewvanbreda - shall we close this issue and open any specific ones for PHP8 glitches?