fatal error: zconf.h: No such file or directory when I do have the file in the specified directory

I’m trying to make a code in PHP that I want uploaded on Google Cloud Run.
This is my Dockerfile:

# Use the official PHP image.
FROM php:8.2-apache

# Install necessary PHP extensions
RUN docker-php-ext-install -j "$(nproc)" opcache

# Set CPPFLAGS environment variable
ENV CPPFLAGS="-I/C:\zlib131zlib-1.3.1build"

# Install gRPC extension
RUN pecl install grpc && 
    docker-php-ext-enable grpc

# Configure PHP for Cloud Run
RUN echo "memory_limit = -1" > "$PHP_INI_DIR/conf.d/cloud-run.ini" && 
    echo "max_execution_time = 0" >> "$PHP_INI_DIR/conf.d/cloud-run.ini" && 
    echo "upload_max_filesize = 32M" >> "$PHP_INI_DIR/conf.d/cloud-run.ini" && 
    echo "post_max_size = 32M" >> "$PHP_INI_DIR/conf.d/cloud-run.ini" && 
    echo "opcache.enable = On" >> "$PHP_INI_DIR/conf.d/cloud-run.ini" && 
    echo "opcache.validate_timestamps = Off" >> "$PHP_INI_DIR/conf.d/cloud-run.ini" && 
    echo "opcache.memory_consumption = 32" >> "$PHP_INI_DIR/conf.d/cloud-run.ini"

# Copy in custom code from the host machine.
WORKDIR /var/www/html
COPY . .

# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Install Composer dependencies
RUN composer install --no-dev --optimize-autoloader

# Update Apache configuration to use pass_hash.php as the default file
RUN echo "DirectoryIndex loginAPI.php" >> /etc/apache2/apache2.conf

# Use the PORT environment variable in Apache configuration files
RUN sed -i "s/80/${PORT}/g" /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf

# Expose port 8080
EXPOSE 8080

# Start Apache in the foreground
CMD ["apache2-foreground"]

The problem appears when I use the following command in my terminal:
docker build -t loginapi .

And this is the error I get:

