我在Tomcat 7上设置了带有quercus(4.0.25)的mediawiki(1.19.2)。安装过程进行的很顺利,没有错误或警告,数据库连接正常,在安装过程结束时,我复制LocalSettings.php根据需要放入mediawiki基础文件夹中。
从那一刻起,我在每个mediawiki页面上多次获得了以下的php警告:
webapps\mediawiki\includes\Message.php:388: Warning: function 'htmlspecialchars' called with 4 arguments, but only expects 3 arguments [htmlspecialchars]
Message.php:
365:/** 366: * Returns the message parsed from wikitext to HTML. 367: * @return String: HTML 368: */ 369:public function toString() { 370: $string = $this->getMessageText(); 371: 372: # Replace parameters before text parsing 373: $string = $this->replaceParameters( $string, 'before' ); 374: 375: # Maybe transform using the full parser 376: if( $this->format === 'parse' ) { 377: $string = $this->parseText( $string ); 378: $m = array(); 379: if( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $string, $m ) ) { 380: $string = $m[1]; 381: } 382: } elseif( $this->format === 'block-parse' ){ 383: $string = $this->parseText( $string ); 384: } elseif( $this->format === 'text' ){ 385: $string = $this->transformText( $string ); 386: } elseif( $this->format === 'escaped' ){ 387: $string = $this->transformText( $string ); 388: $string = htmlspecialchars( $string, ENT_QUOTES, 'UTF-8', false ); 389: } 390: 391: # Raw parameter replacement 392: $string = $this->replaceParameters( $string, 'after' ); 393: 394: return $string; 395:}
任何人都可以告诉我,如果这是一个严重的警告,或者如果可能存在版本冲突(最新mediawiki不与栎属工作)?
可能这个警告来自一个错误的编码(我select在设置utf-8)?
如果没有解决办法,有没有办法摆脱这个特殊的警告(mediawiki似乎工作正常,因为我可以看到)?
根据PHP手册 ,htmlspecialchars 确实需要4个参数,其中3个是可选的。
这表明Quercus是PHP的一个不完整的实现。
PHP中的警告通常表示它将继续前进并尽其所能。 在这种情况下,假定它的行为就像设置为真,因此它将对任何现有的实体进行双重编码。
如果第388行上的第四个参数(以及其他用四个参数调用该函数的地方)设置为true,则可以忽略此警告。
如果它被设置为false(现在代码在你的问题中,我可以看到它),你可能会在wiki的html中结束双重编码的实体。 这可能会导致显示问题和可能断开的链接。
在我心中更紧迫的问题是栎属植物是多么不完整? 有多less其他function不像香草PHP一样工作?
如果这是面向公众的,则可能存在不完整function的安全问题(例如, htmlspecialchars_decode()的等效问题可能允许XSS)。
至于如何解决这个警告,正确的方法是用Caucho提出一个错误报告,一旦修正就更新。