Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YF7.0.2] module import issues #70

Closed
davide-alghi opened this issue Dec 9, 2024 · 2 comments
Closed

[YF7.0.2] module import issues #70

davide-alghi opened this issue Dec 9, 2024 · 2 comments

Comments

@davide-alghi
Copy link

Try to export a custom module (just the one attached, My Symple Module) from a YF7.0.2 instance and import to another YF7.0.2 instance ...
it issues a system error
Schermata del 2024-12-09 15-33-27

My Symple Module
MySimpleModule.zip

system.log

2024-12-09 15:30:40.0343 [error][] - SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (dev_yf_7_0_XX.a_yf_module_reference, CONSTRAINT fk_module_relations_entityname FOREIGN KEY (module_id) REFERENCES vtiger_entityname (tabid) ON DELETE CASCADE)
The SQL being executed was: INSERT INTO a_yf_module_reference (module_id, ref_table, ref_column, sort, is_custom_field_table) VALUES (142, 'vtiger_crmentity', 'crmid', 1, 0)
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (dev_yf_7_0_XX.a_yf_module_reference, CONSTRAINT fk_module_relations_entityname FOREIGN KEY (module_id) REFERENCES vtiger_entityname (tabid) ON DELETE CASCADE) in /var/www/html/development/yf_7.0/XX/vendor/yetiforce/yii2/db/Command.php:1302
Stack trace:
#0 /var/www/html/development/yf_7.0/XX/vendor/yetiforce/yii2/db/Command.php(1302): PDOStatement->execute()
#1 /var/www/html/development/yf_7.0/XX/vendor/yetiforce/yii2/db/Command.php(1102): yii\db\Command->internalExecute()
#2 /var/www/html/development/yf_7.0/XX/vtlib/Vtiger/PackageImport.php(729): yii\db\Command->execute()
#3 /var/www/html/development/yf_7.0/XX/vtlib/Vtiger/PackageImport.php(653): vtlib\PackageImport->importEntityModuleReferences()
#4 /var/www/html/development/yf_7.0/XX/vtlib/Vtiger/PackageImport.php(606): vtlib\PackageImport->importModule()
#5 /var/www/html/development/yf_7.0/XX/modules/Settings/ModuleManager/views/ModuleImport.php(151): vtlib\PackageImport->import()
#6 /var/www/html/development/yf_7.0/XX/app/Controller/ExposeMethod.php(68): Settings_ModuleManager_ModuleImport_View->importUserModuleStep3()
#7 /var/www/html/development/yf_7.0/XX/modules/Settings/ModuleManager/views/ModuleImport.php(45): Settings_ModuleManager_ModuleImport_View->invokeExposedMethod()
#8 /var/www/html/development/yf_7.0/XX/include/main/WebUI.php(161): Settings_ModuleManager_ModuleImport_View->process()
#9 /var/www/html/development/yf_7.0/XX/index.php(26): Vtiger_WebUI->process()
#10 /var/www/html/development/yf_7.0/XX/public_html/index.php(13): require('...')
#11 {main}

Next yii\db\IntegrityException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (dev_yf_7_0_XX.a_yf_module_reference, CONSTRAINT fk_module_relations_entityname FOREIGN KEY (module_id) REFERENCES vtiger_entityname (tabid) ON DELETE CASCADE)
The SQL being executed was: INSERT INTO a_yf_module_reference (module_id, ref_table, ref_column, sort, is_custom_field_table) VALUES (142, 'vtiger_crmentity', 'crmid', 1, 0) in /var/www/html/development/yf_7.0/XX/vendor/yetiforce/yii2/db/Schema.php:676
Stack trace:
#0 /var/www/html/development/yf_7.0/XX/vendor/yetiforce/yii2/db/Command.php(1307): yii\db\Schema->convertException()
#1 /var/www/html/development/yf_7.0/XX/vendor/yetiforce/yii2/db/Command.php(1102): yii\db\Command->internalExecute()
#2 /var/www/html/development/yf_7.0/XX/vtlib/Vtiger/PackageImport.php(729): yii\db\Command->execute()
#3 /var/www/html/development/yf_7.0/XX/vtlib/Vtiger/PackageImport.php(653): vtlib\PackageImport->importEntityModuleReferences()
#4 /var/www/html/development/yf_7.0/XX/vtlib/Vtiger/PackageImport.php(606): vtlib\PackageImport->importModule()
#5 /var/www/html/development/yf_7.0/XX/modules/Settings/ModuleManager/views/ModuleImport.php(151): vtlib\PackageImport->import()
#6 /var/www/html/development/yf_7.0/XX/app/Controller/ExposeMethod.php(68): Settings_ModuleManager_ModuleImport_View->importUserModuleStep3()
#7 /var/www/html/development/yf_7.0/XX/modules/Settings/ModuleManager/views/ModuleImport.php(45): Settings_ModuleManager_ModuleImport_View->invokeExposedMethod()
#8 /var/www/html/development/yf_7.0/XX/include/main/WebUI.php(161): Settings_ModuleManager_ModuleImport_View->process()
#9 /var/www/html/development/yf_7.0/XX/index.php(26): Vtiger_WebUI->process()
#10 /var/www/html/development/yf_7.0/XX/public_html/index.php(13): require('...')
#11 {main}
Additional Information:
Array
(
[0] => 23000
[1] => 1452
[2] => Cannot add or update a child row: a foreign key constraint fails (dev_yf_7_0_XX.a_yf_module_reference, CONSTRAINT fk_module_relations_entityname FOREIGN KEY (module_id) REFERENCES vtiger_entityname (tabid) ON DELETE CASCADE)
)

