Moodl:集成密码,消除错误phpCAS error: phpCAS::client(): type mismatched for parameter $se

本文详细介绍了如何使用PHP脚本来生成Moodle密码,并解决了使用phpCAS时遇到的服务器版本类型不匹配的问题。通过添加特定的user属性值,成功地解决了phpCAS错误。

1. Generate Moodle password

 

For generating a moodle password , first of all include the the configuration page then use the script given below

$password = “new password”;
$moodle_password = md5($password.$CFG->passwordsaltmain);

 
$password is the actual password and the passwordsaltmain is a hash key generated at moodle installation.

 

原文: http://php-experts-code.blogspot.com/2011/03/generate-moodle-password.html

 

另一种方法是:

$moodle_password = hash_internal_user_password($password);

 

完全一样的效果!

 

2. phpCAS error: phpCAS::client(): type mismatched for parameter $server_version (should be `string') in C:\xmoodle\moodle\auth\cas\auth.php on line 170

 

这个关键在于属性"mnethostid", 这个值默认是0, 但是应该让其为1, 所以添加一个新的user,应该是:

$person               = new StdClass();
$person->auth         = 'manual';
$person->confirmed    = 1;
$person->mnethostid   = 1;  // 重点
$person->lastlogin    = time();
$person->currentlogin = time();

$person->username     = "newperson";
$person->password     = hash_internal_user_password('newperson');
//$person->idnumber   = $person->username;
$person->firstname    = "newperson";
$person->lastname     = "liang";
$person->email        = "newperson@gmail.com";
$person->city         = "sf";
$person->country      = "US";
$person->lang         = "en";

echo $person->id = $DB->insert_record('user', $person);

 

也可以去参考 https://moodle.org/mod/forum/discuss.php?d=73451, 可能会有其他的办法解决。

 

 

WARNING: library USBHost claims to run on sam architecture(s) and may be incompatible with your current board which runs on esp32 architecture(s). In file included from c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/KeyboardController.h:22, from D:\kaifa\printer\HP2124\HP2124.ino:1: c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h: In member function 'virtual void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint32_t, uint32_t, uint32_t, uint32_t, const USB_ENDPOINT_DESCRIPTOR*)': c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:76: error: 'UOTGHS_HSTPIPCFG_PTYPE_INTRPT' was not declared in this scope 474 | pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:107: error: 'UOTGHS_HSTPIPCFG_PTOKEN_IN' was not declared in this scope 474 | pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:165: error: 'UOTGHS_HSTPIPCFG_PBK_1_BANK' was not declared in this scope 474 | pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:24: error: there are no arguments to 'UHD_Pipe_Alloc' that depend on a template parameter, so a declaration of 'UHD_Pipe_Alloc' must be available [-fpermissive] 474 | pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK); | ^~~~~~~~~~~~~~ c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:24: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h: In member function 'virtual uint32_t HIDBoot<BOOT_PROTOCOL>::Release()': c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:500:9: error: there are no arguments to 'UHD_Pipe_Free' that depend on a template parameter, so a declaration of 'UHD_Pipe_Free' must be available [-fpermissive] 500 | UHD_Pipe_Free(epInfo[epInterruptInIndex].hostPipeNum); | ^~~~~~~~~~~~~ D:\kaifa\printer\HP2124\HP2124.ino: At global scope: D:\kaifa\printer\HP2124\HP2124.ino:22:1: error: 'USBPrinter' does not name a type 22 | USBPrinter printer; // USB打印机实例 | ^~~~~~~~~~ D:\kaifa\printer\HP2124\HP2124.ino:32:6: error: variable or field 'printerEventCallback' declared void 32 | void printerEventCallback(usb_host_client_handle_t clientHandle, | ^~~~~~~~~~~~~~~~~~~~ D:\kaifa\printer\HP2124\HP2124.ino:32:27: error: 'usb_host_client_handle_t' was not declared in this scope 32 | void printerEventCallback(usb_host_client_handle_t clientHandle, | ^~~~~~~~~~~~~~~~~~~~~~~~ D:\kaifa\printer\HP2124\HP2124.ino:32:66: error: 'usb_host_event_t' was not declared in this scope 32 | void printerEventCallback(usb_host_client_handle_t clientHandle, | ^ D:\kaifa\printer\HP2124\HP2124.ino:32:90: error: expected primary-expression before 'void' 32 | void printerEventCallback(usb_host_client_handle_t clientHandle, | ^ D:\kaifa\printer\HP2124\HP2124.ino:32:6: error: variable or field 'printerEventCallback' declared void 32 | void printerEventCallback(usb_host_client_handle_t clientHandle, | ^~~~~~~~~~~~~~~~~~~~ D:\kaifa\printer\HP2124\HP2124.ino:32:27: error: 'usb_host_client_handle_t' was not declared in this scope 32 | void printerEventCallback(usb_host_client_handle_t clientHandle, | ^~~~~~~~~~~~~~~~~~~~~~~~ D:\kaifa\printer\HP2124\HP2124.ino:33:26: error: 'usb_host_event_t' was not declared in this scope 33 | usb_host_event_t event, void *arg) { | ^~~~~~~~~~~~~~~~ D:\kaifa\printer\HP2124\HP2124.ino:33:50: error: expected primary-expression before 'void' 33 | usb_host_event_t event, void *arg) { | ^~~~ D:\kaifa\printer\HP2124\HP2124.ino: In function 'void sendPCLCommand(const uint8_t*, size_t)': D:\kaifa\printer\HP2124\HP2124.ino:68:27: error: no matching function for call to 'min(int, size_t)' 68 | size_t chunkSize = min(64, len - i); | ~~~^~~~~~~~~~~~~ In file included from C:/Users/Dev/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/algorithm:61, from C:\Users\Dev\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\cores\esp32/Arduino.h:190, from c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hid.h:24, from c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:24: C:/Users/Dev/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_algo.h:5695:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5695 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ C:/Users/Dev/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_algo.h:5695:5: note: template argument deduction/substitution failed: D:\kaifa\printer\HP2124\HP2124.ino:68:27: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 68 | size_t chunkSize = min(64, len - i); | ~~~^~~~~~~~~~~~~ C:/Users/Dev/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_algo.h:5685:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5685 | min(initializer_list<_Tp> __l) | ^~~ C:/Users/Dev/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_algo.h:5685:5: note: candidate expects 1 argument, 2 provided In file included from C:/Users/Dev/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/specfun.h:43, from C:/Users/Dev/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/cmath:3898, from C:/Users/Dev/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/math.h:36, from C:\Users\Dev\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\cores\esp32/esp32-hal.h:30, from C:\Users\Dev\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.0\cores\esp32/Arduino.h:44: C:/Users/Dev/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ C:/Users/Dev/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided C:/Users/Dev/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ C:/Users/Dev/AppData/Local/Arduino15/packages/esp32/tools/esp-x32/2411/xtensa-esp-elf/include/c++/14.2.0/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: D:\kaifa\printer\HP2124\HP2124.ino:68:27: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'size_t' {aka 'unsigned int'}) 68 | size_t chunkSize = min(64, len - i); | ~~~^~~~~~~~~~~~~ D:\kaifa\printer\HP2124\HP2124.ino:69:10: error: 'printer' was not declared in this scope; did you mean 'printf'? 69 | if (!printer.sendData(data + i, chunkSize)) { | ^~~~~~~ | printf D:\kaifa\printer\HP2124\HP2124.ino: In function 'void setup()': D:\kaifa\printer\HP2124\HP2124.ino:96:16: error: 'class USBHost' has no member named 'begin' 96 | if (!usbHost.begin()) { | ^~~~~ D:\kaifa\printer\HP2124\HP2124.ino:102:3: error: 'printer' was not declared in this scope; did you mean 'printf'? 102 | printer.registerEventCallback(printerEventCallback); | ^~~~~~~ | printf D:\kaifa\printer\HP2124\HP2124.ino:102:33: error: 'printerEventCallback' was not declared in this scope 102 | printer.registerEventCallback(printerEventCallback); | ^~~~~~~~~~~~~~~~~~~~ D:\kaifa\printer\HP2124\HP2124.ino:105:3: error: 'USBHConfig' was not declared in this scope 105 | USBHConfig config = { | ^~~~~~~~~~ D:\kaifa\printer\HP2124\HP2124.ino:109:11: error: 'class USBHost' has no member named 'setConfig'; did you mean 'USBDeviceConfig* USBHost::devConfig [16]'? (not accessible from this context) 109 | usbHost.setConfig(config); | ^~~~~~~~~ In file included from c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:23: c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/Usb.h:163:65: note: declared private here 163 | USBDeviceConfig* devConfig[USB_NUMDEVICES]; | ^~~~~~~~~ D:\kaifa\printer\HP2124\HP2124.ino:109:21: error: 'config' was not declared in this scope 109 | usbHost.setConfig(config); | ^~~~~~ D:\kaifa\printer\HP2124\HP2124.ino: In function 'void loop()': D:\kaifa\printer\HP2124\HP2124.ino:115:11: error: 'class USBHost' has no member named 'task'; did you mean 'Task'? 115 | usbHost.task(); // 处理USB事件 | ^~~~ | Task c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h: In instantiation of 'uint32_t HIDBoot<BOOT_PROTOCOL>::Release() [with unsigned char BOOT_PROTOCOL = 2; uint32_t = long unsigned int]': c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:497:10: required from here 497 | uint32_t HIDBoot<BOOT_PROTOCOL>::Release() | ^~~~~~~~~~~~~~~~~~~~~~ c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:500:22: error: 'UHD_Pipe_Free' was not declared in this scope 500 | UHD_Pipe_Free(epInfo[epInterruptInIndex].hostPipeNum); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h: In instantiation of 'void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint32_t, uint32_t, uint32_t, uint32_t, const USB_ENDPOINT_DESCRIPTOR*) [with unsigned char BOOT_PROTOCOL = 2; uint32_t = long unsigned int]': c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:447:6: required from here 447 | void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint32_t conf, uint32_t iface, uint32_t alt, uint32_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) | ^~~~~~~~~~~~~~~~~~~~~~ c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:192: error: 'UHD_Pipe_Alloc' was not declared in this scope 474 | pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK); | ^ c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h: In instantiation of 'uint32_t HIDBoot<BOOT_PROTOCOL>::Release() [with unsigned char BOOT_PROTOCOL = 1; uint32_t = long unsigned int]': c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:497:10: required from here 497 | uint32_t HIDBoot<BOOT_PROTOCOL>::Release() | ^~~~~~~~~~~~~~~~~~~~~~ c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:500:22: error: 'UHD_Pipe_Free' was not declared in this scope 500 | UHD_Pipe_Free(epInfo[epInterruptInIndex].hostPipeNum); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h: In instantiation of 'void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint32_t, uint32_t, uint32_t, uint32_t, const USB_ENDPOINT_DESCRIPTOR*) [with unsigned char BOOT_PROTOCOL = 1; uint32_t = long unsigned int]': c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:447:6: required from here 447 | void HIDBoot<BOOT_PROTOCOL>::EndpointXtract(uint32_t conf, uint32_t iface, uint32_t alt, uint32_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) | ^~~~~~~~~~~~~~~~~~~~~~ c:\Users\Dev\Documents\Arduino\libraries\USBHost\src/hidboot.h:474:192: error: 'UHD_Pipe_Alloc' was not declared in this scope 474 | pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].deviceEpNum, UOTGHS_HSTPIPCFG_PTYPE_INTRPT, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 10, UOTGHS_HSTPIPCFG_PBK_1_BANK); | ^ exit status 1 Compilation error: 'USBPrinter' does not name a type
08-14
在软件开发中,"Mismatched Properties" 错误通常表示两个或多个对象、类或数据结构之间存在属性定义的不一致。这种错误可以出现在多种场景中,例如对象序列化/反序列化、数据库映射、接口实现、跨平台数据交换等。 ### 常见原因与解决方法 1. **对象映射不一致** - 当使用 ORM(如 Hibernate、Entity Framework)时,数据库表字段与实体类属性之间存在不匹配。例如,数据库中的列名为 `user_name`,而实体类中使用了 `userName`- 解决方法:检查映射配置,确保字段名称、类型、大小等一致,必要时使用注解或配置文件明确指定映射关系。 2. **JSON/XML 序列化问题** - 在反序列化 JSON 或 XML 数据时,目标类的属性与数据源中的字段名或结构不匹配。 - 示例: ```json { "name": "Alice", "age": 30 } ``` 若目标类中没有 `name``age` 属性,则可能抛出属性不匹配异常。 - 解决方法:使用自定义属性名映射,例如在 Java 中使用 `@JsonProperty("name")`,在 C# 中使用 `[JsonProperty("name")]`。 3. **接口与实现不一致** - 在面向对象编程中,若接口定义了某些属性,但实现类未正确实现这些属性,也可能导致运行时错误- 解决方法:确保实现类完整实现接口定义的所有属性和方法。 4. **跨平台或跨语言通信** - 在使用 REST API、gRPC 或消息队列进行服务间通信时,若发送方与接收方的数据结构定义不一致,也会出现属性不匹配错误- 解决方法:使用统一的数据契约(如 Protocol Buffers、OpenAPI),并确保所有服务端点使用相同版本的契约。 5. **配置文件或环境变量不匹配** - 在微服务或容器化环境中,若配置文件中定义的属性与代码中读取的属性名不一致,也可能导致运行时错误- 解决方法:使用配置管理工具(如 Spring Cloud Config、Consul)并进行配置验证。 ### 调试建议 - 检查错误日志中的堆栈跟踪,定位具体出错的类或方法。 - 使用调试器或日志输出对象的实际属性结构,与预期结构进行比对。 - 在开发过程中启用严格的类型检查和编译时验证机制。 若错误信息中提到了具体的字段或类名,可以据此进一步定位问题所在。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值