extract with EXTR_PREFIX_ALL does not give me variables

I’m trying use extract() to create prefixed variables. However, the variable I expect is not being created, and I get an undefined variable warning.

Here’s my code:

<?php
    $my_user_id = 1;


    $stmt = $mysqli->prepare("SELECT id, email FROM users_index WHERE user_id=?"); 
    $stmt->bind_param("i", $my_user_id);
    $stmt->execute();
    $result = $stmt->get_result();
    $row = $result->fetch_assoc();
    $stmt->close();
    if (!$row) {
        echo "<p>There was no rows returned for your user session.</p>"; die;
    }
    extract($row, EXTR_PREFIX_ALL, 'sql_my_');

    if (empty($sql_my_id)) {
        echo "
        <p>PHP Error: The variable is blank. row['id']={$row['id']} sql_my_id=$sql_my_id.</p>
        <pre>";
        print_r($row);
        echo "</pre>";
        die;
    }

Output:

Warning: Undefined variable $sql_my_id in C:Apache24htdocswebsitetest.php

PHP Error: The variable is blank. row[‘id’]=1 sql_my_id=.

Array
(
[id] => 1
[email] => [email protected]
)

Problem:
I expected extract($row, EXTR_PREFIX_ALL, 'sql_my_') to create $sql_my_id and $sql_my_email, but $sql_my_id is not defined.

What I’ve tried:

  • Using EXTR_PREFIX_ALL with a prefix.
  • Checking if $row is empty before extracting.

Why isn’t $sql_my_id being created by extract()? How can I correctly create prefixed variables from my associative array?

autoformat with CS Fixer exited with non-zero code

I’m trying to set up PHP Coding Standards Fixer with PhpStorm but when I run the code auto formatter (Ctrl Alt L) I get an error:

PHP External Formatter: Process exited with non-zero code

error bubble

Clicking the notification doesn’t expands any info and I don’t know where to get this output or code.

I had set PHP CS Fixer as the external formatter in “Quality tools”, activated the inspection in “Quality tools > PHP CS Fixer” and the validate for “PHP CS Fixer path” does not show any issues.

I have also setted “Run built-in formatter before external formatter” in Advanced settings.

I have my .php-cs-fixer.dist.php not in the root of my project but in a symfony folder (so path is symfony/.php-cs-fixer.dist.php). Could this be the issue? How can I set this path if it is the case?

How can I fix this error? I would prefer not to ignore it…

Block style is not getting a priority over Font awesome icon

I have added a Font Awesome Icon to my WordPress website which should trigger on small screens such as mobile devices. But it looks like this

Image showing website

It is getting triggered even on larger screens. The problem is, this header was created as a custom block and registered in functions.php using the init hook. But the font awesome scripts are being registered using wp_enqueue_scripts() hook. I am guessing that since init hook is prioritised before wp_enqueue_scripts() hook, even when I have the styles to not show the icon on large screens, the icon styles since registered later gets a priority and shows up in on the screen. I was wondering if there was another way to register font awesome so that this would not happen.

This is my functions.php code

function create_block_temp_block_block_init() {
/**
 * Registers the block(s) metadata from the `blocks-manifest.php` and registers the block type(s)
 * based on the registered block metadata.
 * Added in WordPress 6.8 to simplify the block metadata registration process added in WordPress 6.7.
 *
 * @see https://make.wordpress.org/core/2025/03/13/more-efficient-block-type-registration-in-6-8/
 */
if ( function_exists( 'wp_register_block_types_from_metadata_collection' ) ) {
    wp_register_block_types_from_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
    return;
}

/**
 * Registers the block(s) metadata from the `blocks-manifest.php` file.
 * Added to WordPress 6.7 to improve the performance of block type registration.
 *
 * @see https://make.wordpress.org/core/2024/10/17/new-block-type-registration-apis-to-improve-performance-in-wordpress-6-7/
 */
if ( function_exists( 'wp_register_block_metadata_collection' ) ) {
    wp_register_block_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
}
/**
 * Registers the block type(s) in the `blocks-manifest.php` file.
 *
 * @see https://developer.wordpress.org/reference/functions/register_block_type/
 */
$manifest_data = require __DIR__ . '/build/blocks-manifest.php';
foreach ( array_keys( $manifest_data ) as $block_type ) {
    register_block_type( __DIR__ . "/build/{$block_type}" );
}
}
add_action( 'init', 'create_block_temp_block_block_init' );

