Custom cPanel Module Errors Out in Latest cPanel
-
Which version is this? v116? If this is a bug it would be helpful to know when precisely this started, as I can look up the version's tag in git to try to see what code might have been responsible for this kind of change. Regardless, I can at least give you some context about where this is failing. Like 367 starts a perl eval
block which attempts to execute your module's custom function. The function itself is found and executed like so:365 if ( my $function_cr = $function_cache{"Cpanel::API::${module}::$function"} ||= "Cpanel::API::${module}"->can($function) ) { 366 local $@; 367 eval { 368 local $SIG{'__DIE__'}; 369 $result->status( scalar $function_cr->( $args, $result ) ); 370 1; 371 } or do { 372 _handle_eval_fail( $result, $@ ); 373 }; 374 }
Since this code is inside an eval, It's hard to say without looking at your code what exactly is going wrong, but certainly if I had to guess, the subroutine you've defined which matches what we get withCpanel::API::ExampleDevModule->can('test_function');
is perhaps returning something unexpected. Given you executedExampleDevModule
yet your stacktrace showsStarshipDev
, I'd say that there's likely some shenanigans going on here with what this module is returning viaUNIVERSAL::can
, which might explain why typeglobs are involved in this error. If you want your module to return a subroutine reference from another module, It's probably better to use the haveCpanel::API::ExampleDevModule::test_function
require that other module thenreturn Cpanel::API::StarshipDev::test_function($args,$result);
instead of fiddling with the symbol table across namespaces in perl. Apologies in advance if I misunderstand what's happening here. Errors within an eval block are already frustrating enough to have to deal with at times. The "canonical" example for custom UAPI modules currently lives here:0 -
Which version is this? v116? If this is a bug it would be helpful to know when precisely this started, as I can look up the version's tag in git to try to see what code might have been responsible for this kind of change.
This is moving from a 110.0.15 server to 114.0.12 server. The earlier one may have been broken recently with an upgrade too, not certain. I just know that it was working some months ago. [quote]Since this code is inside an eval, It's hard to say without looking at your code what exactly is going wrong, but certainly if I had to guess, the subroutine you've defined which matches what we get withCpanel::API::ExampleDevModule->can('test_function');
is perhaps returning something unexpected.
Basically this:package Cpanel::API::ExampleDevModule; use strict; use JSON::XS qw( decode_json ); use Data::Dumper qw(Dumper); our $VERSION = '1.0'; # Cpanel Dependencies use Cpanel (); use Cpanel::API (); use Cpanel::Locale (); use Cpanel::Logger (); use Cpanel::LiveAPI (); # Globals my $logger; my $locale; ........... sub test_function{ # $Cpanel::CPDATA pulls data from /var/cpanel/users/user file my $user = $Cpanel::CPDATA{'USER'}; my ( $args, $result ) = @_; # Build the results. my $success = "true"; if ($success) { return 1; } else { return 0; } }
[quote]Given you executedExampleDevModule
yet your stacktrace showsStarshipDev
, I'd say that there's likely some shenanigans going on here.
That's because I edited the code to post it here, must have missed that edit. There is no mismatch in between module and function names in the code. [quote]The "canonical" example for custom UAPI modules currently lives here:0
Please sign in to leave a comment.
Comments
3 comments