Skip to content

Commit

Permalink
Dev: Update to latest Yii master (no release yet; needed for PHP 7.4 …
Browse files Browse the repository at this point in the history
…compatibility)
  • Loading branch information
olleharstedt committed Jan 10, 2020
1 parent 67427c6 commit 5ddec10
Show file tree
Hide file tree
Showing 18 changed files with 285 additions and 142 deletions.
2 changes: 1 addition & 1 deletion framework/YiiBase.php
Expand Up @@ -87,7 +87,7 @@ class YiiBase
*/
public static function getVersion()
{
return '1.1.21';
return '1.1.22-dev';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions framework/db/schema/pgsql/CPgsqlSchema.php
Expand Up @@ -166,7 +166,7 @@ protected function resolveTableNames($table,$name)
protected function findColumns($table)
{
$sql=<<<EOD
SELECT a.attname, LOWER(format_type(a.atttypid, a.atttypmod)) AS type, pg_get_expr(d.adbin,d.adrelid) as adsrc, a.attnotnull, a.atthasdef,
SELECT a.attname, LOWER(format_type(a.atttypid, a.atttypmod)) AS type, d.adsrc, a.attnotnull, a.atthasdef,
pg_catalog.col_description(a.attrelid, a.attnum) AS comment
FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attnum > 0 AND NOT a.attisdropped
Expand Down Expand Up @@ -231,7 +231,7 @@ protected function findConstraints($table)
CASE WHEN contype='f' THEN
pg_catalog.pg_get_constraintdef(oid)
ELSE
'CHECK (' || pg_get_expr(conbin, conrelid) || ')'
'CHECK (' || consrc || ')'
END AS consrc,
contype,
conrelid AS relid,
Expand Down
2 changes: 1 addition & 1 deletion framework/gii/components/Pear/Text/Diff3.php
Expand Up @@ -194,7 +194,7 @@ function isConflict()
*/
class Text_Diff3_Op_copy extends Text_Diff3_Op {

function Text_Diff3_Op_Copy($lines = false)
function __construct($lines = false)
{
$this->orig = $lines ? $lines : array();
$this->final1 = &$this->orig;
Expand Down
2 changes: 1 addition & 1 deletion framework/i18n/CDateFormatter.php
Expand Up @@ -90,7 +90,7 @@ public function format($pattern,$time)

if(is_string($time))
{
if(ctype_digit($time) || ($time{0}=='-' && ctype_digit(substr($time, 1))))
if(ctype_digit($time) || ($time[0]=='-' && ctype_digit(substr($time, 1))))
$time=(int)$time;
else
$time=strtotime($time);
Expand Down
2 changes: 1 addition & 1 deletion framework/utils/CDateTimeParser.php
Expand Up @@ -210,7 +210,7 @@ public static function parse($value,$pattern='MM/dd/yyyy',$defaults=array())
default:
{
$tn=self::$_mbstringAvailable ? mb_strlen($token,Yii::app()->charset) : strlen($token);
if($i>=$n || ($token{0}!='?' && (self::$_mbstringAvailable ? mb_substr($value,$i,$tn,Yii::app()->charset) : substr($value,$i,$tn))!==$token))
if($i>=$n || ($token[0]!='?' && (self::$_mbstringAvailable ? mb_substr($value,$i,$tn,Yii::app()->charset) : substr($value,$i,$tn))!==$token))
return false;
$i+=$tn;
break;
Expand Down
2 changes: 1 addition & 1 deletion framework/utils/CFormatter.php
Expand Up @@ -229,7 +229,7 @@ protected function normalizeDateValue($time)
{
if(is_string($time))
{
if(ctype_digit($time) || ($time{0}=='-' && ctype_digit(substr($time, 1))))
if(ctype_digit($time) || ($time[0]=='-' && ctype_digit(substr($time, 1))))
return (int)$time;
else
return strtotime($time);
Expand Down
12 changes: 11 additions & 1 deletion framework/validators/CEmailValidator.php
Expand Up @@ -200,7 +200,17 @@ private function encodeIDN($value)
if(preg_match_all('/^(.*)@(.*)$/',$value,$matches))
{
if(function_exists('idn_to_ascii'))
$value=$matches[1][0].'@'.idn_to_ascii($matches[2][0]);
{

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Jan 11, 2020

Collaborator

This mean we can come back to Yii emailvalidator ?

PHPMailer have his own validator :!

public static $validator = 'php-idna';
sysem

$value=$matches[1][0].'@';
if (defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46'))
{
$value.=idn_to_ascii($matches[2][0],IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
}
else
{
$value.=idn_to_ascii($matches[2][0]);
}
}
else
{
require_once(Yii::getPathOfAlias('system.vendors.Net_IDNA2.Net').DIRECTORY_SEPARATOR.'IDNA2.php');
Expand Down
26 changes: 24 additions & 2 deletions framework/validators/CUrlValidator.php
Expand Up @@ -169,7 +169,18 @@ private function encodeIDN($value)
if(preg_match_all('/^(.*):\/\/([^\/]+)(.*)$/',$value,$matches))
{
if(function_exists('idn_to_ascii'))
$value=$matches[1][0].'://'.idn_to_ascii($matches[2][0]).$matches[3][0];
{
$value=$matches[1][0].'://';
if (defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46'))
{
$value.=idn_to_ascii($matches[2][0],IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
}
else
{
$value.=idn_to_ascii($matches[2][0]);
}
$value.=$matches[3][0];
}
else
{
require_once(Yii::getPathOfAlias('system.vendors.Net_IDNA2.Net').DIRECTORY_SEPARATOR.'IDNA2.php');
Expand All @@ -191,7 +202,18 @@ private function decodeIDN($value)
if(preg_match_all('/^(.*):\/\/([^\/]+)(.*)$/',$value,$matches))
{
if(function_exists('idn_to_utf8'))
$value=$matches[1][0].'://'.idn_to_utf8($matches[2][0]).$matches[3][0];
{
$value=$matches[1][0].'://';
if (defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46'))
{
$value.=idn_to_utf8($matches[2][0],IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
}
else
{
$value=idn_to_utf8($matches[2][0]);
}
$value.=$matches[3][0];
}
else
{
require_once(Yii::getPathOfAlias('system.vendors.Net_IDNA2.Net').DIRECTORY_SEPARATOR.'IDNA2.php');
Expand Down
8 changes: 4 additions & 4 deletions framework/vendors/Net_IDNA2/Net/IDNA2.php
Expand Up @@ -2683,7 +2683,7 @@ private function _decode($encoded)

if ($delim_pos > self::_byteLength($this->_punycode_prefix)) {
for ($k = self::_byteLength($this->_punycode_prefix); $k < $delim_pos; ++$k) {
$decoded[] = ord($encoded{$k});
$decoded[] = ord($encoded[$k]);
}
} else {
$decoded = array();
Expand All @@ -2700,7 +2700,7 @@ private function _decode($encoded)

for ($enco_idx = ($delim_pos)? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) {
for ($old_idx = $idx, $w = 1, $k = $this->_base; 1 ; $k += $this->_base) {
$digit = $this->_decodeDigit($encoded{$enco_idx++});
$digit = $this->_decodeDigit($encoded[$enco_idx++]);
$idx += $digit * $w;

$t = ($k <= $bias) ?
Expand Down Expand Up @@ -3112,7 +3112,7 @@ private function _utf8_to_ucs4($input)
$mode = 'next';
$test = 'none';
for ($k = 0; $k < $inp_len; ++$k) {
$v = ord($input{$k}); // Extract byte from input string
$v = ord($input[$k]); // Extract byte from input string

if ($v < 128) { // We found an ASCII char - put into stirng as is
$output[$out_len] = $v;
Expand Down Expand Up @@ -3279,7 +3279,7 @@ private function _ucs4_string_to_ucs4($input)
$out_len++;
$output[$out_len] = 0;
}
$output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) );
$output[$out_len] += ord($input[$i]) << (8 * (3 - ($i % 4) ) );
}
return $output;
}
Expand Down
Expand Up @@ -419,7 +419,7 @@ function _makeRE($text, $case = false)
if (!strlen($text)) {
$this->_error(TEXT_HIGHLIGHTER_EMPTY_RE);
}
if (!strlen($text) || $text{0} != '/') {
if (!strlen($text) || $text[0] != '/') {
$text = '/' . $text . '/';
}
if (!$case) {
Expand Down

1 comment on commit 5ddec10

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\o/

Please sign in to comment.