Katamaze / WHMCS-Action-Hook-Factory

Free collection of Action Hooks, Reports and Modules to perfect your WHMCS
https://katamaze.com
MIT License
209 stars 84 forks source link

[Bug] Prevent changes to Client Custom Fields #21

Closed HostChefs closed 3 years ago

HostChefs commented 3 years ago

Action Hook File Name

PreventChangesToClientCustomFields.php

Describe the Bug

The client is registering successfully, but the above error is displayed, and also the custom client fields aren't populated.

To Reproduce

While a new client registers the following error comes up:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'value' cannot be null in /home/username/public_html/vendor/illuminate/database/Connection.php:464
Stack trace:
#0 /home/username/public_html/vendor/illuminate/database/Connection.php(464): PDOStatement->execute()
#1 /home/username/public_html/vendor/illuminate/database/Connection.php(664): Illuminate\Database\Connection->Illuminate\Database\{closure}('insert into `tb...', Array)
#2 /home/username/public_html/vendor/illuminate/database/Connection.php(631): Illuminate\Database\Connection->runQueryCallback('insert into `tb...', Array, Object(Closure))
#3 /home/username/public_html/vendor/illuminate/database/Connection.php(465): Illuminate\Database\Connection->run('insert into `tb...', Array, Object(Closure))
#4 /home/username/public_html/vendor/illuminate/database/Connection.php(417): Illuminate\Database\Connection->statement('insert into `tb...', Array)
#5 /home/username/public_html/vendor/illuminate/database/Query/Processors/Processor.php(32): Illuminate\Database\Connection->insert('insert into `tb...', Array)
#6 /home/username/public_html/vendor/illuminate/database/Query/Builder.php(2771): Illuminate\Database\Query\Processors\Processor->processInsertGetId(Object(Illuminate\Database\Query\Builder), 'insert into `tb...', Array, 'id')
#7 /home/username/public_html/vendor/illuminate/database/Eloquent/Builder.php(1403): Illuminate\Database\Query\Builder->insertGetId(Array, 'id')
#8 /home/username/public_html/vendor/illuminate/database/Eloquent/Model.php(900): Illuminate\Database\Eloquent\Builder->__call('insertGetId', Array)
#9 /home/username/public_html/vendor/illuminate/database/Eloquent/Model.php(865): Illuminate\Database\Eloquent\Model->insertAndSetId(Object(Illuminate\Database\Eloquent\Builder), Array)
#10 /home/username/public_html/vendor/illuminate/database/Eloquent/Model.php(728): Illuminate\Database\Eloquent\Model->performInsert(Object(Illuminate\Database\Eloquent\Builder))
#11 /home/username/public_html/includes/customfieldfunctions.php(0): Illuminate\Database\Eloquent\Model->save()
#12 /home/username/public_html/includes/clientfunctions.php(0): saveCustomFields(20630, Array, 'client', false)
#13 /home/username/public_html/vendor/whmcs/whmcs-foundation/lib/User/User.php(0): addClient(Object(WHMCS\User\User), 'ASDASD', 'asdasd', '', 'aaa@a.com', 'asdasd', '', 'asd', 'asd', '12311', 'GR', '+30.123123123', true, Array, '6b7f0312-c65e-4...', false, true, '176.58.227.111')
#14 /home/username/public_html/register.php(0): WHMCS\User\User->createClient('ASDASD', 'asdasd', '', 'aaa@a.com', 'asdasd', '', 'asd', 'asd', '12311', 'GR', '+30.123123123', true, Array, '', false, true)
#15 {main}
Next Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'value' cannot be null (SQL: insert into `tblcustomfieldsvalues` (`fieldid`, `relid`, `value`, `updated_at`, `created_at`) values (72, 20630, ?, 2020-12-18 20:16:11, 2020-12-18 20:16:11)) in /home/username/public_html/vendor/illuminate/database/Connection.php:671
Stack trace:
#0 /home/username/public_html/vendor/illuminate/database/Connection.php(631): Illuminate\Database\Connection->runQueryCallback('insert into `tb...', Array, Object(Closure))
#1 /home/username/public_html/vendor/illuminate/database/Connection.php(465): Illuminate\Database\Connection->run('insert into `tb...', Array, Object(Closure))
#2 /home/username/public_html/vendor/illuminate/database/Connection.php(417): Illuminate\Database\Connection->statement('insert into `tb...', Array)
#3 /home/username/public_html/vendor/illuminate/database/Query/Processors/Processor.php(32): Illuminate\Database\Connection->insert('insert into `tb...', Array)
#4 /home/username/public_html/vendor/illuminate/database/Query/Builder.php(2771): Illuminate\Database\Query\Processors\Processor->processInsertGetId(Object(Illuminate\Database\Query\Builder), 'insert into `tb...', Array, 'id')
#5 /home/username/public_html/vendor/illuminate/database/Eloquent/Builder.php(1403): Illuminate\Database\Query\Builder->insertGetId(Array, 'id')
#6 /home/username/public_html/vendor/illuminate/database/Eloquent/Model.php(900): Illuminate\Database\Eloquent\Builder->__call('insertGetId', Array)
#7 /home/username/public_html/vendor/illuminate/database/Eloquent/Model.php(865): Illuminate\Database\Eloquent\Model->insertAndSetId(Object(Illuminate\Database\Eloquent\Builder), Array)
#8 /home/username/public_html/vendor/illuminate/database/Eloquent/Model.php(728): Illuminate\Database\Eloquent\Model->performInsert(Object(Illuminate\Database\Eloquent\Builder))
#9 /home/username/public_html/includes/customfieldfunctions.php(0): Illuminate\Database\Eloquent\Model->save()
#10 /home/username/public_html/includes/clientfunctions.php(0): saveCustomFields(20630, Array, 'client', false)
#11 /home/username/public_html/vendor/whmcs/whmcs-foundation/lib/User/User.php(0): addClient(Object(WHMCS\User\User), 'ASDASD', 'asdasd', '', 'aaa@a.com', 'asdasd', '', 'asd', 'asd', '12311', 'GR', '+30.123123123', true, Array, '6b7f0312-c65e-4...', false, true, '176.58.227.111')
#12 /home/username/public_html/register.php(0): WHMCS\User\User->createClient('ASDASD', 'asdasd', '', 'aaa@a.com', 'asdasd', '', 'asd', 'asd', '12311', 'GR', '+30.123123123', true, Array, '', false, true)
#13 {main}

Affected Version

Kian987 commented 3 years ago

Thanks for reporting the issue. The bug has been fixed.