Skip to content

Commit

Permalink
9.9.8: #273
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Jul 26, 2023
1 parent 7f92b11 commit a89de19
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
60 changes: 33 additions & 27 deletions Framework/lib/fs/contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,36 @@
* @param Closure|bool|mixed $onE [optional]
* @param ?resource $rs [optional]
*/
function df_contents(string $f, $onE = true, $rs = null):string {return df_try(
/**
* 2015-11-27
* Обратите внимание, что для использования @uses file_get_contents
* с адресами https требуется расширение php_openssl интерпретатора PHP,
* однако оно является системным требованием Magento 2:
* http://devdocs.magento.com/guides/v2.0/install-gde/system-requirements.html#required-php-extensions
* Поэтому мы вправе использовать здесь @uses file_get_contents
* 2016-05-31, 2022-10-14
* file_get_contents() could generate @see E_WARNING: e.g.:
* *) if the file is absent
* *) in the case of network errors:
* «failed to open stream: A connection attempt failed
* because the connected party did not properly respond after a period of time,
* or established connection failed because connected host has failed to respond.»
* https://www.php.net/manual/function.file-get-contents.php#refsect1-function.file-get-contents-errors
* That is why I use the silence operator.
* 2023-07-16
* «file_get_contents(): Passing null to parameter #2 ($use_include_path) of type bool is deprecated
* in vendor/mage2pro/core/Framework/lib/fs/contents.php on line 36»:
* https://github.com/mage2pro/core/issues/230
*/
function() use ($f, $rs):string {return df_assert_ne(false, @file_get_contents($f, false, $rs));}
,true !== $onE ? $onE : function() use ($f) {df_error(
'Unable to read the %s «%s».', df_check_url($f) ? 'URL' : 'file', $f
);}
);}
function df_contents(string $f, $onE = true, $rs = null):string {
# 2023-07-26 "`df_contents()` should accept internal paths": https://github.com/mage2pro/core/issues/273
if (!df_check_url($f)) {
$f = df_path_abs($f);
}
return df_try(
/**
* 2015-11-27
* Обратите внимание, что для использования @uses file_get_contents
* с адресами https требуется расширение php_openssl интерпретатора PHP,
* однако оно является системным требованием Magento 2:
* http://devdocs.magento.com/guides/v2.0/install-gde/system-requirements.html#required-php-extensions
* Поэтому мы вправе использовать здесь @uses file_get_contents
* 2016-05-31, 2022-10-14
* file_get_contents() could generate @see E_WARNING: e.g.:
* *) if the file is absent
* *) in the case of network errors:
* «failed to open stream: A connection attempt failed
* because the connected party did not properly respond after a period of time,
* or established connection failed because connected host has failed to respond.»
* https://www.php.net/manual/function.file-get-contents.php#refsect1-function.file-get-contents-errors
* That is why I use the silence operator.
* 2023-07-16
* «file_get_contents(): Passing null to parameter #2 ($use_include_path) of type bool is deprecated
* in vendor/mage2pro/core/Framework/lib/fs/contents.php on line 36»:
* https://github.com/mage2pro/core/issues/230
*/
function() use ($f, $rs):string {return df_assert_ne(false, @file_get_contents($f, false, $rs));}
,true !== $onE ? $onE : function() use ($f) {df_error(
'Unable to read the %s «%s».', df_check_url($f) ? 'URL' : 'file', $f
);}
);
}
2 changes: 2 additions & 0 deletions Framework/lib/fs/path/abs-rel.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ function df_adjust_paths_in_message(string $m):string {
/**
* 2023-07-25 "`df_path_absolute()` is wrongly implemented": https://github.com/mage2pro/core/issues/270
* @see df_sys_path_abs()
* @used-by df_contents()
* @used-by df_module_name_by_path()
*/
function df_path_abs(string $p):string {
$bp = df_path_n(BP);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage2pro/core"
,"version": "9.9.7"
,"version": "9.9.8"
,"description": "Mage2.PRO core package."
,"type": "magento2-module"
,"homepage": "https://mage2.pro"
Expand Down

0 comments on commit a89de19

Please sign in to comment.