fatal error: zconf.h: No such file or directory
530.6    23 | #include <zconf.h>
530.6       |          ^~~~~~~~~
530.6 compilation terminated.
530.6 make: *** [Makefile:1455: src/core/lib/compression/message_compress.lo] Error 1
530.6 ERROR: `make' failed
------
Dockerfile:11
--------------------
  10 |     # Install gRPC extension
  11 | >>> RUN pecl install grpc && 
  12 | >>>     docker-php-ext-enable grpc
  13 |
--------------------
ERROR: failed to solve: process "/bin/sh -c pecl install grpc &&     docker-php-ext-enable grpc" did not complete successfully: exit code: 1

Thing is that I have the zconf.h file in my system and at the specified path, as you can see here: https://i.sstatic.net/gYiR9vJI.png

So I’m not sure what the real issue is. I’ve tried typing the path differently in the line ENV CPPFLAGS="-I/C:\zlib131zlib-1.3.1build" but nothing has changed.

  • IDE: VS Code
  • System: Windows 10

Symfony Valdidator does not work with nested AtLeastOneOf Constraint

In following code (condensed from a project) the validation for $constraint2 returns no error, which is not the behaviour I expect (should also return errors):

    use SymfonyComponentValidatorValidation;
    use SymfonyComponentValidatorConstraintsType;
    use SymfonyComponentValidatorConstraintsAtLeastOneOf;
    
    $config = 1; //Integer
    $constraint1 = new AtLeastOneOf([ new Type('string') ]);
    $constraint2 = new AtLeastOneOf([ new AtLeastOneOf([ new Type('string') ]) ]);
    
    $validator = Validation::createValidator();
    echo "Constraint 1: ".(count($validator->validate($config,$constraint1))).'<br>';
    echo "Constraint 2: ".(count($validator->validate($config,$constraint2))).'<br>';

Output:

Constraint 1: 1
Constraint 2: 0

The problem seems to be the nested AtLeastOneOf validator, but I do not understand why it does validate to no errors.

Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in G:PleskVhosts [duplicate]

Actually I am submitting a HTML form and when i filled the details and then click submit Two warnings appeared and one Fatal error (HTTP 500).

Warning: Undefined array key “country” in G:PleskVhosts…submit.php on line 30
Warning: Undefined array key “My_Vertical” in G:PleskVhosts…submit.php on line 36

Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in G:PleskVhosts…submit.php:37 Stack trace: #0 G:PleskVhosts…submit.php(37):implode()#1{main} thrown in G:PleskVhosts…submit.php on line 37

I am putting these statements in my code:-

$title = $_POST['titlea'];
$first_name = $_POST['first_name'];
$surname = $_POST['surname'];
$designation = $_POST['designation'];
$company_name = $_POST['company_name'];
$add1 = $_POST['add1'];
$add2 = $_POST['add2'];
$add3 = $_POST['add3'];
$city = $_POST['city'];
$state = $_POST['state'];
$pin = $_POST['pin'];
$country = $_POST['country'];  **//Line 30**
$telephone = $_POST['telephone'];
$fax = $_POST['fax'];
$mobile = $_POST['mobile'];
$email = $_POST['email'];
$website = $_POST['website'];
$My_Vertical = $_POST['My_Vertical'];    **//Line 36**
$Verticals = implode(",",$_POST["Vertical"]);    **//Line 37**
$Other_Vertical = $_POST['Vertical_others'];
$Information = implode(",",$_POST["Information"]);
$Other_Information = $_POST['others'];
$Objective = implode(",",$_POST["Objective"]);
$Other_Objective = $_POST['otherObjective'];

I am expecting that after submitting this form data should be updated in phpmyadmin database.

Shopware 6.6 plugin installation with composer dependency leads to an error

The installation worked flawless with Shopware 6.5 and whichbrowser/parser is the only dependency.

Shopware version: 6.6.3.0
Environment: dockware/dev:6.6.3.0 container

Required packages in the plugins composer.json

{
  "require": {
    "shopware/core": "^6.6.0.0",
    "whichbrowser/parser": "^v2.1.8"
  },
}

executeComposerCommands is enabled in the plugin base class

class MyPlugin extends Plugin
{
    public function executeComposerCommands(): bool
    {
        return true;
    }
}

The following error message gets thrown:

In FilesystemRepository.php line 166:                                                                                                                                                                                               
                                                                                                                                                                                                                                      
[ErrorException]                                                                                                                                                                                                                  
file_get_contents(/var/www/html/vendor/composer/composer/src/Composer/Repository/../InstalledVersions.php): Failed to open stream: No such file or directory    

The whole installation output:

[ShopwareCoreFrameworkPluginExceptionPluginComposerRequireException]                                                                                                                                                           
  Could not execute "composer require" for plugin "MyPlugin (my-plugin:2.3.0). Output:                                                                                                                                   
  ./composer.json has been updated                                                                                                                                                                                                    
  Running composer update my-plugin --with-all-dependencies                                                                                                                                                                    
  > pre-update-cmd: SymfonyFlexFlex_composer_tmp1->configureInstaller                                                                                                                                                               
  Loading composer repositories with package information                                                                                                                                                                              
  > pre-pool-create: SymfonyFlexFlex_composer_tmp1->truncatePackages                                                                                                                                                                
  Updating dependencies                                                                                                                                                                                                               
  Dependency resolution completed in 0.007 seconds                                                                                                                                                                                    
  Analyzed 624 packages to resolve dependencies                                                                                                                                                                                       
  Analyzed 2148 rules to resolve dependencies                                                                                                                                                                                         
  Lock file operations: 2 installs, 6 updates, 0 removals                                                                                                                                                                             
  Installs: whichbrowser/parser:v2.1.8, my-plugin:2.3.0                                                                                                                                                                        
  Updates: twig/twig:v3.8.0, zircote/swagger-php:4.10.0, twig/intl-extra:v3.8.0, shopware/conflicts:0.1.22, composer/class-map-generator:1.3.3, composer/composer:2.7.7                                                               
    - Locking my-plugin (2.3.0)                                                                                                                                                                                                
    - Upgrading composer/class-map-generator (1.3.2 => 1.3.3)                                                                                                                                                                         
    - Upgrading composer/composer (2.7.6 => 2.7.7)                                                                                                                                                                                    
    - Upgrading shopware/conflicts (0.1.20 => 0.1.22)                                                                                                                                                                                 
    - Downgrading twig/intl-extra (v3.10.0 => v3.8.0)                                                                                                                                                                                 
    - Downgrading twig/twig (v3.10.3 => v3.8.0)                                                                                                                                                                                       
    - Locking whichbrowser/parser (v2.1.8)                                                                                                                                                                                            
    - Upgrading zircote/swagger-php (4.9.3 => 4.10.0)                                                                                                                                                                                 
  Writing lock file                                                                                                                                                                                                                   
  Installing dependencies from lock file (including require-dev)                                                                                                                                                                      
  > pre-operations-exec: SymfonyFlexFlex_composer_tmp1->recordOperations                                                                                                                                                            
  Package operations: 2 installs, 6 updates, 0 removals                                                                                                                                                                               
  Installs: whichbrowser/parser:v2.1.8, my-plugin:2.3.0                                                                                                                                                                        
  Updates: zircote/swagger-php:4.10.0, twig/twig:v3.8.0, twig/intl-extra:v3.8.0, shopware/conflicts:0.1.22, composer/class-map-generator:1.3.3, composer/composer:2.7.7                                                               
    - Downloading whichbrowser/parser (v2.1.8)                                                                                                                                                                                        
    - Downloading zircote/swagger-php (4.10.0)                                                                                                                                                                                        
    - Downloading twig/twig (v3.8.0)                                                                                                                                                                                                  
    - Downloading twig/intl-extra (v3.8.0)                                                                                                                                                                                            
    - Downloading composer/class-map-generator (1.3.3)                                                                                                                                                                                
    - Downloading composer/composer (2.7.7)                                                                                                                                                                                           
   0/6 [>---------------------------]   0% < 1 sec                                                                                                                                                                                    
   3/6 [==============>-------------]  50%  1 sec                                                                                                                                                                                     
   6/6 [============================] 100%  1 sec                                                                                                                                                                                     
    - Installing whichbrowser/parser (v2.1.8): Extracting archive                                                                                                                                                                     
    - Upgrading zircote/swagger-php (4.9.3 => 4.10.0): Extracting archive                                                                                                                                                             
    - Downgrading twig/twig (v3.10.3 => v3.8.0): Extracting archive                                                                                                                                                                   
    - Downgrading twig/intl-extra (v3.10.0 => v3.8.0): Extracting archive                                                                                                                                                             
    - Upgrading shopware/conflicts (0.1.20 => 0.1.22)                                                                                                                                                                                 
    - Upgrading composer/class-map-generator (1.3.2 => 1.3.3): Extracting archive                                                                                                                                                     
    - Upgrading composer/composer (2.7.6 => 2.7.7): Extracting archive                                                                                                                                                                
    - Installing my-plugin (2.3.0): Symlinking from custom/plugins/MyPlugin                                                                                                                                              
   0/6 [>---------------------------]   0% < 1 sec                                                                                                                                                                                    
   5/6 [=======================>----]  83% < 1 sec                                                                                                                                                                                    
   6/6 [============================] 100% < 1 sec                                                                                                                                                                                    
  In FilesystemRepository.php line 166:                                                                                                                                                                                               
                                                                                                                                                                                                                                      
    [ErrorException]                                                                                                                                                                                                                  
    file_get_contents(/var/www/html/vendor/composer/composer/src/Composer/Repository/../InstalledVersions.php): Failed to open stream: No such file or directory                                                                      
                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                      
  Exception trace:                                                                                                                                                                                                                    
    at /var/www/html/vendor/composer/composer/src/Composer/Repository/FilesystemRepository.php:166                                                                                                                                    
   ComposerUtilErrorHandler::handle() at n/a:n/a                                                                                                                                                                                    
   file_get_contents() at /var/www/html/vendor/composer/composer/src/Composer/Repository/FilesystemRepository.php:166                                                                                                                 
   ComposerRepositoryFilesystemRepository->write() at /var/www/html/vendor/composer/composer/src/Composer/Installer/InstallationManager.php:381                                                                                     
   ComposerInstallerInstallationManager->ComposerInstaller{closure}() at /var/www/html/vendor/react/promise/src/FulfilledPromise.php:28                                                                                           
   ReactPromiseFulfilledPromise->then() at /var/www/html/vendor/react/promise/src/Promise.php:134                                                                                                                                   
   ReactPromisePromise::ReactPromise{closure}() at /var/www/html/vendor/react/promise/src/Promise.php:168                                                                                                                         
   ReactPromisePromise->settle() at /var/www/html/vendor/react/promise/src/Promise.php:231                                                                                                                                          
   ReactPromisePromise::ReactPromise{closure}() at /var/www/html/vendor/react/promise/src/FulfilledPromise.php:42                                                                                                                 
   ReactPromiseFulfilledPromise->done() at /var/www/html/vendor/react/promise/src/Promise.php:135                                                                                                                                   
   ReactPromisePromise::ReactPromise{closure}() at /var/www/html/vendor/react/promise/src/Promise.php:168                                                                                                                         
   ReactPromisePromise->settle() at /var/www/html/vendor/react/promise/src/Promise.php:231                                                                                                                                          
   ReactPromisePromise::ReactPromise{closure}() at /var/www/html/vendor/react/promise/src/FulfilledPromise.php:42                                                                                                                 
   ReactPromiseFulfilledPromise->done() at /var/www/html/vendor/react/promise/src/Promise.php:135                                                                                                                                   
   ReactPromisePromise::ReactPromise{closure}() at /var/www/html/vendor/react/promise/src/Promise.php:168                                                                                                                         
   ReactPromisePromise->settle() at /var/www/html/vendor/react/promise/src/Promise.php:231                                                                                                                                          
   ReactPromisePromise::ReactPromise{closure}() at /var/www/html/vendor/react/promise/src/FulfilledPromise.php:42                                                                                                                 
   ReactPromiseFulfilledPromise->done() at /var/www/html/vendor/react/promise/src/Promise.php:66                                                                                                                                    
   ReactPromisePromise::ReactPromise{closure}() at /var/www/html/vendor/react/promise/src/Promise.php:168                                                                                                                         
   ReactPromisePromise->settle() at /var/www/html/vendor/react/promise/src/Promise.php:231                                                                                                                                          
   ReactPromisePromise::ReactPromise{closure}() at /var/www/html/vendor/react/promise/src/FulfilledPromise.php:42                                                                                                                 
   ReactPromiseFulfilledPromise->done() at /var/www/html/vendor/react/promise/src/Promise.php:135                                                                                                                                   
   ReactPromisePromise::ReactPromise{closure}() at /var/www/html/vendor/react/promise/src/Promise.php:168                                                                                                                         
   ReactPromisePromise->settle() at /var/www/html/vendor/react/promise/src/Promise.php:231                                                                                                                                          
   ReactPromisePromise::ReactPromise{closure}() at /var/www/html/vendor/react/promise/src/FulfilledPromise.php:42                                                                                                                 
   ReactPromiseFulfilledPromise->done() at /var/www/html/vendor/react/promise/src/Promise.php:135                                                                                                                                   
   ReactPromisePromise::ReactPromise{closure}() at /var/www/html/vendor/react/promise/src/Promise.php:168                                                                                                                         
   ReactPromisePromise->settle() at /var/www/html/vendor/react/promise/src/Promise.php:231                                                                                                                                          
   ReactPromisePromise::ReactPromise{closure}() at /var/www/html/vendor/react/promise/src/FulfilledPromise.php:42                                                                                                                 
   ReactPromiseFulfilledPromise->done() at /var/www/html/vendor/react/promise/src/Promise.php:135                                                                                                                                   
   ReactPromisePromise::ReactPromise{closure}() at /var/www/html/vendor/react/promise/src/Promise.php:168                                                                                                                         
   ReactPromisePromise->settle() at /var/www/html/vendor/react/promise/src/Promise.php:231                                                                                                                                          
   ReactPromisePromise::ReactPromise{closure}() at n/a:n/a                                                                                                                                                                        
   call_user_func() at /var/www/html/vendor/composer/composer/src/Composer/Util/ProcessExecutor.php:328                                                                                                                               
   ComposerUtilProcessExecutor->countActiveJobs() at /var/www/html/vendor/composer/composer/src/Composer/Util/Loop.php:90                                                                                                           
   ComposerUtilLoop->wait() at /var/www/html/vendor/composer/composer/src/Composer/Installer/InstallationManager.php:430                                                                                                            
   ComposerInstallerInstallationManager->waitOnPromises() at /var/www/html/vendor/composer/composer/src/Composer/Installer/InstallationManager.php:405                                                                              
   ComposerInstallerInstallationManager->executeBatch() at /var/www/html/vendor/composer/composer/src/Composer/Installer/InstallationManager.php:319                                                                                
   ComposerInstallerInstallationManager->downloadAndExecuteBatch() at /var/www/html/vendor/composer/composer/src/Composer/Installer/InstallationManager.php:218                                                                     
   ComposerInstallerInstallationManager->execute() at /var/www/html/vendor/composer/composer/src/Composer/Installer.php:827                                                                                                         
   ComposerInstaller->doInstall() at /var/www/html/vendor/composer/composer/src/Composer/Installer.php:652                                                                                                                           
   ComposerInstaller->doUpdate() at /var/www/html/vendor/composer/composer/src/Composer/Installer.php:298                                                                                                                            
   ComposerInstaller->run() at /var/www/html/vendor/composer/composer/src/Composer/Command/RequireCommand.php:496                                                                                                                    
   ComposerCommandRequireCommand->doUpdate() at /var/www/html/vendor/composer/composer/src/Composer/Command/RequireCommand.php:340                                                                                                  
   ComposerCommandRequireCommand->execute() at /var/www/html/vendor/symfony/console/Command/Command.php:279                                                                                                                         
   SymfonyComponentConsoleCommandCommand->run() at /var/www/html/vendor/symfony/console/Application.php:1031                                                                                                                      
   SymfonyComponentConsoleApplication->doRunCommand() at /var/www/html/vendor/symfony/console/Application.php:318                                                                                                                  
   SymfonyComponentConsoleApplication->doRun() at /var/www/html/vendor/composer/composer/src/Composer/Console/Application.php:394                                                                                                  
   ComposerConsoleApplication->doRun() at /var/www/html/vendor/symfony/console/Application.php:169                                                                                                                                  
   SymfonyComponentConsoleApplication->run() at /var/www/html/vendor/composer/composer/src/Composer/Console/Application.php:148                                                                                                    
   ComposerConsoleApplication->run() at /var/www/html/vendor/shopware/core/Framework/Plugin/Composer/CommandExecutor.php:40                                                                                                         
   ShopwareCoreFrameworkPluginComposerCommandExecutor->require() at /var/www/html/vendor/shopware/core/Framework/Plugin/PluginLifecycleService.php:697                                                                           
   ShopwareCoreFrameworkPluginPluginLifecycleService->executeComposerRequireWhenNeeded() at /var/www/html/vendor/shopware/core/Framework/Plugin/PluginLifecycleService.php:126                                                    
   ShopwareCoreFrameworkPluginPluginLifecycleService->installPlugin() at /var/www/html/vendor/shopware/core/Framework/Plugin/Command/Lifecycle/PluginInstallCommand.php:69                                                        
   ShopwareCoreFrameworkPluginCommandLifecyclePluginInstallCommand->execute() at /var/www/html/vendor/symfony/console/Command/Command.php:279                                                                                   
   SymfonyComponentConsoleCommandCommand->run() at /var/www/html/vendor/symfony/console/Application.php:1049                                                                                                                      
   SymfonyComponentConsoleApplication->doRunCommand() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:125                                                                                                 
   SymfonyBundleFrameworkBundleConsoleApplication->doRunCommand() at /var/www/html/vendor/symfony/console/Application.php:318                                                                                                     
   SymfonyComponentConsoleApplication->doRun() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:79                                                                                                         
   SymfonyBundleFrameworkBundleConsoleApplication->doRun() at /var/www/html/vendor/symfony/console/Application.php:169                                                                                                            
   SymfonyComponentConsoleApplication->run() at /var/www/html/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49                                                                                                
   SymfonyComponentRuntimeRunnerSymfonyConsoleApplicationRunner->run() at /var/www/html/vendor/autoload_runtime.php:29                                                                                                           
   require_once() at /var/www/html/bin/console:17                                                                                               

Symfony 6.4 – Unable to declare an abstract form type as a service

In my Symfony 6.4 project, I’m trying to declare an abstract service in services.yaml by doing the following :

services:
  _defaults:
    autowire: true
    autoconfigure: true

  AppAdminFormHostingFormAbstract:
    arguments:
      $authorizationChecker: '@security.authorization_checker'
      $tokenStorage: '@security.token_storage'
      $phpHandlers: '%php_handlers%'
      $nodeJsHandlers: '%nodeJs_handlers%'
    abstract:  true
...

The HostingFormAbstract class is extending AbstractType from symfony/form package :

namespace AppAdminForm;

use SymfonyComponentFormAbstractType;
use SymfonyComponentFormExtensionCoreTypeChoiceType;
use SymfonyComponentFormExtensionCoreTypeCollectionType;
use SymfonyComponentFormExtensionCoreTypeTextareaType;
use SymfonyComponentFormExtensionCoreTypeTextType;
use SymfonyComponentFormExtensionCoreTypeCheckboxType;
use SymfonyComponentFormFormBuilderInterface;
use SymfonyComponentSecurityCoreAuthenticationTokenStorageTokenStorageInterface;
use SymfonyComponentSecurityCoreAuthorizationAuthorizationCheckerInterface;
use SymfonyComponentSecurityCoreUserUserInterface;
use SymfonyComponentValidatorConstraintsNotBlank;

abstract class HostingFormAbstract extends AbstractType
{
    
    private TokenStorageInterface $tokenStorage;
    private AuthorizationCheckerInterface $authorizationChecker;
    private array $phpHandlers;
    private array $nodeJsHandlers;

    public function __construct(TokenStorageInterface $tokenStorage, AuthorizationCheckerInterface $authorizationChecker, array $phpHandlers, array $nodeJsHandlers)
    {
        $this->tokenStorage = $tokenStorage;
        $this->authorizationChecker = $authorizationChecker;
        $this->phpHandlers = $phpHandlers;
        $this->nodeJsHandlers = $nodeJsHandlers;
    }
...

And with that, I get the following error while going on my symfony app :

The service "AppAdminFormHostingFormAbstract" tagged "form.type" must not be abstract.

For more context, I’m rewriting a Symfony 3.4 app into a new Symfony 6.4 app.

It was working fine on 3.4, but now it seems that in services.yaml, you can’t declare an abstract service/class extending the AbstractType class.

I tried to add a custom tag in the yaml for this service, but it didn’t change anything.

I didn’t find any workaround on Symfony documentation, and it seems odd to me that you can’t do that. Maybe I missed something.

If anyone as an idea on how to do this…

Thanks !

How to move product-customization text fields after product-variants in Prestashop 8.1.5?

inside product.tpl there is the next code:

<div class="product-information">
                {block name='product_description_short'}
                    <div id="product-description-short-{$product.id}"
                          class="rte-content product-description">{$product.description_short nofilter}</div>
                {/block}

                {if $product.is_customizable && count($product.customizations.fields)}
                    {block name='product_customization'}
                        {include file="catalog/_partials/product-customization.tpl" customizations=$product.customizations}
                    {/block}
                {/if}

                <div class="product-actions js-product-actions">
                    {block name='product_buy'}
                        <form action="{$urls.pages.cart}" method="post" id="add-to-cart-or-refresh">
                            <input type="hidden" name="token" value="{$static_token}">
                            <input type="hidden" name="id_product" value="{$product.id}"
                                   id="product_page_product_id">
                            <input type="hidden" name="id_customization" value="{$product.id_customization}" id="product_customization_id" class="js-product-customization-id">

                            {block name='product_variants'}
                                {hook h='displayProductVariants' product=$product}
                                {include file='catalog/_partials/product-variants.tpl'}
                            {/block}

                            {block name='product_pack'}
                                {if $packItems}
                                    <section class="product-pack">
                                        <p class="h4">{l s='This pack contains' d='Shop.Theme.Catalog'}</p>
                                        {foreach from=$packItems item="product_pack"}
                                            {block name='product_miniature'}
                                                {include file='catalog/_partials/miniatures/pack-product.tpl' product=$product_pack showPackProductsPrice=$product.show_price}
                                            {/block}
                                        {/foreach}
                                    </section>
                                {/if}
                            {/block}

                            {if $iqitTheme.pp_price_position == 'above-button'}
                                <div class="product_p_price_container">
                                {block name='product_prices'}
                                    {include file='catalog/_partials/product-prices.tpl'}
                                {/block}
                                </div>
                            {/if}

                            {block name='product_add_to_cart'}
                                {include file='catalog/_partials/product-add-to-cart.tpl'}
                            {/block}

                            {block name='product_discounts'}
                                {include file='catalog/_partials/product-discounts.tpl'}
                            {/block}

                            {block name='product_refresh'}{/block}
                        </form>
                        {block name='product_additional_info'}
                            {include file='catalog/_partials/product-additional-info.tpl'}
                        {/block}
                    {/block}

I tried to move

 {if $product.is_customizable && count($product.customizations.fields)}
                    {block name='product_customization'}
                        {include file="catalog/_partials/product-customization.tpl" customizations=$product.customizations}
                    {/block}
                {/if}

after

{block name='product_variants'}
                                {hook h='displayProductVariants' product=$product}
                                {include file='catalog/_partials/product-variants.tpl'}
                            {/block}

To see the product customization text fields after the attributes, but then, add to cart button keeps loading when i pressed it.

I tried to paste also the previous if part in different sides, but doesn’t work. Always damage the add to cart button function.

Thank you very much in advance

Running PHPSpreadsheet via crontab on DigitalOcean – not saving

When I run the following script via a browser using the URL, all emails are sent, the XLSX is saved where it should be and the result is very quick.

However, when it runs via crontab, it sends me the first two emails but not the last one and it doesn’t save the XLSX file, making me believe there’s an error at this point.

Unfortunately I don’t get any error messages in the log file.

<?php

require dirname(dirname(__FILE__)).'/vendor/autoload.php';
use PhpOfficePhpSpreadsheetSpreadsheet;
include dirname(dirname(__FILE__)) . '/includes/mail.php';

//SEND AN EMAIL TO ME: "STARTED CRON"

$spreadsheet = new Spreadsheet();
$newsheet = new PhpOfficePhpSpreadsheetWorksheetWorksheet($spreadsheet, "My first sheet");
$spreadsheet->addSheet($newsheet);

$activesheet = $spreadsheet->setActiveSheetIndexByName("My first sheet");
$activesheet->getTabColor()->setRGB("FF0000");
$activesheet->setCellValue("A1", "Test");
$activesheet->setCellValue("A2", "Some numbers...");
$activesheet->setCellValue("A3", 1);
$activesheet->setCellValue("A4", 2);
$activesheet->setCellValue("A5", "=SUM(A3:A4)");

$activesheet->getStyle("A1")->getFill()->setFillType(PhpOfficePhpSpreadsheetStyleFill::FILL_SOLID);
$activesheet->getStyle("A1")->getFill()->getStartColor()->setARGB("FFC6EFCE"); //LIGHT GREEN

//SEND AN EMAIL TO ME: "SET THE DATA"

$destinationfile = "/folder/to/file/TEST_FILE.xlsx";
$writer = PhpOfficePhpSpreadsheetIOFactory::createWriter($spreadsheet, "Xlsx");
$writer->setPreCalculateFormulas(false);
$writer->save($destinationfile);

//SEND AN EMAIL TO ME: "FINISHED CRON"

I’m currently using DigitalOcean as my server with PHP Version 8.2.13 and the composer.json file says:

{
    "require": {
        "phpoffice/phpspreadsheet": "^1.29",
        "phpmailer/phpmailer": "^6.9.1"
    }
}

Faster ranking and updating in mysql [closed]

In my laravel project I have a students table which contains the students’ exam results, each student belongs to a school, district and city. All the students can have the initial exam results and some of them fail specific subjects and they have a re exam in those subjects (termed as second_subject or second_total in the database)

At first the data was split into a students and a results table, however, they were all moved to a single students table for performance reasons. There are 16 subjects in total. and also exists a section field, each section have different subjects but there are also subjects in common, when ranking the student on total, schools, districts and cities the ranking should be also partitioned by the section. However the subject_ranking should include everyone who took that subject

public function up()
    {
        Schema::create((new Student)->getTable(), function (Blueprint $table) {
            $table->unsignedBigInteger('seat_number')->primary();
            $table->string('name');
            $table->foreignIdFor(School::class)->constrained((new School)->getTable());
            $table->string('school_name');
            $table->foreignIdFor(District::class)->constrained((new District)->getTable());
            $table->string('district_name');
            $table->foreignIdFor(City::class)->constrained((new City)->getTable());
            $table->string('city_name');
            $table->unsignedSmallInteger('section');
            $this->result($table);
            $this->result($table, 'second_');
            $table->timestamps();
        });
    }

    public function result(Blueprint $table, string $prefix = ''): void
    {
        $table->unsignedInteger($prefix . 'school_rank')->nullable();
        $table->unsignedInteger($prefix . 'district_rank')->nullable();
        $table->unsignedInteger($prefix . 'city_rank')->nullable();
        $table->unsignedInteger($prefix . 'country_rank')->nullable();
        $table->unsignedFloat($prefix . 'total')->nullable();
        $table->unsignedFloat($prefix . 'percentage')->nullable();
        foreach (Student::$subjects as $subject) {
            $table->unsignedFloat($prefix . $subject)->nullable();
            $table->unsignedInteger($prefix . $subject . '_rank')->nullable();
        }
        $table->unsignedInteger($prefix . 'status')->nullable();
    }

in mysql that would be

CREATE TABLE `students` (
  `seat_number` bigint(20) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  `school_id` bigint(20) unsigned NOT NULL,
  `school_name` varchar(255) NOT NULL,
  `district_id` bigint(20) unsigned NOT NULL,
  `district_name` varchar(255) NOT NULL,
  `city_id` bigint(20) unsigned NOT NULL,
  `city_name` varchar(255) NOT NULL,
  `section` smallint(5) unsigned NOT NULL,
  `school_rank` int(10) unsigned DEFAULT NULL,
  `district_rank` int(10) unsigned DEFAULT NULL,
  `city_rank` int(10) unsigned DEFAULT NULL,
  `country_rank` int(10) unsigned DEFAULT NULL,
  `total` double(8,2) unsigned DEFAULT NULL,
  `percentage` double(8,2) unsigned DEFAULT NULL,
  `english` double(8,2) unsigned DEFAULT NULL,
  `english_rank` int(10) unsigned DEFAULT NULL,
  `math` double(8,2) unsigned DEFAULT NULL,
  `math_rank` int(10) unsigned DEFAULT NULL,
  -- ... rest of the 16 subjects
  `status` int(10) unsigned DEFAULT NULL,
  `second_school_rank` int(10) unsigned DEFAULT NULL,
  `second_district_rank` int(10) unsigned DEFAULT NULL,
  `second_city_rank` int(10) unsigned DEFAULT NULL,
  `second_country_rank` int(10) unsigned DEFAULT NULL,
  `second_total` double(8,2) unsigned DEFAULT NULL,
  `second_percentage` double(8,2) unsigned DEFAULT NULL,
  `second_english` double(8,2) unsigned DEFAULT NULL,
  `second_english_rank` int(10) unsigned DEFAULT NULL,
  `second_math` double(8,2) unsigned DEFAULT NULL,
  `second_math_rank` int(10) unsigned DEFAULT NULL,
  -- ... rest of the 16 subjects
  `second_status` int(10) unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`seat_number`),

Essentially this data never changes and after importing all the data, the only missing fields are the “rank” fields which we need to do ourselves, which is done using a console command.

public function handle(): void
    {
        $time = microtime(true);
        $this->updateRanksForStudentsWithoutSecondExam();
        $secondExists = Student::query()->whereNotNull('second_total')->exists();
        if ($secondExists) {
            $this->updateRanksForStudentsWithSecondExam();
            $this->updatePreviousRanksForStudentsWithSecondExam();
        }
        $time = number_format(microtime(true) - $time, 2);
        $this->info('Updated all ranks in ' . $time . ' seconds');
    }

    /**
     * Update the ranks for students who didn't attend any second exam based on the latest results they have
     *
     * @return void
     */
    public function updateRanksForStudentsWithoutSecondExam(): void
    {
        $time = microtime(true);
        $this->info('Updating normal ranks for students...');
        $subjectsUpdates = [];
        foreach (Student::$subjects as $subject) {
            $subjectsUpdates["$subject" . '_rank'] = DB::raw("case when $subject is null then null else {$subject}_rank_calculated end");
        }
        $count = Student::query()->toBase()
            ->whereNull('second_total')
            ->joinSub($this->getCoalescedRanksQuery(), 'ranks', 'seat_number', '=', 'seat_number_calculated')
            ->update([
                'country_rank' => DB::raw('country_rank_calculated'),
                'school_rank' => DB::raw('school_rank_calculated'),
                'district_rank' => DB::raw('district_rank_calculated'),
                'city_rank' => DB::raw('city_rank_calculated'),
                ...$subjectsUpdates,
            ]);
        $time = number_format(microtime(true) - $time, 2);
        $this->info('Updated the ranks of ' . $count . ' students without second exam in ' . $time . ' seconds');
    }

    /**
     * Essentially the same as the previous method, but for students who have a second exam
     * since now we are updating the second_ fields instead of the normal fields
     *
     * @return void
     */
    public function updateRanksForStudentsWithSecondExam(): void
    {
        $time = microtime(true);
        $this->info('Updating second exam ranks for students...');
        $updateSubjectsRanksRaw = [];
        foreach (Student::$subjects as $subject) {
            $updateSubjectsRanksRaw['second_' . $subject . '_rank'] = DB::raw("case when $subject is null then null else {$subject}_rank_calculated end");
        }
        $count = Student::query()->toBase()
            ->whereNotNull('second_total')
            ->joinSub($this->getCoalescedRanksQuery(), 'ranks', 'seat_number', '=', 'seat_number_calculated')
            ->update([
                'second_country_rank' => DB::raw('country_rank_calculated'),
                'second_school_rank' => DB::raw('school_rank_calculated'),
                'second_district_rank' => DB::raw('district_rank_calculated'),
                'second_city_rank' => DB::raw('city_rank_calculated'),
                ...$updateSubjectsRanksRaw,
            ]);
        $time = number_format(microtime(true) - $time, 2);
        $this->info('Updated the ranks of ' . $count . ' students with second exam in ' . $time . ' seconds');
    }

    /**
     * This will update the initial ranks of the students who had a second exam based only on the initial results of all the students
     * this is so the student can compare their ranks before and after the retaking the exam
     *
     * @return void
     */
    public function updatePreviousRanksForStudentsWithSecondExam(): void
    {
        $time = microtime(true);
        $this->info('Updating previous ranks for students with second exam...');

        $updateSubjectsRanksRaw = [];
        foreach (Student::$subjects as $subject) {
            $updateSubjectsRanksRaw["$subject" . '_rank'] = DB::raw("case when $subject is null then null else {$subject}_rank_calculated end");
        }
        $count = Student::query()->toBase()
            ->whereNotNull('second_total')
            ->joinSub($this->getNonCoalescedRanksQuery(), 'ranks', 'seat_number', '=', 'seat_number_calculated')
            ->update([
                'country_rank' => DB::raw('country_rank_calculated'),
                'school_rank' => DB::raw('school_rank_calculated'),
                'district_rank' => DB::raw('district_rank_calculated'),
                'city_rank' => DB::raw('city_rank_calculated'),
                ...$updateSubjectsRanksRaw,
            ]);
        $time = number_format(microtime(true) - $time, 2);
        $this->info('Updated previous ranks of ' . $count . ' students in ' . $time . ' seconds');
    }

    /**
     * This returns a subquery that contains all the students ranked based on their latest result (either the second, or the first if there is no second)
     *
     * @return Builder
     */
    public function getCoalescedRanksQuery(): Builder
    {
        $selects = [];
        foreach (Student::$subjects as $subject) {
            $selects[] = DB::raw("rank() over (order by COALESCE(second_$subject, $subject) desc) as {$subject}_rank_calculated");
        }
        foreach (['school', 'district', 'city'] as $type) {
            $selects[] = DB::raw("rank() over (partition by section, {$type}_id order by COALESCE(second_total, total) desc) as {$type}_rank_calculated");
        }
        $selects[] = DB::raw('rank() over (partition by section order by COALESCE(second_total, total) desc) as country_rank_calculated');
        return Student::query()->toBase()
            ->select([DB::raw('seat_number as seat_number_calculated'), ...$selects]);
    }

    public function getNonCoalescedRanksQuery(): Builder
    {
        $selects = [];
        foreach (Student::$subjects as $subject) {
            $selects[] = DB::raw("rank() over (order by $subject desc) as {$subject}_rank_calculated");
        }
        foreach (['school', 'district', 'city'] as $type) {
            $selects[] = DB::raw("rank() over (partition by section, {$type}_id order by total desc) as {$type}_rank_calculated");
        }
        $selects[] = DB::raw('rank() over (partition by section order by total desc) as country_rank_calculated');
        return Student::query()->toBase()
            ->whereNotNull('total')
            ->select([DB::raw('seat_number as seat_number_calculated'), ...$selects]);
    }

I went through alot of different approaches for calculating and setting these ranks correctly, however since the table is usually 1,000,000+ records (which could be considered alot or not depending on who you ask), this console command takes more than 15 minutes to finish, roughly the first 2 queries takes the same time and third is a tiny bit faster.

Is mysql efficient in calculating the ranks and then setting those ranks based on a subquery? since the data doesn’t change will creating an index on all of those fields be beneficial in faster sorting for ranking? Or would somehow doing all this proccessing in php be faster? I can load the entire table in memory because it is less than 500mb anyways, however I believe this would make the updating part alot slower even if the ranking is faster. any ideas on how to improve this would be appreciated. Storage and import time don’t matter at all, the only thing that matters in this project is speed and performance in all other parts.

How to read cyrillic in PHP url?

I’m trying to create WordPress WooCommerce plugin where I can scrape url product from partner shop and get the product title, description, images automatically in my website. My problem is that url contains mix of latin and cyrillic letters. Here’s everything go wrong. Instead of the url: garvan.bg/collections/шлемови-каски/products/шлемова-каска-размер-л-4
I got
https://www.garvan.bg/collections/-/products/—-4
therefore I get 404 the page does not exist. How to fix url?

    function link_scraper_debugger_page() {
?>
<div class="wrap">
    <h1>Link Scraper Debugger</h1>
    <form method="post" action="">
        <label for="scrape_url">Enter URL to Scrape:</label>
        <input type="text" id="scrape_url" name="scrape_url" style="width: 100%; max-width: 600px;">
        <input type="submit" name="scrape_submit" value="Scrape" class="button button-primary">
    </form>
</div>
<?php

if (isset($_POST['scrape_submit'])) {
    $url = sanitize_text_field($_POST['scrape_url']);
    if (!empty($url)) {
        link_scraper_debugger_process($url);
    }
}


function link_scraper_debugger_process($url) {
$decoded_url = urldecode($url);

$args = array(
    'redirection' => 5, 
    'headers' => array(
        'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
    )
);

$response = wp_remote_get($decoded_url, $args);
if (is_wp_error($response)) {
    echo '<div class="notice notice-error is-dismissible"><p>Failed to fetch URL: ' . $response->get_error_message() . '</p></div>';
    return;
}

full code here
https://pastebin.com/E7SKUihE

Consistently Slow Performance in Local VM Environment

I am experiencing consistently slow performance on both OpenLiteSpeed and Apache2 in my local development environment, even though my virtual machine has sufficient resources. I’m using WordPress and the slowness is more notable in the WordPress environment.

Environment:

  • VM Details: VM Settings

Hard Disk: HDD 2TB WD Black

  • PHP version: 8.1.28

Symptoms:

  • Slow AJAX requests
  • General slow response times
  • RAM usage per request is around 60MB but takes 21 seconds to process

What I’ve Tried:

  • Checked server and PHP configuration

  • Enabled OPcache

  • Optimized database queries

  • Monitored system resources (CPU, RAM, Disk I/O)

  • Ensured proper indexing in the database

  • Checked DNS and network settings

  • OpenLiteSpeed settings: OpenLiteSpeed Settings

Logs and Monitoring:

Despite these efforts, the performance remains slow. Here are images of my VM details and resource usage:

  • Query Monitor Log for Resource Usage: enter image description here

Can anyone provide insights or suggestions on how to further diagnose and resolve this issue?

Laravel can no longer find my self-created commands

no matter what command I want to execute, Laravel responds with the following error:

There are no commands defined in the "dev" namespace.

It doesn’t matter which of my commands I run. I always get the same error message, just with a different namespace

Thats my code of one command:

<?php

namespace AppConsoleCommands;

use IlluminateConsoleCommand;

class dTest extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'dev:test';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $this->info("Test Command");
    }
}

My PHP-Version: 8.2.20
My Laravel-Version: 11.8.0
My OS: Debian
My Webserver: Apache

Does anyone have an idea where the error might be?

I created a new command for testing. This was done with the command

php artisan make:command --command=dev:test

HTML Form Post URL

Ok so I have a HTML form which is using javascript to display an image thats uploaded here is my HTML code

<form action="/inc/sendtochan.php" method="post">
              <label for="fname">Title:</label><br>
              <input type="text" id="fname" name="title" value="" size="64"><br>
              <label for="discription">Enter content description:</label><br>
              <textarea name="discription" rows="10" cols="60"></textarea><br>
              <label for="link">Link to content:</label><br>
              <input type="text" id="lcontent" name="lcontent" value="" size="64"><br>
              <label for="link">Select Image:</label><br>
              <div class="profile-picture">
              <h1 class="upload-icon">
                <i class="fa fa-plus fa-2x" aria-hidden="true"></i>
              </h1>
              <input
                class="file-uploader"
                type="file"
                onchange="upload()"
                accept="image/*"
                name ="imageurl"
              />
              </div><br><br>
              <input type="submit" name="submitcontent" value="Send Content to Channel">
            </form>

The javascript involved which displays a box, which then changes to a preview of the image selected

function upload() {
  const fileUploadInput = document.querySelector('.file-uploader');

  if (!fileUploadInput.value) {
    return;
  }

  const image = fileUploadInput.files[0];

  if (!image.type.includes('image')) {
    return alert('Sorry Only images are allowed!');
  }

  if (image.size > 10_000_000) {
    return alert('Maximum upload size is 10MB!');
  }
  
  const fileReader = new FileReader();
  fileReader.readAsDataURL(image);

  fileReader.onload = (fileReaderEvent) => {
    const profilePicture = document.querySelector('.profile-picture');
    profilePicture.style.backgroundImage = `url(${fileReaderEvent.target.result})`;
    
  }
}

Everything works perfect and the image displays, now to the php from the post request, what I am trying to get is the url of the image to be posted, in my /inc/sendtochan.php I am reading the data from the post request with

$imageurl = trim($_POST['imageurl']);

But when I echo this, it basically is just returning the image name, what I want the post form to actually post is the image url. Any help would be appricated.

Thank you

I can get the image url to display straight away when its selected by adding this to the javascript

return alert(`url(${fileReaderEvent.target.result})`);

So I just need to actually have that url sent with the post request, now the image name

odbc_prepare(): SQLColAttribute can’t handle SQL_DESC_OCTET_LENGTH: [S1C00] [TimesTen][TimesTen 18.1.4.42.0 CLIENT]Driver not capable

Here is my connection.php

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$dsn = 'DSN=demo;Server=demo;UID=demo;PWD=demo';

$conn = odbc_connect($dsn, '', '');

if ($conn) {
    // Connection successful, proceed with query execution
    echo "Connection successful.<br>";

    // Define the SQL query
    $sql = "SELECT * FROM employee";  // Ensure this is the correct table name

    // Prepare and execute the SQL query
    $stmt = odbc_prepare($conn, $sql);
    if (odbc_execute($stmt)) {
        // Get column names
        $columns = [];
        $num_fields = odbc_num_fields($stmt);
        for ($i = 1; $i <= $num_fields; $i++) {
            $columns[] = odbc_field_name($stmt, $i);
        }

        // Print the column names
        print_r($columns);
        echo "<br>";

        // Fetch and display the results row by row
        while ($row = odbc_fetch_array($stmt)) {

            print_r($row);
            echo "<br>";
        }
    } else {
        echo "Query execution failed: " . odbc_errormsg($conn);
    }

    // Close the connection
    odbc_close($conn);
} else {
    echo "Connection failed: " . odbc_errormsg();
}
?>

from the localhost i cannot find the column name everytime it’s ouput like

Warning: odbc_prepare(): SQLColAttribute can't handle SQL_DESC_OCTET_LENGTH: [S1C00] [TimesTen][TimesTen 18.1.4.42.0 CLIENT]Driver not capable in C:\xampp\htdocs\timesten\test_connection.php on line 20

Warning: odbc_prepare(): SQLColAttribute can't handle SQL_DESC_OCTET_LENGTH: [S1C00] [TimesTen][TimesTen 18.1.4.42.0 CLIENT]Driver not capable in C:\xampp\htdocs\timesten\test_connection.php on line 20

Warning: odbc_prepare(): SQLColAttribute can't handle SQL_DESC_OCTET_LENGTH: [S1C00] [TimesTen][TimesTen 18.1.4.42.0 CLIENT]Driver not capable in C:\xampp\htdocs\timesten\test_connection.php on line 20
Array ( [0] => [1] =>  [2] =>  )
Array ( [John Doe] => John Doe [] => 30 [] => [email protected] )
Array ( [Jane Smith] => Jane Smith [] => 25 [] => [email protected] )
Array ( [Alice Johnson] => Alice Johnson [] => 28 [] => [email protected] )
Array ( [Bob Brown] => Bob Brown [] => 35 [] => [email protected] )
Array ( [Charlie Davis] => Charlie Davis [] => 40 [] => [email protected] )

i want to see the column name . it always showing me like this “Warning: odbc_prepare(): SQLColAttribute can’t handle SQL_DESC_OCTET_LENGTH: [S1C00] [TimesTen][TimesTen 18.1.4.42.0 CLIENT]Driver not capable in C:xampphtdocstimestenconnection.php on line 20”