Page 1 of 1

MAMS SetUserPropertyFull

Posted: Mon May 03, 2021 4:25 am
by rotezecke
I just rolled back from FEU 3.2.2 on a CMSMS 2.2.15 to MAMS 1.0. on PHP7.4

I have one frontend form where a member of an FEU user group could add properties to another FEU user group and instantly fill that property with an empty value for ALL users of that group.
I managed to fix the "AddGroupPropertyRelation()" method (which has an additional argument in MAMS vs FEU3)

Code: Select all

//... i tested that my fieldname $newfieldname is unique and that $prompt is not empty
$attribs = 'a:0:{}';
$adding = $mod->AddPropertyDefn($newfieldname,$prompt,0,10,10,$attribs,false);
//the above adds a text field property with length of 10; i want to eventually store dates there, but not right now.
$relation = $mod->AddGroupPropertyRelation(1, $newfieldname, $sort_key, -1, 4);
//now that property is added to my group, id 1; there's some logic to find the $sort_key, not shown here, as that works
//So far so good. But I cannot then fill that property with an empty value,
//i confirmed that the $user_ids array holds ~ 30 uids.
foreach($user_ids as $uid)
{
  $mod->SetUserPropertyFull($newfieldname, '', $uid) ;
}
i also tried setting '0' or even '1' as value. There is no error in PHP or CMSMS logs. the property appears to be fully functional, as I can edit it in MAMS backend or via changesettings frontend (if it wasnt for the readonly I enforced). But, the method GetUserProperties($uid) does not know about the existence of this property until it appears in the module_mams_properties table. The database field can be Null and from looking and comparing source code, i cannot see why this should not work anymore. it did work in FEU3. Any ideas?


----------------------------------------------

Cms Version: 2.2.15

Installed Modules:

CGExtensions: 1.65.2
CGSimpleSmarty: 2.2.1
CGSmartImage: 1.22.7
CMSContentManager: 1.1.9
CMSMSExt: 1.0.1
CMSMailer: 6.2.14
Captcha: 1.0
DesignManager: 1.1.9
FileManager: 1.6.12
FormBuilder: 1.1.1
JM_Forum: 1.1.rc.2
JQueryTools: 1.4.2
LISE: 1.4.2
LISEaccommodationdb: 1.4.2
LISEcgblog: 1.4.2
LISEinstallersdb: 1.4.2
MAMS: 1.0
MAMSDirectory: 1.0.b.2
ModuleManager: 2.1.8
Navigator: 1.0.9
News: 2.51.11
RPCTools: 1.0.b.2
Search: 1.52
SmartyExt: 1.0


Config Information:

php_memory_limit:
max_upload_size: 64000000
url_rewriting: mod_rewrite
page_extension: .html
query_var: page
auto_alias_content: true
locale:
set_names: true
timezone: Australia/Brisbane
permissive_smarty: true


Php Information:

phpversion: 7.4.16
md5_function: On (True)
json_function: On (True)
gd_version: 2
tempnam_function: On (True)
magic_quotes_runtime: Off (False)
E_ALL: 30711
E_STRICT: 0
E_DEPRECATED: 8192
test_file_timedifference: No time difference found
test_db_timedifference: No time difference found
create_dir_and_file: 1
memory_limit: 384M
max_execution_time: 90
register_globals: Off (False)
output_buffering: 4096
disable_functions:
open_basedir:
test_remote_url: Success
file_uploads: On (True)
post_max_size: 64M
upload_max_filesize: 64M
session_save_path: /tmp (0700)
session_use_cookies: On (True)
xml_function: On (True)
xmlreader_class: On (True)
check_ini_set: On (True)
curl: On


Performance Information:

allow_browser_cache: Off (False)
browser_cache_expiry: 0
php_opcache: On (True)
smarty_cache: Off (False)
smarty_compilecheck: On (True)
auto_clear_cache_age: On (True)

Server Information:

Server Software: Apache
Server Api: litespeed
Server Os: Linux 2.6.32-954.3.5.lve1.4.78.el6.x86_64 On x86_64
Server Db Type: MySQL (mysqli)
Server Db Version: 10.2.37
Server Db Grants: Found a "GRANT ALL" statement that appears to be suitable


Permission Information:

tmp: /home/x/public_html/tmp (0755)
tmp_cache: /home/x/public_html/tmp/cache (0755)
templates_c: /home/x/public_html/tmp/templates_c (0755)
modules: /home/x/public_html/modules (0755)
uploads: /home/x/public_html/uploads (0755)
File Creation Mask (umask): /home/x/public_html/tmp/cache (0755)
config_file: 0444

----------------------------------------------

Re: MAMS SetUserPropertyFull

Posted: Mon May 03, 2021 4:36 am
by rotezecke
I think the difference is in the GetPropertyDefns() method.

The SetUserPropertyFull() checks the existance of the property via GetPropertyDefns(). In FEU3, that check is a database query. In MAMS, it checks the cache. As I have just created that property, it is not cached, and then fails.

Can I add this property to cache, or reload the cache in the middle of my script?

Re: MAMS SetUserPropertyFull

Posted: Mon May 03, 2021 4:45 am
by rotezecke
found it. i added

Code: Select all

$mod->ClearPropertyCache();
$mod->_cache_propertydefns();
and now it creates the empty fields.