function university_files() {
wp_enqueue_style('custom-google-fonts', '//fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700,700i|Roboto:100,300,400,400i,700,700i');
wp_enqueue_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
}

add_action('wp_enqueue_scripts', 'university_files');

In Inspector it’s showing that my icon styles with classname fa are getting priority over my own styles with classname site-header__menu-trigger

Image showing inspector tools

Here is my git repository for reference:
https://github.com/Revolter23/fictional-block-copy

Security issue with a WordPress plugin.plugin writes a log file to the uploads folder, which is publicly accessible via the browser on Nginx servers

I’m running into a security issue with a WordPress plugin. The plugin writes a log file to the uploads folder, which is publicly accessible via the browser on Nginx servers.

Originally, the log was saved to:

$log_file = WP_CONTENT_DIR . '/site.log';

But due to WordPress compliance and server permission issues (especially on shared hosts), we moved the log file to the uploads directory to ensure it’s writable. That worked — but now the file is exposed to the public, which is a security risk.

I don’t have access to the server config or Nginx rules, so I need to implement a fix within the plugin code itself.

Any suggestions on how to secure or hide the log file from direct access, while keeping it writable across different hosting environments?

supervisor creating logs file without the write permissions

We’re running some Laravel commands using Supervisor on our server. Each program writes to a log file in storage/logs.

The issue is that whenever a Supervisor rotates or creates a new log file, it’s being created with restrictive permissions -rw-r--r--.

What we need:

All log files should always be created with 0666 or 0777 permissions.

The log files should not be owned by root, but instead by the www-data user.

How can we configure Supervisor (or the environment) so that new log files created by these processes always use those permissions?

Example issue:

-rwxrwxrwx 1 root     root      5187 Aug 28 23:00 laravel-2025-08-28.log
-rwxrwxrwx 1 root     root      6780 Aug 29 23:00 laravel-2025-08-29.log
-rwxrwxrwx 1 root     root      7087 Aug 30 23:01 laravel-2025-08-30.log
-rwxrwxrwx 1 root     root      7295 Aug 31 23:00 laravel-2025-08-31.log
-rwxrwxrwx 1 root     root      8282 Sep  1 23:00 laravel-2025-09-01.log
-rwxrwxrwx 1 root     root      8282 Sep  2 23:00 laravel-2025-09-02.log
-rwxrwxrwx 1 root     root      6966 Sep  3 23:00 laravel-2025-09-03.log
-rwxrwxrwx 1 root     root      7295 Sep  4 23:00 laravel-2025-09-04.log
-rwxrwxrwx 1 root     root      9690 Sep  5 23:00 laravel-2025-09-05.log
-rwxrwxrwx 1 root     root      8533 Sep  6 23:00 laravel-2025-09-06.log
-rwxrwxrwx 1 root     root      7771 Sep  7 23:00 laravel-2025-09-07.log
-rwxrwxrwx 1 root     root      6801 Sep  8 23:00 laravel-2025-09-08.log
-rwxrwxrwx 1 root     root       574 Sep  9 14:54 laravel-2025-09-09.log
-rw-r--r-- 1 root     root       149 Sep 10 07:25 laravel-2025-09-10.log

Note, this one is created by the supervisor:

-rw-r--r-- 1 root     root       149 Sep 10 07:25 laravel-2025-09-10.log

MongoDB error: No suitable servers found (`serverSelectionTryOnce` set): [socket timeout calling hello on ‘localhost:27017’]. Topology type: Single

So I have a dockerized mongodb.