2024-12-09 15:30:39.8643 [info][[application]] -
$_POST = ['_csrf'=>'sid:616e0f5f6d79d2b41416019c4582e94ee20a4de6,1733754638','module'=>'ModuleManager','parent'=>'Settings','view'=>'ModuleImport','module_import_file'=>'usermodule_1733754638.zip','module_import_type'=>'inventory','module_import_name'=>'MySimpleModule','mode'=>'importUserModuleStep3']
$_COOKIE = ['YTSID'=>'r208qoro6fdeo4s1gt3i5gcnqf']
$_SESSION = ['CSP_TOKEN'=>'421c509b6363096555ff5afe2c0d1bf8c8a832959692ca2bc0705a34241fea64','last_activity'=>1733754639.864678,'fingerprint'=>'2750bc42-702e-4cbe-bae5-798f171389e1','user_agent'=>'Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0','UserAuthMethod'=>'PASSWORD','app_unique_key'=>'K7XD5HxtmEc5RvmuBmiv2d0tyuFVnsgcXTMEilfZ','user_name'=>'davide','full_user_name'=>'Alghi Davide','authenticated_user_id'=>1,'DashBoard'=>['Home'=>['LastDashBoardId'=>1]],'language'=>'en-US']
_HEADERS = ['Host'=>'www.yeticrmxx70.com','Te'=>'trailers','Priority'=>'u=0, i','Sec-Fetch-User'=>'?1','Sec-Fetch-Site'=>'same-origin','Sec-Fetch-Mode'=>'navigate','Sec-Fetch-Dest'=>'document','Upgrade-Insecure-Requests'=>'1','Cookie'=>'YTSID=r208qoro6fdeo4s1gt3i5gcnqf','Origin'=>'null','Content-Length'=>'255','Content-Type'=>'application/x-www-form-urlencoded','Accept-Encoding'=>'gzip, deflate, br, zstd','Accept-Language'=>'it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3','Accept'=>'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,/;q=0.8','User-Agent'=>'Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0','Authorization'=>'']
$stability = ['output_buffering'=>'1']
$security = ['disable_functions'=>'']
$libraries = ['pdo_sqlsrv'=>'LBL_NO','mongodb'=>'LBL_NO']
$performance = ['opcache.save_comments'=>'1']
$environment = ['open_basedir'=>false]
$functionalVerification = ['branding'=>'No']

@davide-alghi
Copy link
Author

davide-alghi commented Dec 9, 2024

Additionally, if I import an update package by Module Manager, the import process ends with an error

Schermata del 2024-12-09 20-53-53

this happens for both YF7.0.1 and YF7.0.2 (anyway the update goes well)
the same update package is imported correctly in YF7.0.0, without errors: this is a regression.

NB the importer is trying to delete the package zip file, which most likely has already been deleted

the system.log

