Error 12 , Uncaught Error: Class "DataTables\HtmLawed\HtmLawed" not found
Error 12 , Uncaught Error: Class "DataTables\HtmLawed\HtmLawed" not found
I recently released a project from development into a hosted server environment, and experienced a #12 error when Editor submits a POST request, to update an inline field. The response is 500 internal server error.
The XHR response shows an empty response, the payload appears to be correct:data[row_42][tbuild_params][last_item_count]: 0.0002
action: edit
What is making it hard to diagnose is that the error does NOT occur in the development environment of the same PHP version 8.x.x., and there is no error with the GET request that loads the datatable.
the error stack looks like this:
[02-Aug-2024 12:21:23 America/Vancouver] PHP Fatal error: Uncaught Error: Class "DataTables\HtmLawed\HtmLawed" not found in /home/caditrac/public_html/gpt/vendor/datatables.net/editor-php/HtmLawed/HtmLawedVanillaWrapper.php:69
Stack trace:
#0 /home/caditrac/public_html/gpt/vendor/datatables.net/editor-php/Editor/Field.php(855): DataTables\HtmLawed\HtmLawedVanillaWrapper::filter()
#1 /home/caditrac/public_html/gpt/vendor/datatables.net/editor-php/Editor/Field.php(731): DataTables\Editor\Field->xssSafety()
#2 /home/caditrac/public_html/gpt/vendor/datatables.net/editor-php/Editor.php(2218): DataTables\Editor\Field->val()
#3 /home/caditrac/public_html/gpt/vendor/datatables.net/editor-php/Editor.php(2111): DataTables\Editor->_insert_or_update_table()
#4 /home/caditrac/public_html/gpt/vendor/datatables.net/editor-php/Editor.php(1293): DataTables\Editor->_insert_or_update()
#5 /home/caditrac/public_html/gpt/vendor/datatables.net/editor-php/Editor.php(1041): DataTables\Editor->_update()
#6 /home/caditrac/public_html/gpt/vendor/datatables.net/editor-php/Editor.php(707): DataTables\Editor->_process()
#7 /home/caditrac/public_html/gpt/api/dataTables/bp-plan-api.php(49): DataTables\Editor->process()
#8 {main}
thrown in /home/caditrac/public_html/gpt/vendor/datatables.net/editor-php/HtmLawed/HtmLawedVanillaWrapper.php on line 69
my API code is this:
<?php
// DataTables PHP library and database connection
require '../../vendor/autoload.php';
require '../../header-php.php';
// Alias Editor classes so they are easy to use
use
CompanyTools\DB\DBConnexion,
DataTables\Database,
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;
$database = new DBConnexion($_SESSION["housekeepingPath"], $_SESSION["biznum"]);
$sql_details = $database->datatablesCredentials();
unset($database);
$db = new Database($sql_details);
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'tbuild_params')
->fields(
Field::inst( 'tbuild_params.id' ),
Field::inst( 'tbuild_params.item_num' ),
Field::inst( 'tbuild_params.item_name' ),
Field::inst( 'tbuild_params.process_type' ),
Field::inst( 'tbuild_params.brand' ),
Field::inst( 'tbuild_params.buy_unit' ),
Field::inst( 'tbuild_params.sell_unit' ),
Field::inst( 'tbuild_params.vendor' ),
Field::inst( 'tbuild_params.sales_per_month' ),
Field::inst( 'tbuild_params.last_item_count' ),
Field::inst( 'tbuild_params.months_required' ),
Field::inst( 'tbuild_params.build_instruction' ),
Field::inst( 'tbuild_params.created_at' )
)
->process( $_POST )
->json();
Any ideas on how to proceed would be much appreciated.
Thanks
Answers
Issue with Release 2.3.2 of editor-php
I have combed through the updates in my new release, and have discovered that the problem appears to be related to composer updating my package editor-php from release 2.2.2 to release 2.3.2.
When I backed down to 2.2.2 the problem went away.
Again, the problem only occured in my hosted server environment, not in development.
see below the composer.lock file containing the problematic editor-php version.
Thank you for the files. I'll try it when I get into the office next week (it will probably be Tuesday due to other commitments on Monday). I wasn't aware of an issue with a composer install of the libraries.
The HtmlLawed part only kicks in on submission - it is part of the anti-XSS checks, which is why GET will work, but an error on update.
Regards,
Allan