My docker-composer.yml code is:

  mongodb:
    image: mongo:latest
    container_name: mongodb
    restart: unless-stopped
    environment:
      MONGO_INITDB_ROOT_USERNAME: xxxx
      MONGO_INITDB_ROOT_PASSWORD: xxxx
    ports:
      - "27017:27017"
    volumes:
      - ./mongodb/data:/data/db
    logging:
      driver: "json-file"       # Use the JSON file logging driver
      options:
        max-size: "200k"        # Rotate log files when they reach 200KB
        max-file: "10"          # Keep up to 10 rotated log files

When I connect to it from with this command, it give me the list of databases:
docker exec -it mongodb mongosh “mongodb://wmd_mongo_admin21:T8d_jm5_y0Clz3De2x@localhost:27017/Test?authSource=admin” –eval “db.getCollectionNames()”

But when I try to connect to it using php driver:

$mongodb_url = "mongodb://xxxx:xxxx@localhost:27017/Test";

try {
    // Create MongoDB manager
    $manager = new MongoDBDriverManager($mongodb_url);

    // Test query on 'urls' collection
    $query = new MongoDBDriverQuery([]);
    $cursor = $manager->executeQuery('Test.urls', $query);
    
    echo "Mongodb successfully connected!n";

    foreach ($cursor as $doc) {
        print_r($doc);
    }
} catch (MongoDBDriverExceptionException $e) {
    echo "Failed to connect or query MongoDB. Error: " . $e->getMessage() . "n";
}

It give me this error:

Failed to connect or query MongoDB. Error: No suitable servers found (`serverSelectionTryOnce` set): [socket timeout calling hello on '127.0.0.1:27017']. Topology type: Single

The PHP driver works because I can create a MongoDB manager

$manager = new MongoDBDriverManager($mongodb_url);

The problem is when I try to execute a query

$query = new MongoDBDriverQuery([]);
$cursor = $manager->executeQuery('Test.urls', $query);

Please note that the php script was working perfectly and stop working suddently without me changing the code.

CodeSniffer rules override each other

I have those rules:

<rule ref="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces">
    <include-pattern>/src/Module/Quotes/Adapter/Incoming/</include-pattern>
    <properties>
        <property name="namespacesRequiredToUse" type="array">
            <element value="AppModuleQuotesDomain"/>
            <element value="Psr"/>
        </property>
        <property name="allowUseFromRootNamespace" value="true"/>
    </properties>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces">
    <include-pattern>/src/Module/DemandPartners/Adapter/Incoming/</include-pattern>
    <properties>
        <property name="namespacesRequiredToUse" type="array">
            <element value="AppModuleDemandPartnersDomain"/>
            <element value="Psr"/>
        </property>
        <property name="allowUseFromRootNamespace" value="true"/>
    </properties>
</rule>

It returns some messages that point issues in src/Module/Quotes/Adapter/Incoming/... files.

But when I reverse the order:

<rule ref="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces">
    <include-pattern>/src/Module/DemandPartners/Adapter/Incoming/</include-pattern>
    <properties>
        <property name="namespacesRequiredToUse" type="array">
            <element value="AppModuleDemandPartnersDomain"/>
            <element value="Psr"/>
        </property>
        <property name="allowUseFromRootNamespace" value="true"/>
    </properties>
</rule>

<rule ref="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces">
    <include-pattern>/src/Module/Quotes/Adapter/Incoming/</include-pattern>
    <properties>
        <property name="namespacesRequiredToUse" type="array">
            <element value="AppModuleQuotesDomain"/>
            <element value="Psr"/>
        </property>
        <property name="allowUseFromRootNamespace" value="true"/>
    </properties>
</rule>

It points to files in src/Module/DemandPartners/Adapter/Incoming directory.

It looks like the configuration at the bottom overwrites the configuration on the top.

How can I fix that? I would like to have different rules configurations for each directory.

Is there any other approach to update or chunk to populate a new column with millions rows?

