Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): Provide empty string instead of null value #600

Open
wants to merge 2 commits into
base: support/3.1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions setup/compiler.class.inc.php
Expand Up @@ -1165,6 +1165,7 @@ protected function GetMandatoryPropNumber($oNode, $sTag)
*/
protected function QuoteForPHP($sStr, $bSimpleQuotes = false)
{
$sStr = $sStr ?? '';
if ($bSimpleQuotes)
{
$sEscaped = str_replace(array('\\', "'"), array('\\\\', "\\'"), $sStr);
Expand Down Expand Up @@ -3221,10 +3222,11 @@ protected function CompileDictionaries($oDictionaries, $sTempTargetDir, $sFinalT

$aEntriesPHP = array();
$oEntries = $oDictionaryNode->GetUniqueElement('entries');
/** @var MFElement $oEntry */
foreach ($oEntries->getElementsByTagName('entry') as $oEntry)
{
$sStringCode = $oEntry->getAttribute('id');
$sValue = $oEntry->GetText();
$sValue = $oEntry->GetText('');
$aEntriesPHP[] = "\t'$sStringCode' => ".self::QuoteForPHP(self::FilterDictString($sValue), true).",";
Molkobain marked this conversation as resolved.
Show resolved Hide resolved
}
$sEntriesPHP = implode("\n", $aEntriesPHP);
Expand Down Expand Up @@ -3259,7 +3261,7 @@ protected function CompileDictionaries($oDictionaries, $sTempTargetDir, $sFinalT
file_put_contents($sLanguagesFile, $sLanguagesFileContent);
}

protected static function FilterDictString($s)
protected static function FilterDictString(string $s): string
{
if (strpos($s, '~') !== false)
{
Expand Down