HEX
Server: Apache
System: Linux digivps 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC 2025 x86_64
User: root (0)
PHP: 8.3.15
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/biographybirthday.com/wp-content/plugins/webp-express/lib/migrate/migrate6.php
<?php

namespace WebPExpress;

use \WebPExpress\Config;
use \WebPExpress\Messenger;
use \WebPExpress\HTAccess;
use \WebPExpress\Paths;
use \WebPExpress\Option;

/**
 *  Fix records - if possible
 */
function webpexpress_migrate6_fixHtaccessRecordsForDir($dirId) {
    $haveRules = HTAccess::haveWeRulesInThisHTAccess(Paths::getAbsDirById($dirId) . '/.htaccess');

    // PS: $haveRules may be null, meaning "maybe"
    if ($haveRules === true) {
        HTAccess::addToActiveHTAccessDirsArray($dirId);
    }
    if ($haveRules === false) {
        HTAccess::removeFromActiveHTAccessDirsArray($dirId);
    }
}

function webpexpress_migrate6() {

    // Regenerate .htaccess file if placed in root (so rewrites does not apply in wp-admin area)
    if (HTAccess::isInActiveHTAccessDirsArray('index')) {
        if (Config::isConfigFileThere()) {
            $config = Config::loadConfigAndFix(false);  // false, because we do not need to test if quality detection is working

            $rules = HTAccess::generateHTAccessRulesFromConfigObj($config, 'index');
            $success = (HTAccess::saveHTAccessRulesToFile(Paths::getIndexDirAbs() . '/.htaccess', $rules, true));

            if ($success) {
                Messenger::addMessage(
                    'info',
                    'Fixed .htaccess rules in root (the old rules were also applying to wp-admin folder. In some cases this resulted in problems with the media library).'
                );
            } else {
                Messenger::addMessage(
                    'warning',
                    'Tried to fix .htaccess rules in root folder (the old rules applied to wp-admin, which in some cases resulted in problems with media library). However, the attempt failed.'
                );
            }
        }
    }

    // The records about which .htaccess files that contains rules were not correct.
    // Correct them if possible (haveWeRulesInThisHTAccess() may return null, if we cannot determine)
    // https://github.com/rosell-dk/webp-express/issues/169

    $dirsToFix = [
        'index',
        'home',
        'wp-content',
        'plugins',
        'uploads'
    ];
    foreach ($dirsToFix as $dirId) {
        webpexpress_migrate6_fixHtaccessRecordsForDir($dirId);
    }

    Option::updateOption('webp-express-migration-version', '6');
}

webpexpress_migrate6();