Error 12 , Uncaught Error: Class "DataTables\HtmLawed\HtmLawed" not found

Error 12 , Uncaught Error: Class "DataTables\HtmLawed\HtmLawed" not found

jasoncaditrackjasoncaditrack Posts: 14Questions: 6Answers: 0

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

  • jasoncaditrackjasoncaditrack Posts: 14Questions: 6Answers: 0

    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.

    {
        "_readme": [
            "This file locks the dependencies of your project to a known state",
            "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
            "This file is @generated automatically"
        ],
        "content-hash": "006bd5d5368f1008bb46231e643f9891",
        "packages": [
            {
                "name": "datatables.net/editor-php",
                "version": "2.3.2",
                "source": {
                    "type": "git",
                    "url": "https://github.com/DataTables/Editor-PHP.git",
                    "reference": "ef7a9cff90ca9e1a5424f4e32743ddbe4d84a42f"
                },
                "dist": {
                    "type": "zip",
                    "url": "https://api.github.com/repos/DataTables/Editor-PHP/zipball/ef7a9cff90ca9e1a5424f4e32743ddbe4d84a42f",
                    "reference": "ef7a9cff90ca9e1a5424f4e32743ddbe4d84a42f",
                    "shasum": ""
                },
                "require": {
                    "php": ">=5.4.0 <8.4"
                },
                "require-dev": {
                    "friendsofphp/php-cs-fixer": "~3.41.0",
                    "phpstan/extension-installer": "^1.1",
                    "phpstan/phpstan": "~1.10.47",
                    "phpstan/phpstan-deprecation-rules": "^1.0"
                },
                "type": "library",
                "autoload": {
                    "psr-4": {
                        "DataTables\\": ""
                    }
                },
                "notification-url": "https://packagist.org/downloads/",
                "license": [
                    "MIT"
                ],
                "authors": [
                    {
                        "name": "SpryMedia Ltd",
                        "homepage": "https://datatables.net"
                    }
                ],
                "description": "PHP server-side libraries for Editor",
                "homepage": "https://editor.datatables.net",
                "keywords": [
                    "datatables",
                    "editor",
                    "jquery"
                ],
                "support": {
                    "issues": "https://github.com/DataTables/Editor-PHP/issues",
                    "source": "https://github.com/DataTables/Editor-PHP/tree/2.3.2"
                },
                "time": "2024-03-08T11:38:41+00:00"
            }
        ],
        "packages-dev": [],
        "aliases": [],
        "minimum-stability": "stable",
        "stability-flags": [],
        "prefer-stable": false,
        "prefer-lowest": false,
        "platform": [],
        "platform-dev": [],
        "plugin-api-version": "2.3.0"
    }
    
    
  • allanallan Posts: 63,274Questions: 1Answers: 10,424 Site admin

    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

Sign In or Register to comment.