My query is taking too long to run when I use general filters, but it’s fine with specific filters. I suspect it’s an optimization issue.

To fix it, I’m trying to create a non-clustered index on a new column. This column will extract a specific value from a JSON attributes column.

The table has over 2 million rows. I ran the migration and it created the new column instantly, but it’s hanging indefinitely while trying to populate the data. I’m also planning to create a composite index on three columns, including this new one.

What is the best way to backfill a column on a large table without causing the migration to fail or hang?

<?php

use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('answer_tests', function (Blueprint $table) {
            $table->BigInteger('unity_id')->after('institution_id')->nullable();
        });

        DB::table('answer_tests')->orderBy('id')->chunkById(100, function ($rows) {
            foreach ($rows as $row) {
                DB::table('answer_tests')
                    ->where('id', $row->id)
                    ->update([
                        'unity_id' => DB::raw("JSON_UNQUOTE(JSON_EXTRACT(attributes, '$.class_school.unity.id'))"),
                    ]);
            }
        });

        Schema::table('answer_tests', function (Blueprint $table) {
            $table->index(['institution_id', 'unity_id', 'created_at'], 'idx_unity_institution_created_at');
        });

    }

    public function down(): void
    {
        Schema::table('answer_tests', function (Blueprint $table) {
            $table->dropIndex('idx_unity_institution_created_at');
            $table->dropColumn('unity_id');
        });
    }
};

laravel mail issue while using the laravel default mail template

I am using the Laravel default mail directory. The path is like this:
resources/views/vendor/mail/html/. This is a directory and I added two new custom email templates.

Inside the html directory I have the following blade files:

  1. email_promo.blade.php
  2. email_temp.blade.php
  3. message.blade.php

When I use the first two templates it is giving me this error:

View [vendor.mail.html.email_promo] not found.

View [vendor.mail.html.email_temp] not found.

But the default message.blade.php email template is working. Does anyone one know why it is saying that? I have cleared the view and checked if it’s case-senstive but it is the same as defined. Can anyone help with this?

I am expecting that the view error should not be generated.

E_COMPILE_ERROR [duplicate]

An error of type E_COMPILE_ERROR was caused in line 4238 of the file
/www/plusbyapn_925/public/wp-content/themes/plusbyapn/functions.php.
Error message: Cannot redeclare plus_typeform() (previously declared
in
/www/plusbyapn_925/public/wp-content/themes/plusbyapn/functions.php:4204)

I checked functions.php but I don’t see any redeclaration there.

How can I remove duplicated and non categorized pages on google search? [closed]

I have made a real estate website for a company I work for using the yii2 framework. Google search console have found many variations of links and marked them as duplicate or chose not to categorize them at all. What can I do to make them categorized or point to the main page of each duplicated url?
I will provide some info on how these urls got produced in the first place:

  • Yii2 framework on its own make variations of the urls according to how many languages you have set.
  • In real estate search page, if you choose any of the filters available, the url changes dynamically. Considering that we have many filters this can produce a large amount of urls.
  • We have a large amount of properties, each property id with its own url.

Here is examples of the flags of google search console:

  1. Duplicated:
    https://goldenhome.gr/?sort=-AskedValue&page=967 (actually non-existent. This parameter should only exist in the search page)
    https://goldenhome.gr/property/view/320943 (property sold page)
    https://goldenhome.gr/epikoinwnia / https://goldenhome.gr/contact-us (greek and english page)
    https://goldenhome.gr/property/view/324726?language=el (auto generated lang parameter)
    https://goldenhome.gr/property/view?id=466676

iframe to PHP file is downloading instead of displaying, can I display PHP inside an HTML iframe? [duplicate]

I’m developing a webpage that uses strictly PHP files because it’s a lot of repetition and I wanted to use templates for my files. Unfortunately GitHub doesn’t display PHP files like it does for HTML files so I wanted to try to use an HTML file to bypass this restriction. However, when I used an iframe to try to display the PHP files, it downloaded the file instead.

