Skip to content

Commit

Permalink
PHP 7.4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
twiro committed Jul 7, 2021
1 parent b16a678 commit c197acd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions extension.meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
</author>
</authors>
<releases>
<release version="1.3.1" date="2019-03-13" min="2.4.x" max="2.7.x">
* Tested with PHP 7.2
<release version="1.3.1" date="2021-07-07" min="2.4.x" max="2.7.x">
* PHP 7.4 compatibility
</release>
<release version="1.3.0" date="2018-07-10" min="2.4.x" max="2.7.x">
* PHP7 compatibility
Expand Down
17 changes: 9 additions & 8 deletions fields/field.reflectedupload.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,10 @@ public function compile($entry)
if(empty($old_value['file'])){
return true;
}
preg_match("/([^\/]*)(\.[^\.]+)/e" , $old_value['file'] , $oldMatches);
$old_filename = $oldMatches[1];
$file_extension = $oldMatches[2];

// Fetch filename and extension from the old file
$old_filename = pathinfo($old_value['file'], PATHINFO_FILENAME);
$file_extension = pathinfo($old_value['file'], PATHINFO_EXTENSION);

// Find queries:
preg_match_all('/\{[^\}]+\}/' , $expression , $matches);
Expand All @@ -260,17 +261,17 @@ public function compile($entry)
$expression
);

if($unique){
$new_value = $value . '-' . uniqid() . $file_extension;
}else{
$new_value = $value . $file_extension;
if ($unique) {
$new_value = $value . '-' . uniqid() . '.' . $file_extension;
} else {
$new_value = $value . '.' . $file_extension;
}
$new_value = Lang::createFilename($new_value);

$abs_path = DOCROOT . '/' . trim($this->get('destination') , '/');
$rel_path = str_replace('/workspace' , '' , $this->get('destination'));

$old = $abs_path . '/' . $old_filename . $file_extension;
$old = $abs_path . '/' . $old_filename . '.' . $file_extension;
$new = $abs_path . '/' . $new_value;

if (rename($old , $new)) {
Expand Down

0 comments on commit c197acd

Please sign in to comment.