eu – Ryanair using “unauthorised screen scraper” argument to refuse refund

I had a return flight (booked on the 29th of Oct) with Ryanair that was moved from Dec 1. to Dec. 3 and subsequently cancelled. I requested a refund after the cancellation, and received an e-mail a few days after confirming that I, through their website, could get my cash refund.

When I go on the website and provide my e-mail and booking reference, they reject my application and provide the following reason:

“This booking has been identified as one purchased through an unauthorised screen scraper. In order to request a cash refund, the customer must complete our customer verification process. Please click here to complete the form.”

The problem is, the above is a complete fabrication – I have never booked any flight, ever, via anything but the corresponding airline websites, and I can see in my history that I went through the entire booking process with Ryanair.com!

To move forward they require that I fill out a demanding ‘customer verification form’, but this requires that I confirm which online travel agency (OTA) I used, but as noted, I never did. I guess they hope that I try to fill it out, allowing them subsequently to invalidate my claim by accusing me of falsifying my verification form. From my viewpoint it appears they actively are trying to defraud me, or hope I do something dumb.

I paid via MasterCard. It is impossible to get through to their customer service. What do you suggest? I don’t want a voucher – I only used Ryanair because they – due to CoVID – were the only direct option via my local airport.

java – Mutating input List method argument to add new item

I really don’t like the idea of method (especially public) mutating state of input argument. I been thinking to see what will be the better way of achieving this without violatation.

I wrote a sample code to compare two ways of updating list (There are other ways of doing this and I am interested in understanding Java 8 approach to handle this).

Question: The approach used in method addItemToListUsingConsumerWithPredicate can be considered as not mutating the state of input param?

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Predicate;

class Scratch {
    public static void main(String() args) {
            new Scratch().testTraditionalForEach();
            new Scratch().addItemToListUsingConsumerWithPredicate();
    }

private void addItemToListUsingConsumerWithPredicate() {

    List<String> inputList = new ArrayList<>();
    inputList.add("one");
    inputList.add("two");
    inputList.add("three");
    List<String> newList = new ArrayList<>();
    newList.add("one");
    newList.add("four");
    newList.add("three");


    newList.stream().forEach(nl -> {
        addIfNotPresentUsingConsumerAndPredicate(nl, p -> !inputList.contains(nl), inputList, x -> inputList.add(nl));
    });
    System.out.println("addItemToListUsingConsumerWithPredicate = " + inputList);

}

private void addIfNotPresentUsingConsumerAndPredicate(String nl, Predicate<String> predicate, List<String> inputList, Consumer<List<String>> listConsumer) {
    if (predicate.test(nl)){
        listConsumer.accept(inputList);
    }
}

 private void testTraditionalForEach() {

    List<String> inputList = new ArrayList<>();
    inputList.add("one");
    inputList.add("two");
    inputList.add("three");
    List<String> newList = new ArrayList<>();
    newList.add("one");
    newList.add("four");
    newList.add("three");

    newList.stream().forEach(nl -> addIfNotPresent(nl, inputList));
    System.out.println("testTraditionalForEach =" + inputList);

}

private void addIfNotPresent(String nl, List<String> inputList) {

    if(!inputList.contains(nl)){
        inputList.add(nl);
    }

}

}

get pages – invalid argument in foreach when trying to list custom post types in archive.php

I try to list pages of custom post type in archive.php, and I get this error message:

Invalid argument supplied for foreach()

$post_type = get_post_type( get_the_ID() );
$pages = get_pages(array( 'post_type' => $post_type ) );
    foreach ($pages as $page ) {
        echo '<div class = "prop-sidebar-section">';
        echo $page->post_title;
        echo '</div>';
    }

the weird thing is, that with get_pages(array( 'post_type' => 'page'); is working, and if I use get_pages(array( 'post_type' => 'post') ); is not.

php – invalid argument: invalid transport DSN

Olá!
Estou iniciando um projeto com mercure (https://github.com/dunglas/mercure 0.10.4) no symfony (5.1) mercure bundle (0.4.0)
Máquina Windows virtualizando Ubuntu (scotch box) com vagrant (apache 2.4.18).

Passos (os mesmos da documentação):

1 – download mercure.rocks v0.10.4

2 – coloquei na pasta /bin

3 – na raiz do projeto composer req mercure

Quando tento o comando:

> JWT_KEY='aVerySecretKey' ADDR='localhost:3000' ALLOW_ANONYMOUS=1 ./bin/mercure

Estou recebendo o erro:

> bolt://updates.db": invalid argument: invalid transport DSN

Alguém que já passou por isso?

graph isomorphism: Simple argument why it is not NP-complete

I need to provide one simple evidence that graph isomorphism is not NP-complete.

I saw a number of papers on google scholar and answers on StackExchange. However, I have very limited knowledge of graph isomorphism, and I would like to just provide one simple evidence which I both understand and can explain clearly.

Below is what I can think of. Is this a valid argument?

Currently, we can solve GI in Quasipolynomial Time. If GI is NP-complete, then we should be able to solve other NP-complete problems in Quasipolynomial Time as well. However, right now, we are unable to solve any NP-complete problem in Quasipolynomial Time. Therefore, GI cannot be in np-complete.

magento2 – Argument X __construct() must implement interface xx

I’ve created a Console command that imports customers from a json file. It works fine, Magento generates the classes correctly when executing setup:di:compile.

But I get constantly the error:

Type Error occurred when creating object: BrildorMigrationConsoleCommandImportCustomersInterceptor, Argument 4 passed to BrildorMigrationConsoleCommandImportCustomers::__construct() must implement interface MagentoCustomerApiAddressRepositoryInterface, ins  
tance of MagentoCustomerModelResourceModelCustomerRepositoryInterceptor given, called in /var/www/html/generated/code/Brildor/Migration/Console/Command/ImportCustomers/Interceptor.php on line 14

I’m using Magento 2.4.1 and PHP 7.4.

I’m obliged to execute bin/magento setup:di:compile everytime to get rid of this error. My module is very simple:

etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoCatalogModelCategoryDataProvider">
        <plugin name="categoryCustomAttributes" type="ModuleMigrationPluginModelCategoryDataProvider" sortOrder="1" disabled="false"/>
    </type>
    <type name="MagentoFrameworkConsoleCommandListInterface">
        <arguments>
            <argument name="commands" xsi:type="array">
                <item name="import_customers" xsi:type="object">ModuleMigrationConsoleCommandImportCustomers</item>
            </argument>
        </arguments>
    </type>
</config>

Console/Command/ImportCustomers.php

<?php
/**
 * Copyright ©  All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace ModuleMigrationConsoleCommand;

use JsonMachineJsonMachine;
use MagentoCustomerApiAccountManagementInterface;
use MagentoCustomerApiCustomerRepositoryInterface;
use MagentoCustomerApiDataCustomerInterface;
use MagentoCustomerApiDataCustomerInterfaceFactory;
use MagentoCustomerApiDataAddressInterfaceFactory;
use MagentoCustomerApiDataAddressExtensionFactory;
use MagentoFrameworkApiSearchCriteriaBuilder;
use MagentoCustomerModelCustomer;
use MagentoCustomerApiAddressRepositoryInterface;
use MagentoFrameworkApiDataObjectHelper;
use MagentoFrameworkAppResourceConnection;
use MagentoFrameworkExceptionInputException;
use MagentoFrameworkExceptionLocalizedException;
use MagentoFrameworkExceptionNoSuchEntityException;
use MagentoFrameworkExceptionStateInputMismatchException;
use MagentoFrameworkFilesystemDirectoryList;
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputInterface;
use SymfonyComponentConsoleInputInputOption;
use SymfonyComponentConsoleOutputOutputInterface;

class ImportCustomers extends Command
{
    const FILE_OPTION = "file";
    private DirectoryList $directoryList;
    protected CustomerInterfaceFactory $customerFactory;
    protected CustomerRepositoryInterface $customerRepository;
    protected AddressInterfaceFactory $customerAddressFactory;
    protected AddressExtensionFactory $customerAddressExtensionFactory;
    protected AddressRepositoryInterface $customerAddressRepository;
    private DataObjectHelper $dataObjectHelper;
    private AccountManagementInterface $accountManagement;
    private int $count;
    private array $referers = (
        'Google' => '3806',
        'Youtube' => '3807',
        'Facebook' => '3809',
        'Instagram' => '3810',
        'C!Print' => '3812',
        'Recomendación' => '3811'
    );
    private array $allowedCountries = (
        'AL', 'AD', 'AM', 'AT', 'AZ', 'BY', 'BE', 'BA', 'BG', 'CA', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'GE', 'DE', 'GI', 'GR', 'HU',
        'IS', 'IE', 'IT', 'LV', 'LI', 'LT', 'LU', 'MT', 'MD', 'MC', 'ME', 'NL', 'MK', 'NO', 'PL', 'PT', 'RO', 'RU', 'RS', 'SK', 'SI', 'ES',
        'SE', 'CH', 'TR', 'UA', 'GB', 'US', 'VA',
    );
    private SearchCriteriaBuilder $searchCriteriaBuilder;
    /**
     * @var Customer
     */
    private Customer $customer;
    private int $countcompare;
    /**
     * @var ResourceConnection
     */
    private ResourceConnection $resource;

    /**
     * ImportProducts constructor.
     * @param DirectoryList $directoryList
     * @param ResourceConnection $resource
     * @param CustomerInterfaceFactory $customerFactory
     * @param AddressRepositoryInterface $customerAddressRepository
     * @param AddressExtensionFactory $customerAddressExtensionFactory
     * @param CustomerRepositoryInterface $customerRepository
     * @param AddressInterfaceFactory $customerAddressFactory
     * @param SearchCriteriaBuilder $searchCriteriaBuilder
     * @param DataObjectHelper $dataObjectHelper
     * @param AccountManagementInterface $accountManagement
     * @param Customer $customer
     */
    public function __construct(
        DirectoryList $directoryList,
        ResourceConnection $resource,
        CustomerInterfaceFactory $customerFactory,
        AddressRepositoryInterface $customerAddressRepository,
        AddressExtensionFactory $customerAddressExtensionFactory,
        CustomerRepositoryInterface $customerRepository,
        AddressInterfaceFactory $customerAddressFactory,
        SearchCriteriaBuilder $searchCriteriaBuilder,
        DataObjectHelper $dataObjectHelper,
        AccountManagementInterface $accountManagement,
        Customer $customer
    )
    {
        $this->directoryList = $directoryList;
        $this->resource = $resource;
        $this->count = 0;
        $this->countcompare = 0;
        $this->customerFactory = $customerFactory;
        $this->customerAddressFactory = $customerAddressFactory;
        $this->customerAddressExtensionFactory = $customerAddressExtensionFactory;
        $this->customerAddressRepository = $customerAddressRepository;
        $this->searchCriteriaBuilder = $searchCriteriaBuilder;
        $this->customerRepository = $customerRepository;
        $this->dataObjectHelper = $dataObjectHelper;
        $this->accountManagement = $accountManagement;
        $this->customer = $customer;

        parent::__construct();
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(
        InputInterface $input,
        OutputInterface $output
    )
    {
        $file = $input->getOption(self::FILE_OPTION);
        $dir = $this->directoryList->getRoot();

        if ($file) {
            $customersData = JsonMachine::fromFile($dir . "https://magento.stackexchange.com/" . $file);

            if ($customersData) {
                $this->importCustomers($customersData);
            }
        } else {
            echo 'File is missing: please introduce a file parameter with -f' . "n";
        }
    }

    public function deleteCustomers($customersData)
    {
        $searchCriteria = $this->searchCriteriaBuilder->create();
        $result = $this->customerRepository->getList($searchCriteria);

        if (count($result->getItems()) > 0) {
            foreach ($result->getItems() as $customer) {
                $customerId = $customer->getId();
                $this->customerRepository->deleteById($customerId);
            }
        }
    }

    public function importCustomers($customersData)
    {
        foreach ($customersData as $customerData) {
            $this->count++;
            $this->createCustomerAccount($customerData);
        }
    }

    public function createCustomerAccount($customerData)
    {
        /*if ($customerData('email') != 'laranxocreacions@gmail.com') {
            return;
        }*/
        try {
            $customer = $this->customerRepository->get($customerData('email'));
            echo 'Customer with email: ' . $customerData('email') . " exists. Updating and recreating addresses...n";
        } catch (NoSuchEntityException $e) {
            echo 'There is no customer with email: ' . $customerData('email') . "n";
            $customer = $this->customerFactory->create();

            echo 'Name and email: ' . $customerData('firstname') . ' -- ' . $customerData('email') . "n";

            //$customer->setData(CustomerInterface::ID, $customerData('old_id'));
            $customer->setData(CustomerInterface::EMAIL, $customerData('email'));
            $customer->setData(CustomerInterface::WEBSITE_ID, $customerData('website_id'));
            $customer->setData(CustomerInterface::STORE_ID, $customerData('sendemail_store_id'));
            $customer->setData(CustomerInterface::FIRSTNAME, $customerData('firstname'));
            $customer->setData(CustomerInterface::LASTNAME, $customerData('lastname'));
            $customer->setData(CustomerInterface::GROUP_ID, 1);
            $customer->setData(CustomerInterface::CREATED_AT, $customerData('created_at'));
            $customer->setData(CustomerInterface::UPDATED_AT, $customerData('updated_at'));
            $customer->setData(CustomerInterface::TAXVAT, $customerData('taxvat'));

            $customer->setCustomAttribute('old_id', $customerData('old_id'));
            $customAttributesData = (
                'old_id' => $customerData('old_id'),
                'company' => $customerData('empresa'),
                'account_manager' => $customerData('account_manager'),
                'business_info' => $customerData('info_negocio'),
                'job_description' => $customerData('cargo'),
                'tax_exempt' => $customerData('free_tax'),
                'admin' => $customerData('administrador'),
                'referer' => ($customerData('where_meet_us') != '') ? $this->referers($customerData('where_meet_us')) : '',
                'website' => $customerData('webpage')
            );

            foreach ($customAttributesData as $code => $customAttributesDatum) {
                $customer->setCustomAttribute($code, $customAttributesDatum);
            }

            try {
                $customer = $this->customerRepository->save($customer);
            } catch (InputException $e) {
            } catch (InputMismatchException $e) {
            } catch (LocalizedException $e) {
                $customer = $this->customer->setWebsiteId(0)->loadByEmail($customerData('email'));
            }
        } catch (LocalizedException $e) {
            var_dump($e->getMessage());
        }

        // Update Password Hash
        $customerId = $customer->getId();
        $hash = $customerData('password_hash');
        $connection = $this->resource->getConnection(MagentoFrameworkAppResourceConnection::DEFAULT_CONNECTION);
        $connection->query("UPDATE customer_entity SET password_hash = '$hash' WHERE entity_id = '$customerId'");

        // Save customer addresses
        if ($customerData('addresses')) {
            $this->deleteAllCustomerAddresses($customerId);

            $addresses = $this->cleanDuplicatedAddresses($customerData('addresses'));
            foreach ($addresses as $addressData) {
                $this->saveCustomerAddress($addressData, $customerId);
            }
        }
    }

    public function cleanDuplicatedAddresses($addresses)
    {
        $attributesToCompare = array('vat_id', 'firstname', 'lastname', 'company', 'city', 'region', 'postcode', 'country_id', 'fax', 'region_id', 'street');
        $dontCheck = array();
        foreach ($addresses as $key => $address) {
            //var_dump('Key ' . $key);
            //var_dump($checked);
            $checkForDuplicates = false;
            if (!isset($dontCheck($key))) {
                $checkForDuplicates = true;
            } else {
                if (!$dontCheck($key)) {
                    $checkForDuplicates = true;
                }
            }

            if ($checkForDuplicates) {
                foreach ($addresses as $subkey => $subaddress) {
                    $dontCheck($subkey) = 0;
                    if ($key != $subkey && $subaddress('country_id')) {
                        //var_dump('Subkey: ' . $subkey);
                        $equal = true;
                        foreach ($attributesToCompare as $attributeToCompare) {
                            if (isset($subaddress($attributeToCompare)) && isset($address($attributeToCompare))) {
                                if ($subaddress($attributeToCompare) != $address($attributeToCompare)) {
                                    $equal = false;
                                }
                            }

                            if (isset($subaddress($attributeToCompare)) && !isset($address($attributeToCompare))) {
                                if ($subaddress($attributeToCompare) != '') {
                                    $equal = false;
                                } else {
                                    $equal = true;
                                }
                            }

                            if (isset($address($attributeToCompare)) && !isset($subaddress($attributeToCompare))) {
                                if ($address($attributeToCompare) != '') {
                                    $equal = false;
                                } else {
                                    $equal = true;
                                }
                            }
                        }

                        if ($equal) {
                            $dontCheck($subkey) = 1;
                            //echo 'Address are equal' . "n";
                            if (isset($subaddress('default_shipping'))) {
                                $addresses($key)('default_shipping') = '1';
                            }
                            if (isset($subaddress('default_billing'))) {
                                $addresses($key)('default_billing') = '1';
                            }
                            unset($addresses($subkey));
                            continue;
                        }
                    }
                }
            }
        }

        return $addresses;
    }

    public function deleteAllCustomerAddresses($customerId)
    {
        $searchCriteria = $this->searchCriteriaBuilder->addFilter('parent_id', $customerId, 'eq')->create();
        $result = $this->customerAddressRepository->getList($searchCriteria);

        foreach ($result->getItems() as $address) {
            $this->customerAddressRepository->deleteById($address->getId());
        }
    }

    public function saveCustomerAddress($addressData, $customerId)
    {
        if (isset($addressData('country_id')) && isset($addressData('firstname')) && isset($addressData('city')) && isset($addressData('street'))) {
            if (in_array($addressData('country_id'), $this->allowedCountries)) {
                $address = $this->customerAddressFactory->create();
                if (!isset($addressData('telephone'))) {
                    $addressData('telephone') = '';
                }
                $addressData('street_array') = explode("n", $addressData('street'));

                $telephone = $addressData('telephone');
                if (isset($addressData('fax'))) {
                    if ($addressData('fax') != '') {
                        $telephone = $addressData('fax');
                    }
                }

                $vatId = '';
                if (isset($addressData('vat_id'))) {
                    $vatId = $addressData('vat_id');
                }

                if ($addressData('country_id') == 'PT' && isset($addressData('region'))) {
                    $region = $addressData('region');
                    $connection = $this->resource->getConnection(MagentoFrameworkAppResourceConnection::DEFAULT_CONNECTION);
                    $addressData('region_id') = $connection->fetchOne("SELECT region_id FROM directory_country_region WHERE code = '$region'");
                }

                $address->setCustomerId($customerId)
                    ->setFirstname($addressData('firstname'))
                    ->setLastname($addressData('lastname'))
                    ->setCountryId($addressData('country_id'))
                    ->setPostcode($addressData('postcode'))
                    ->setCity($addressData('city'))
                    ->setTelephone($telephone)
                    ->setVatId($vatId)
                    ->setCustomAttribute('landline', $addressData('telephone'))
                    ->setStreet($addressData('street_array'));

                if (isset($addressData('default_billing'))) {
                    $address->setIsDefaultBilling($addressData('default_billing'));
                }

                if (isset($addressData('region_id')) && $addressData('country_id') == 'ES') {
                    $address->setRegionId($addressData('region_id'));
                }

                if (isset($addressData('default_shipping'))) {
                    $address->setIsDefaultShipping($addressData('default_shipping'));
                }

                try {
                    $this->customerAddressRepository->save($address);
                } catch (LocalizedException $e) {
                    var_dump($e->getMessage());
                    echo 'Trying again...' . "n";
                    sleep(5);
                    $this->saveCustomerAddress($addressData, $customerId);
                }
            }
        }
    }

    /**
     * Fill in customer entity using array of customer data and additional customer data.
     *
     * @param array $customerData
     * @param array $additionalCustomerData
     * @param CustomerInterface|null $customerEntity
     * @return CustomerInterface
     */
    private function populateCustomerEntity(
        array $customerData,
        ?CustomerInterface $customerEntity = null
    ): CustomerInterface
    {
        $customerEntity = $customerEntity ?? $this->customerFactory->create();
        $this->dataObjectHelper->populateWithArray(
            $customerEntity,
            $customerData,
            CustomerInterface::class
        );

        return $customerEntity;
    }

    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this->setName("custom_migration:import_customers");
        $this->setDescription("Import Customers from a json file");
        $this->setDefinition((
            new InputOption(self::FILE_OPTION, "-f", InputOption::VALUE_REQUIRED, "File name")
        ));
        parent::configure();
    }
}

Any idea why this error happens again and again?

"[warning] Invalid argument supplied for foreach() Migration.php:641"

Why does this error appear when I use the drush ms command?

(warning) Invalid argument supplied for foreach() Migration.php:641

argument patterns – passing splice instructions

Consider some passing splice instructions using start,stop,step pattern

r`data = Range@10;
r`f[data_, start_: 1, stop_: - 1, every_: 1] :=
 Module[{},
  data[[start ;; stop ;; every]] 
 ]
  1. Is there a performance penalty if the splice is effectively a non-splice i.e. [[1;;-1;;1]] or [[1;;;;1]] or [[;;Length@data;;]] etc compared to say returning data? The reason I ask is if so, must I specifically skip splicing in such casses?

  2. Consider the case when multiple splice instrcutions have to be passed: start1,stop1,step1, start2,stop2,step2…. How to structure this compactly in func arguments? e.g. is there something better than r`f[data_, splice1_:{-1,1,1},...]

c – Passing a string to a function (selectionSort), shows the error: passing argument 1 of ‘selectionSort’ from incompatible pointer type

I crated a function that sort n strings in an array. When I do not use parameters the function works, but if I pass my array of strings (strings) deploy a warning: argument 1 of ‘selectionSort’ from incompatible pointer type.

I called the function in main:

selectionSort(strings, numStrings);

The function:

void selectionSort(char strings(), int numStrings)
{
     char sinString(25) //25 is the limit for the string
     for(int i = 0; i <= numStrings - 1; ++i)
     {
       for(int j = 1 + i; j <= numStrigs; ++j)
         if(strcmp(strings(i), strings(j)) > 0)
         {
           strcpy(sinString, strings(j));
           strcpy(strings(j), strings(i));
           strcpy(strings(i), sinString);
         }

     }  
}

8 – How to use a contextual filter argument (term ID) in a View page title?

This question asks how to use a Views contextual filter argument as the title when using a Taxonomy Term: Name filter.

My question is how to set the name of a view page to a contextual filter argument when using a Content: Has taxonomy term ID filter.

My View looks like this.

Type: Page

Path: /groups/%

Contextual filter:

  • (field_ref_term_group) Content: Has taxonomy term ID
  • When the filter value is NOT in the URL: Show “Page not found”
  • When the filter value IS in the URL: Specify validation criteria (Taxonomy term ID)

Relationships: Relate each Content with a field_ref_term_group set to the taxonomy term., required

Fields: Taxonomy term: Name (hiddden), Link to the Taxonomy term is unchecked

I then set the View title to {{ name }}. After saving and clearing the cache and navigating to the view path (/groups/4), then I see the page title as {{ name }} instead of the name of term 4.

How can I print the actual term name as the View title when using a Content: Has taxonomy term ID relationship?