Support ⇒ Modules & Blocks ⇒ Quoting eval statements in cpg_inst.php ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum IndexModules & Blocks

Quoting eval statements in cpg_inst.php Reply to topic


For some time now, in response to user requests, Pro_News can be installed under a different module name. (Eg. Articles - or a local language equivalent - which produces better looking LEO urls.)

I achieve this by making cpg_inst.php basically one big eval statement, eg:
$mod_dirname = basename(dirname(__FILE__));

eval("
		class $mod_dirname {
			var \$description;
			var \$radmin;
			var \$modname;
			var \$version;
			var \$author;
			var \$website;
			var \$dbtables;
		// class constructor
			function $mod_dirname() {


That has served me well for several years/releases. But as indicated by this code snippet, quote escaping is paramount, and tricky!

However I now need to issue a ALTER TABLE CHANGE request (to resize group access fields from tinyint to int so that group numbers > 127 can be supported).

The following works fine in Linux (XAMMP on my system) but fails in Windows (WAMP on my beta tester's Windows system):
					\$installer->add_query('CHANGE', 'pronews_sections', "'view view int(10) UNSIGNED NOT NULL default 0'");


Windows fails to pick up the default value, reporting:CMS Warning line 75: On /efadmin.php?op=modules&upgrade=158 While executing query "ALTER TABLE cpg_pronews_sections CHANGE view view int(10) NOT NULL DEFAULT ''" the following error occured: Invalid default value for 'view' In: C:\wamp\www\includes\classes\installer.php on line: 115

I've already tried:
"view view int(10) UNSIGNED NOT NULL default '0'"
"view view int(10) UNSIGNED NOT NULL default 0"
'view view int(10) NOT NULL default "0"'


Which all work in Linux, but fail the same in Windows. (Plus a whole slew of other sequences which fail in Linux too.)

Anybody have any ideas? Perhaps something that will work in Windows only, which I can select based on OS type?

I did check SQL-modes, but Windows had None and Linux only one relating to db engine. I can't think of anything else that might cause this differing behaviour.

TIA!

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


looking at "UNSIGNED" it's not there either.
Are you sure it's correct query?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial


It's the correct query - or queries - as each does the right thing to the db (on Linux).

I'm only having trouble with CHANGE, all other ALTER TABLE queries I've used are OK. But can't figure out an alternate way. MODIFY doesn't seem to be supported in v9 installer, but uses exact same syntax so will probably fail the same anyway.

But the php BBCode has done a number on them here. Sorry I didn't notice. I'll repeat using code BBCode.

\"'view view int(10) UNSIGNED NOT NULL default 0'\" \"view view int(10) UNSIGNED NOT NULL default '0'\" \"view view int(10) UNSIGNED NOT NULL default 0\" 'view view int(10) NOT NULL default \"0\"'
Each/any of the above (used singly) work fine in Linux/XAMPP but fail in Windows/WAMP with no value picked up for Default.

The last one doesn't have UNSIGNED because that syntax results in unsigned being missed in Linux - I was getting desperate, and could live with 'only' 1M groups. Wink

It seems like I need 3 levels of quotes to get through the eval process!

The defaults are essential as they set the default groups for View (in this case) plus Post, Administrate and Moderate (exactly as they would in Forums).

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4

All times are UTC


Jump to: