Problem with install security patch in magento 2.2.7 - composer-php

I want to install a patch to my project
Patch like this:
Index: vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- vendor/magento/framework/DB/Adapter/Pdo/Mysql.php (revision 6a8701ca9402697f5eaf022e35b9217d3281546c)
+++ vendor/magento/framework/DB/Adapter/Pdo/Mysql.php (date 1553502112000)
## -2904,7 +2904,7 ##
if (isset($condition['to'])) {
$query .= empty($query) ? '' : ' AND ';
$to = $this->_prepareSqlDateCondition($condition, 'to');
- $query = $this->_prepareQuotedSqlCondition($query . $conditionKeyMap['to'], $to, $fieldName);
+ $query = $query . $this->_prepareQuotedSqlCondition($conditionKeyMap['to'], $to, $fieldName);
}
} elseif (array_key_exists($key, $conditionKeyMap)) {
$value = $condition[$key];
I also added to the composer:
"extra": {
"magento-force": "override",
"patches": {
"magento/framework": {
"Fix: PRODSECBUG-2198":
"patches/composer/magento/framework/PRODSECBUG2198.patch"
}
}
}
When I try to run composer install then return this error:
Could not apply patch! Skipping. The error was: Cannot apply patch patches/composer/magento/framework/PRODSECBUG2198.patch
Project for Magento 2.2.7, I installed cweagans/composer-patches but still have problem. Someone can help?

I don't have too much experience with the patches package, but in one of our project, we use it too. In the patch file, the location to the files to be patched is given relative to the package root. So, if you want to patch something in magento/framework, your patch file should probably use DB/Adapter/Pdo/Mysql.php as the filenames

Related

Laravel and php wrapper for youtube-dl norkunas / youtube-dl-php

I'm using Laravel Version 6.14.0 and I wanted to use the following Youtube-dl wrapper for PHP from https://github.com/norkunas/youtube-dl-php in Laravel.
I used the command composer require norkunas/youtube-dl-php to install it and I got the following output :
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
- Installing symfony/options-resolver (v4.4.4): Downloading (100%)
- Installing norkunas/youtube-dl-php (v1.4.0): Downloading (100%)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
This is what my Controller looks like
<?php
namespace App\Http\Controllers;
use App\YtScreen;
use Illuminate\Http\Request;
use YoutubeDl\YoutubeDl;
use YoutubeDl\Exception\CopyrightException;
use YoutubeDl\Exception\NotFoundException;
use YoutubeDl\Exception\PrivateVideoException;
class YtScreenController extends Controller
{
public function frontpage()
{
$dl = new YoutubeDl([
'continue' => true, // force resume of partially downloaded files. By default, youtube-dl will resume downloads if possible.
'format' => 'bestvideo',
]);
// For more options go to https://github.com/rg3/youtube-dl#user-content-options
$dl->setDownloadPath('/home/user/downloads');
// Enable debugging
$dl->debug(function ($type, $buffer) {
if (\Symfony\Component\Process\Process::ERR === $type) {
echo 'ERR > ' . $buffer;
} else {
echo 'OUT > ' . $buffer;
}
});
try {
$video = $dl->download('https://www.youtube.com/watch?v=oDAw7vW7H0c');
echo $video->getTitle(); // Will return Phonebloks
// $video->getFile(); // \SplFileInfo instance of downloaded file
} catch (NotFoundException $e) {
// Video not found
} catch (PrivateVideoException $e) {
// Video is private
} catch (CopyrightException $e) {
// The YouTube account associated with this video has been terminated due to multiple third-party notifications of copyright infringement
} catch (\Exception $e) {
// Failed to download
}
return view("frontpage");
}
}
The problem is that the newly installed php wrapper doesn't work at all. I don't even get an error message. No video gets downloaded, no error message is shown ... nothing happens. The controller itself is fine , I tested it with a different function.
I assume I didn't include the files correctly since I don't even get an error message. Has anyone made a similiar expirience and knows how to get this php wrapper for youtube-dl to work in Laravel? Or maybe has an alternative idea for a different youtube-dl php wrapper.

Puppet Install specific version of package depending on application version

I have a module which installs my Application.
To install system packages i'm using virtual resource:
#package {[
'unzip',
'wget',
'htop',
'xorg-x11-server-Xvfb']:
ensure => installed,
}
define myapp1_packages {
realize(
Package['unzip'],
Package['fontconfig'],
Package['libfreetype.so.6'])
}
#myapp1_packages{ 'myapp1_packages': }
Then I use realize in my manifest to install the above packages:
realize(myapp1_packages['myapp1_packages'])
But for each version of my application I also need appropriate versions of system packages.
I need something like that:
if $app_version == '1.0' {
"install unzip-1xx"
"install fontconfig-1-xx"
"install libfreetype.so.6-1-x-xx"
elseif $app_version == '2.0'
"install unzip-2xx"
"install fontconfig-2-xx"
"install libfreetype.so.6-2-x-xx"
What is most elegant way to do this? And is it possible to keep virtual resources in that case? I'm looking to use ensure_packages but i worried about resource duplication. Thanks for the help!
The best thing to do here is to make $app_version a parameter for your module: https://docs.puppet.com/puppet/4.10/lang_classes.html#class-parameters-and-variables. Note an example from the documentation here: https://docs.puppet.com/puppet/4.10/lang_classes.html#appendix-smart-parameter-defaults.
For your situation, the class would look like:
myclass($app_version = 'default version') {
if $app_version == '1.0' {
#package { 'unzip': ensure => '1xx' }
#package { 'fontconfig': ensure => '1-xx' }
#package { 'libfreetype': ensure => '6-1-xx' }
}
elsif $app_version == '2.0' {
#package { 'unzip': ensure => '2xx' }
#package { 'fontconfig': ensure => '2-xx' }
#package { 'libfreetype': ensure => '6-2-xx' }
}
}
thus also allowing you to retain your virtual resources.
You can then pass parameters to this class by declaring it like:
class { 'myclass': app_version => '2.0' }
or using automatic data bindings with hieradata:
# puppet manifest
include myclass
# hieradata
myclass::app_version: 2.0
Your collector elsewhere will then realize the correct versions for your packages.

Laravel 5.3 response()->download - File(.doc, .docx) becomes unreadable after downloading

Laravel 5.3
When I download a file (.doc, .docx) from my storage folder it becomes unreadable. If I go to the local folder and open the file however it is valid and readable.
I am using the standard download function, using headers and stuff.. Have a look at my code:
$fileNameGenerate = 'example_filename';
$fileArr = [ 'wierd_filename', 'docx' ];
$cvPath = storage_path('app/example_folder/subfolder/wierd_filename.docx');
$headers = array(
'Content-Type: application/' . $fileArr[1],
);
try {
return response()->download($cvPath, $fileNameGenerate . '.' . $fileArr[1], $headers);
} catch (\Exception $e) {
//Error
return redirect()->back()->with('error', trans('locale.file_does_not_exists'));
}
Does anyone know what is wrong here? Thank you!
Update: I removed headers, it doesn't work with or without them.
Here is how the files render in the 2 different cases:
Try this
public function getDownload()
{
//doc file is stored under storagepath/download/info.docx
$file= pathofstorage. "/download/info.docx";
return response()->download($file);
}
I added:
ob_end_clean();
before:
response -> download
and it worked for me.

cakephp 3.0 recaptcha installation

I try to use recaptcha with cakePHP 3.0, but I experience some errors probably dues to a wrong installation.
I work on Windows with composer.
I've add the following lines to composer.json file :
"require": {
(...)
"google/recaptcha": "~1.1"
},
"autoload": {
"psr-4": {
(...)
"ReCaptcha\\": "/vendor/google/recaptcha/src/ReCaptcha"
}
},
Then I execute composer cmd to install the plugin:
composer update
composer install
composer dumpautoload
Finally, I test the plugin in a view :
<?php
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
$resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp);
if ($resp->isSuccess()) {
// verified!
} else {
$errors = $resp->getErrorCodes();
}
?>
The result is an error throwed by cake :
"No secret provided (...) Could this be caused by using Auto-Tables? ..."
Did I correctly installed it ?
Did I miss or misunderstand something ?

Moved Laravel dir to root of server now composer update fails

I wanted the Laravel 4.1 package to be at the root of a particular web server so I took it out of it's "laravel" dir and moved it.
Used to be in: C:\www\mysite.dev\laravel
Now it is in: C:\www\mysite.dev
When I run composer update it chokes producing the error:
{"error":{"type":"ErrorException","message":"mkdir(): No such file or directory","file":"C:\\www\\mysite.dev\\vendor\\laravel\\framework\\src\\Illuminate\\Filesystem\\Filesystem.php","line":302}}
How can I configure composer.json to compensate for this change?
It seems like problem with permissions.
Line 302 of Filesystem.php is the following (in bold):
public function makeDirectory($path, $mode = 0777, $recursive = false, $force = false)
{
if ($force)
{
return #mkdir($path, $mode, $recursive);
}
else
{
302 return mkdir($path, $mode, $recursive);
}
}

Resources