2024-12-09 20:50:48.0252 [error][] - vtlib\Deprecated::checkFileAccessForDeletion(cache/usermodule_1733773846.zip) - Sorry! Attempt to access restricted file. realfilepath:
2024-12-09 20:50:48.0255 [error][] - Sorry! Attempt to access restricted file.
App\Exceptions\AppException: Sorry! Attempt to access restricted file. in vtlib/Vtiger/Deprecated.php:98
Stack trace:
#0 modules/Settings/ModuleManager/views/ModuleImport.php(159): vtlib\Deprecated::checkFileAccessForDeletion()
#1 app/Controller/ExposeMethod.php(68): Settings_ModuleManager_ModuleImport_View->importUserModuleStep3()
#2 modules/Settings/ModuleManager/views/ModuleImport.php(45): Settings_ModuleManager_ModuleImport_View->invokeExposedMethod()
#3 include/main/WebUI.php(161): Settings_ModuleManager_ModuleImport_View->process()
#4 index.php(26): Vtiger_WebUI->process()
#5 public_html/index.php(13): require('...')
#6 {main}
2024-12-09 20:50:47.9466 [info][[application]] -
$_POST = ['_csrf'=>'sid:7e902a1b1c5f70d1d3c2e3faf63fff6b97a37fe7,1733773846','module'=>'ModuleManager','parent'=>'Settings','view'=>'ModuleImport','module_import_file'=>'usermodule_1733773846.zip','module_import_type'=>'update','module_import_name'=>'PAD Lineitem Fields','mode'=>'importUserModuleStep3']
$_COOKIE = ['YTSID'=>'oi6i2ejqegj1ldha4s91aakrlq']
$_SESSION = ['CSP_TOKEN'=>'63128ca026aea319939e32047a312fdf5b21e317b63d59b36bd1a01cb1d60879','last_activity'=>1733773847.946966,'fingerprint'=>'2750bc42-702e-4cbe-bae5-798f171389e1','user_agent'=>'Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0','UserAuthMethod'=>'PASSWORD','app_unique_key'=>'K7XD5HxtmEc5RvmuBmiv2d0tyuFVnsgcXTMEilfZ','user_name'=>'davide','full_user_name'=>'Alghi Davide','authenticated_user_id'=>1,'DashBoard'=>['Home'=>['LastDashBoardId'=>1]],'language'=>'en-US']
_HEADERS = ['Host'=>'www.yeticrmxx70.com','Te'=>'trailers','Priority'=>'u=0, i','Sec-Fetch-User'=>'?1','Sec-Fetch-Site'=>'same-origin','Sec-Fetch-Mode'=>'navigate','Sec-Fetch-Dest'=>'document','Upgrade-Insecure-Requests'=>'1','Cookie'=>'YTSID=oi6i2ejqegj1ldha4s91aakrlq','Origin'=>'null','Content-Length'=>'257','Content-Type'=>'application/x-www-form-urlencoded','Accept-Encoding'=>'gzip, deflate, br, zstd','Accept-Language'=>'it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3','Accept'=>'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,/;q=0.8','User-Agent'=>'Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0','Authorization'=>'']
$stability = ['output_buffering'=>'1']
$security = ['disable_functions'=>'']
$libraries = ['pdo_sqlsrv'=>'LBL_NO','mongodb'=>'LBL_NO']
$performance = ['opcache.save_comments'=>'1']
$environment = ['open_basedir'=>false]
$writableFilesAndFolders = ['cache/templates_c/'=>'LBL_NO']
$functionalVerification = ['branding'=>'No']
$headers = ['Header: content-security-policy'=>'default-src 'self' blob:; img-src 'self' data: https://api.yetiforce.eu *.tile.openstreetmap.org; font-src 'self' data:; script-src 'self' 'unsafe-eval' 'unsafe-inline' blob:; form-action 'self' https://www.paypal.com; frame-ancestors 'self'; frame-src 'self' mailto: tel:; style-src 'self' 'unsafe-inline'; connect-src 'self';']

@davide-alghi
Copy link
Author

I solved this problem by analyzing the update packages of YF7.0.1 and YF7.0.2.

I leave this information for any YetiForce developer who might be interested.

the init.php::postupdate() function is terminated with a return exit;
and in case you are updating via the Module Manager (no via CLI) there is a redirect
in other words the init.php::postupdate() function must terminate with

public function postupdate()
{
    ...
    ...
    $this->log(__METHOD__ . ' | ' . date('Y-m-d H:i:s') . ' | ' . round((microtime(true) - $start) / 60, 2) . ' min');
    if(PHP_SAPI !== 'cli') {
        header('location: index.php?parent=Settings&module=Updates&view=Index');
    }
     $this->log(__METHOD__ . ' | ' . date('Y-m-d H:i:s') . ' | ' . round((microtime(true) - $start) / 60, 2) . ' min');
     return exit;
}

just a note for @rskrzypczak
the return exit; in init.php::postupdate() function precludes the execution of the code in register_shutdown_function()

		register_shutdown_function(function () {
			try {
				\vtlib\Functions::recurseDelete('cache/templates_c');
			} catch (\Exception $e) {
				\App\Log::error($e->getMessage() . PHP_EOL . $e->__toString());
			}
		});

I close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant