From: Bako M. <mi...@ng...> - 2021-02-22 13:34:37
|
// apparently I'm off the list, resubscribed with mi...@ng... Hi guys! Have not seen much talk on this list, hopefully I am still on it. Hi Honza, Ariel, I hope you are doing well during these difficult times - Cc:-d this to you as well just in case. Tried to migrate AA site from php 5.5 to 7.2. Did svn update to the last revision and updated the database. I have encountered the new site module approach, did not understand how it works, how can you migrate sites using the "old way", and could not find any documentation about it. For the time being I had to stick to the old ways - start feeling like in some old, burned out gunman character from a western movie :-) - here is my experience, if anybody needs it: location: apc-aa/modules/site/sites file: Found that the ereg() function used here is out of php 7, found suggestion of using preg_match() instead. # previous php 5.5 version if( ereg( "^([a-zA-Z0-9_])([a-zA-Z0-9_-])([a-zA-Z0-9_-])([a-zA-Z0-9_-])([a-zA-Z0-9_-])([a-zA-Z_]+)([-]|[0-9]+)([a-zA-Z_-])([0-9]*)", $apc, $vars )) list($old_state,$old_w,$old_s,$old_f,$old_l,$old_a,$old_r,$old_p,$old_t,$old_x) = $vars; else list($old_w,$old_s,$old_f,$old_l,$old_a,$old_r,$old_p,$old_t) = array( 'i', '-', '-', 'r', 0, '-', '-', '-'); The problem is that preg_match() is creating two dimensional array, and the syntax is a bit different. Need to use differently the list function, 2 versions below: (need to be adapted to the state variable structure used) # ======================================================= # replacement for PHP 7+ # v. 1 if( preg_match( '"^([a-zA-Z0-9_])([a-zA-Z0-9_-])([a-zA-Z0-9_-])([a-zA-Z0-9_-])([a-zA-Z0-9_-])([a-zA-Z_-]+)([-]|[0-9]+)([a-zA-Z_-])([0-9]*)"', $apc, $vars, PREG_OFFSET_CAPTURE )) { list($old_state,$old_w,$old_s,$old_f,$old_l,$old_a,$old_r,$old_p,$old_t,$old_x) = $vars; $old_state = $vars[0][0]; $old_w = $vars[1][0]; $old_s = $vars[2][0]; $old_f = $vars[3][0]; $old_l = $vars[4][0]; $old_a = $vars[5][0]; $old_r = $vars[6][0]; $old_p = $vars[7][0]; $old_t = $vars[8][0]; $old_x = $vars[9][0]; } else list($old_w,$old_s,$old_f,$old_l,$old_a,$old_r,$old_p,$old_t) = array( 'i', '-', '-', 'r', 0, '-', '-', '-'); # ======================================================= # replacement for PHP 7+ # v. 2 if( preg_match( '"^([a-zA-Z0-9_])([a-zA-Z0-9_-])([a-zA-Z0-9_-])([a-zA-Z0-9_-])([a-zA-Z0-9_-])([a-zA-Z_-]+)([-]|[0-9]+)([a-zA-Z_-])([0-9]*)"', $apc, $vars, PREG_OFFSET_CAPTURE )) list( list($old_state, ),list($old_w, ),list($old_s, ),list($old_f, ),list($old_l, ),list($old_a, ),list($old_r, ),list($old_p, ),list($old_t, ),list($old_x, ) ) = $vars; else list($old_w,$old_s,$old_f,$old_l,$old_a,$old_r,$old_p,$old_t) = array( 'i', '-', '-', 'r', 0, '-', '-', '-'); # ======================================================= This second one looks more sophisticated & PHP like, however I feel like it is to complicated structure to be efficient, I don't know the inner workings of PHP, can not decide which one is faster on execution. Anyway probably there was some sick mind coming up with this syntax of the list function, to use blank space for parameters to skip (embedded list structure). Looks like broken code to me. I still prefer C as a programming language :-) . ------------------------------------------------------- the MLX / add / edit item form problem: I am using MLX for multiple languages. The "Edit <language>" tab works on existing items. However if I want to add another item on ther language, and select "Add <language>" tab, it is generating a blank Add item form of another slice, perhaps the first slice of the database. Also when I select the last button (abort or cancel, mine is in romanian) also jumps back to the other slice item list (not always though). If I coming out of the form with the "Update" (first) button, it behaves normally. Today just logged in again, fresh start, and went in, this time left the form normally with Cancel button. Strange. I noticed that the link ends in the & character when you hover above the Add <language> link - like some parameter is missing. Found that if I add module ID at the end, the Add form is generated but blank, the data from the corresponding item on another language is not copied, and language field is filled with random values, like Norwegian, Japanese, Russian, etc. which I never use. example: Original link: https://site.ro/aa/admin/itemedit.php3?encap=false&add=1&mlxl=HU&mlxid=4e5b4d4073eb2e9f937d5cf72934d819& Altered link generating the blank page: https://site.ro/aa/admin/itemedit.php3?encap=false&add=1&mlxl=HU&mlxid=4e5b4d4073eb2e9f937d5cf72934d819&module_id=fd49721e08b3ad1ffca8211b1dbdee1b After added new item - need to care about the language selection field, otherwise strange things are happening - things are back to normal, you can edit and save normally, MLX does its job and item is properly displayed in the site. This is my 2c. Have a nice day! Best, Misi Strawberrynet Romania |