When editing a project that has no thirdparty attached, the WON/customer
conversion block dereferenced $object->thirdparty->client without first
checking that the thirdparty was loaded. $object->fetch_thirdparty()
leaves the property null in that case so PHP 8 raised a fatal error.
Add !is_null($object->thirdparty) on both opportunity blocks (create
and update paths). This is the same guard already shipped on 23.0
through 6ce7ba17f4, backported to keep 22.0 stable for the N-1 window.
Signed-off-by: Dolicraft <contact@dolicraft.com>
Co-authored-by: Dolicraft <contact@dolicraft.com>
This commit is contained in:
parent
48cb717cd3
commit
f7fdcb3c82
1 changed files with 8 additions and 10 deletions
|
|
@ -365,16 +365,14 @@ if (empty($reshook)) {
|
|||
setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors');
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
if ((int) $object->thirdparty->client == 0 || (int) $object->thirdparty->client == 2) { // If not yet customer
|
||||
// Get ID of the special opportunity status code 'WON'
|
||||
$idoppstatuswon = (int) dol_getIdFromCode($db, 'WON', 'c_lead_status', 'code', 'rowid');
|
||||
if (!$error && !is_null($object->thirdparty) && ((int) $object->thirdparty->client == 0 || (int) $object->thirdparty->client == 2)) { // If not yet customer
|
||||
// Get ID of the special opportunity status code 'WON'
|
||||
$idoppstatuswon = (int) dol_getIdFromCode($db, 'WON', 'c_lead_status', 'code', 'rowid');
|
||||
|
||||
if ($object->opp_status == $idoppstatuswon) {
|
||||
// Switch the thirdparty into a customer (only if thirdparty exists)
|
||||
if (!empty($object->thirdparty) && !empty($object->thirdparty->id)) {
|
||||
$object->thirdparty->setAsCustomer();
|
||||
}
|
||||
if ($object->opp_status == $idoppstatuswon) {
|
||||
// Switch the thirdparty into a customer (only if thirdparty exists)
|
||||
if (!empty($object->thirdparty) && !empty($object->thirdparty->id)) {
|
||||
$object->thirdparty->setAsCustomer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -465,7 +463,7 @@ if (empty($reshook)) {
|
|||
|
||||
// If opportunities are used and the customer is not yet a customer
|
||||
if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') && $object->usage_opportunity) {
|
||||
if ((int) $object->thirdparty->client == 0 || (int) $object->thirdparty->client == 2) { // If not yet customer
|
||||
if (!is_null($object->thirdparty) && ((int) $object->thirdparty->client == 0 || (int) $object->thirdparty->client == 2)) { // If not yet customer
|
||||
// Get ID of the special opportunity status code 'WON'
|
||||
$idoppstatuswon = (int) dol_getIdFromCode($db, 'WON', 'c_lead_status', 'code', 'rowid');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue