Debug v23

This commit is contained in:
Laurent Destailleur 2026-02-17 16:59:07 +01:00
parent 753d89d4ca
commit 9ff8eb695e
3 changed files with 18 additions and 9 deletions

View file

@ -1341,6 +1341,8 @@ function unActivateModule($value, $requiredby = 1, $options = '')
{
global $db;
dol_syslog("unActivateModule value=".$value, LOG_INFO);
// Check parameters
if (empty($value)) {
return 'ErrorBadParameter';
@ -1368,6 +1370,7 @@ function unActivateModule($value, $requiredby = 1, $options = '')
$objMod = new $modName($db);
'@phan-var-force DolibarrModules $objMod';
/** @var DolibarrModules $objMod */
$result = $objMod->remove($options);
if ($result <= 0) {
$ret = $objMod->error;

View file

@ -253,7 +253,7 @@ class modBlockedLog extends DolibarrModules
* The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @param string $options Options when enabling module ('', 'noboxes', 'forcedisable')
* @return int 1 if OK, 0 if KO
*/
public function remove($options = '')
@ -265,6 +265,8 @@ class modBlockedLog extends DolibarrModules
// If already used, we add an entry to show we enable module
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
dol_syslog("modBlockedLog::remove option=".$options, LOG_DEBUG);
$object = new stdClass();
$object->id = 1;
$object->element = 'module';
@ -283,7 +285,7 @@ class modBlockedLog extends DolibarrModules
if ($b->alreadyUsed(1)) {
// Unalterable log was already used.
if (!$b->canBeDisabled()) {
if ($options != 'forcedisable' && !$b->canBeDisabled()) {
// Case we refuse to disable it
global $langs;
$this->error = $langs->trans('DisablingBlockedLogIsNotallowedOnceUsedExceptOnFullreset', $langs->transnoentitiesnoconv('BlockedLog'));

View file

@ -91,19 +91,23 @@ class NumberingModulesTest extends CommonClassTest
print __METHOD__." result3=".$result."\n";
$this->assertEquals(1, $result3, 'Test that the validation of an invoice with the forced ref '.$newref.' is ok: '.$localobject->error); // counter must start to 1
// Force enable of BlockedLog (not possible from application, but required to allow the test with sample data))
activateModule('modBlockedLog', 1, 1);
if (constant("CERTIF_LNE")) {
// If we are a not qualified certified version, we can add this use case test.
$result = $localobject->is_erasable();
print __METHOD__." is_erasable=".$result."\n";
$this->assertEquals(-7, $result, 'Test for is_erasable, 1st invoice without other invoice'); // Can be deleted
// Force enable of BlockedLog (required to allow this use case)
activateModule('modBlockedLog', 1, 1);
$result = $localobject->is_erasable();
print __METHOD__." is_erasable=".$result."\n";
$this->assertEquals(-7, $result, 'Test for is_erasable, once module blockedlog is on, 1st invoice without other invoice'); // Can be deleted
}
// Disable module BlockedLog (not possible from application, but required to allow the test with sample data))
unActivateModule('modBlockedLog');
unActivateModule('modBlockedLog', 1, 'forcedisable');
$result = $localobject->is_erasable();
print __METHOD__." is_erasable=".$result."\n";
$this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, 1st invoice without other invoice'); // Can be deleted
$this->assertGreaterThanOrEqual(1, $result, 'Test for is_erasable, once module blockedlog is off, 1st invoice without other invoice'); // Can be deleted
// We emulate print on invoice 3 times
$localobject->pos_print_counter = 3;