File tree Expand file tree Collapse file tree 1 file changed +24
-6
lines changed
lib/internal/Magento/Framework/Filesystem/Driver Expand file tree Collapse file tree 1 file changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -701,18 +701,36 @@ public function fileClose($resource)
701
701
*/
702
702
public function fileWrite ($ resource , $ data )
703
703
{
704
- $ result = @fwrite ($ resource , $ data );
705
- if (false === $ result ) {
706
- throw new FileSystemException (
707
- new \Magento \Framework \Phrase (
704
+ $ lenData = strlen ($ data );
705
+ for ($ result = 0 ; $ result < $ lenData ; $ result += $ fwrite ) {
706
+ $ fwrite = @fwrite ($ resource , substr ($ data , $ result ));
707
+ if (0 === $ fwrite ) {
708
+ $ this ->fileSystemException ('Unable to write ' );
709
+ }
710
+ if (false === $ fwrite ) {
711
+ $ this ->fileSystemException (
708
712
'Error occurred during execution of fileWrite %1 ' ,
709
713
[$ this ->getWarningMessage ()]
710
- )
711
- );
714
+ );
715
+ }
712
716
}
717
+
713
718
return $ result ;
714
719
}
715
720
721
+ /**
722
+ * Throw a FileSystemException with a Phrase of message and optional arguments
723
+ *
724
+ * @param string $message
725
+ * @param array $arguments
726
+ * @return void
727
+ * @throws FileSystemException
728
+ */
729
+ private function fileSystemException ($ message , $ arguments = [])
730
+ {
731
+ throw new FileSystemException (new \Magento \Framework \Phrase ($ message , $ arguments ));
732
+ }
733
+
716
734
/**
717
735
* Writes one CSV row to the file.
718
736
*
You can’t perform that action at this time.
0 commit comments