clean code (#38826)

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code: remove unnecessary ExtraFields instantiations

Remove 8 dead-code instantiations of ExtraFields across htdocs:
- modDav: full unused block (include, new ExtraFields, 5 commented examples)
- resource/agenda.php, public/project/index.php: variable never used
- public/project/suggestbooth.php, suggestconference.php: require_once + variable never used
- fourn/facture/agenda.php: first instantiation immediately overwritten before any use
- compta/facture/card-rec.php, fourn/facture/card-rec.php: $extralabels = new ExtraFields immediately overwritten by fetch_name_optionals_label() return value

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Frédéric FRANCE 2026-06-15 14:57:01 +02:00 committed by GitHub
parent 9cbb84c1ca
commit 354eadefa2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 4 additions and 25 deletions

View file

@ -1384,7 +1384,6 @@ if ($action == 'create') {
$draft = new Facture($db);
$draft->fetch(GETPOSTINT('facid'));
$extralabels = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($draft->table_element);
if ($draft->fetch_optionals() > 0) {
$sourceInvoice->array_options = array_merge($sourceInvoice->array_options, $draft->array_options);

View file

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2026 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -251,16 +252,6 @@ class modDav extends DolibarrModules
*/
public function init($options = '')
{
// Create extrafields
include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
//$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
//$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
//$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1 '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'dav@dav', '$conf->dav->enabled');
$sql = array();
return $this->_init($sql, $options);

View file

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
*
* This program is free software; you can redistribute it and/or modify
@ -83,7 +83,6 @@ if (!$sortorder) {
// Initialize a technical objects
$object = new FactureFournisseur($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = getMultidirTemp($object).'/massgeneration/'.$user->id;
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context

View file

@ -8,7 +8,7 @@
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
* Copyright (C) 2017-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2017-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2023-2024 Nick Fragoulis
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
*
@ -1028,7 +1028,6 @@ if ($action == 'create') {
$draft = new FactureFournisseur($db);
$draft->fetch(GETPOSTINT('facid'));
$extralabels = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($draft->table_element);
if ($draft->fetch_optionals() > 0) {
$object->array_options = array_merge($object->array_options, $draft->array_options);

View file

@ -98,8 +98,6 @@ if ($resultproject < 0) {
$hookmanager->initHooks(array('newpayment'));
$extrafields = new ExtraFields($db);
$user->loadDefaultValues();
// Security check

View file

@ -48,7 +48,6 @@ if (is_numeric($entity)) {
// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
@ -108,8 +107,6 @@ $langs->loadLangs(array("main", "companies", "install", "other", "eventorganizat
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('publicnewmembercard', 'globalcard'));
$extrafields = new ExtraFields($db);
$user->loadDefaultValues();
$cactioncomm = new CActionComm($db);

View file

@ -48,7 +48,6 @@ if (is_numeric($entity)) {
// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
@ -108,8 +107,6 @@ $langs->loadLangs(array("main", "companies", "install", "other", "eventorganizat
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('publicnewmembercard', 'globalcard'));
$extrafields = new ExtraFields($db);
$user->loadDefaultValues();
$cactioncomm = new CActionComm($db);

View file

@ -7,7 +7,7 @@
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Florian Henry <florian.henry@open-concept.pro
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -86,7 +86,6 @@ if (!$sortorder) {
// Initialize a technical objects
$extrafields = new ExtraFields($db);
$hookmanager->initHooks(array('agendaresource'));
$object = new Dolresource($db);