I have tried the methods shown in question 20276613 – using php inside of iframe html tags and question 50949201 – iframe downloads the html source instead of displaying it. This resulted in my HTML code looking like this:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <iframe align="center" width="100%" height="100%" src="pages/index.php" frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>
</body>
</html>

which unfortunately did not work.

Upon typing this question, I was prompted with questions 35207934 – PHP file downloading instead of displaying files and 32143755 – chrome is downloading file in iframe instead of displaying it, neither of which helped nor were relevant.

If it matters (which I think it does) I have tried this on Opera, Opera GX, Opera Air, Google Chrome, and Microsoft Edge, all most recent versions, and I am running Windows 11 Home 24H2 64x.

Is there any way I can fix this? Should I have used a different approach instead of using PHP for everything?

Thank you.

Is it possible to get metadata (specifically the original creation date or time) from a .pdf that was emailed to me as an attachment in PHP?

I have many .pdf files from attachments that were emailed to me by police and court of apeal (not shared via FTP) and I have the old HDD blocked so that I had to download them in same day and creation date is same with modification date, so I was wondering if it was possible to find out the date and/or time it was originally created after they are shared in a private ftp folder and listed in php? Everything I’ve tried to date just gives me the date/time that I download the attachment. All the files are smaller then 10MB so that I would need just a line of code to read the /CreationDate entry via file_get_contents() and not a class or an API with tons of files and bytes.

<?php 

    $date = array(); $sourcefile = "./file.pdf";
    $stringedPDF = file_get_contents($sourcefile, true);

    preg_match('/(?<=CreationDate )S(?:(?<=().+?(?=))|(?<=[).+?(?=]))./', $stringedPDF, $date);
    echo $all = $date[0];

Best way to automate SQL dump to CodeIgniter 4 migrations? [closed]

I’m working on a project where I need to convert SQL dump files (e.g., from phpMyAdmin) into CodeIgniter 4 migration files, including foreign keys and triggers. Manually writing migrations is inefficient, especially with complex schemas. Are there tools or best practices for this? I’ve started a GitHub project to address this—any feedback or suggestions?

I started by manually converting a SQL dump file (e.g., from phpMyAdmin) into CodeIgniter 4 migration files using the Forge class, defining tables and foreign keys like user_id with ON DELETE SET NULL. However, this process is time-consuming, especially with complex schemas involving triggers and multiple tables. I explored existing tools like CodeIgniter’s migration system and third-party libraries, but none fully automate the conversion of SQL dumps while preserving foreign key actions (e.g., SET NULL, NO ACTION) and triggers.

I attempted to write a custom script using PHP to parse the SQL file and generate migration code, but handling edge cases (e.g., multi-line SQL, non-standard syntax) proved challenging. I expected a more efficient solution that could read a SQL file, extract table structures, foreign keys, and triggers, and output ready-to-use CodeIgniter 4 migration files with minimal manual adjustment. To address this, I’ve begun developing a GitHub project to automate this process, but I’d like to know if there are better approaches or tools I might have missed.

Admin Toolbar Not Showing on All Pages After Restoring WordPress Backup [closed]

I recently restored my WordPress site to a previous backup (dated yesterday). After the restoration:

The admin toolbar is missing on the homepage.

After some time, it disappeared on all pages of the site.

I am logged in as an administrator, and other admin functionalities are working.

Here are my current environment details:

WordPress version: 6.x.x

PHP version: 8.x

Active theme: Woodmart (premium)

Active plugins: Elementor Pro, Dokan Pro, WooCommerce, LiteSpeed Cache, WPForms Lite, and others.

Cache / CDN: LiteSpeed Cache + Cloudflare (if relevant)

Cleared browser cache and cookies.

Deactivated all plugins → still no admin toolbar.

Switched to default theme (Twenty Twenty-Three) → admin toolbar appeared.

Checked user roles → administrator.
Why is the admin toolbar missing after restoring the backup?
How can I make it appear again on all pages without affecting the site?