SIDEBAR
»
S
I
D
E
B
A
R
«
Old WordPress on PHP 8+: Faking get_magic_quotes_gpc() and fixing arrays
Apr 13th, 2023 by miki

If you end up in a situation where your PHP installation gets ahead of your application (like fx. if your hosting provider deprecates PHP 7.4 without you having had the opportunity to update your WordPress 4.9.22 blog), here is a small tip if this results in errors related to the, in PHP 8 removed, function get_magic_quotes_gpc() (see PHP RFC from 2018 about this decision).

As this function has been a dummy function returning false since PHP 5.4 (see php-src commit removing the functionality) and emitting a deprecation warning since PHP 7.4 (see php-src commit deprecating function) in almost any case perceivable you would be able to fake this function and satisfy your application’s need for it to exist.

To fix this for WordPress add the following line to the wp-includes/load.php file (fx. at line 7 for v4.9.22);

function get_magic_quotes_gpc() {return false;}

And voila! WordPress will be functional again (please consider using the chance to upgrade).

Unless, of course, there are other problems related to the PHP upgrade…

This could fx. be ancient themes (like Ahimsa) that use deprecated associative array notation (unquoted string literal indexes). These needs fixing first by adding quotes to all of the indexing strings in sub-arrays of the $skin_fields array, like below;

$skin_fields =
array
(
    array
    (
        "name"    => "skinpagebgtopbg",
        "desc"    => "Page Background Top",
        "csssel"  => "#bgtop",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skinpagediv",
        "desc"    => "Page Background Divider Colour",
        "csssel"  => "#bgtop",
        "attr"    => "border-bottom-color"
    ),
    array
    (
        "name"    => "skinpagebgbotbg",
        "desc"    => "Page Background Bottom",
        "csssel"  => "BODY",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skinhyperlinks",
        "desc"    => "Hyperlinks",
        "csssel"  => "A",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skincapsulebg",
        "desc"    => "Default Bubble Background",
        "csssel"  => ".capsule",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skincapsulefg",
        "desc"    => "Default Bubble Text Colour",
        "csssel"  => ".capsule",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skinheaderbg",
        "desc"    => "Header Background",
        "csssel"  => "#header",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skinheaderfg",
        "desc"    => "Header Text Colour",
        "csssel"  => "#header, #header table, #header a",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skinheadersepcolour",
        "desc"    => "Colour of Separator Bar in Header",
        "csssel"  => "#title",
        "attr"    => "border-right-color"
    ),
    array
    (
        "name"    => "skinsidebarbg",
        "desc"    => "Sidebar Background",
        "csssel"  => ".sidebar, .tdsidebar",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skinsbwidgetbg",
        "desc"    => "Sidebar Widgets Background",
        "csssel"  => ".sidebarlist",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skinsbwidgetfg",
        "desc"    => "Sidebar Widgets Text Colour",
        "csssel"  => ".sidebarlist",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skinsblegendbg",
        "desc"    => "Sidebar Widget Title Background",
        "csssel"  => ".sidebarlist > legend",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skinsblegendfg",
        "desc"    => "Sidebar Widget Title Text Colour",
        "csssel"  => ".sidebarlist > legend",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skinsblistdiv",
        "desc"    => "Sidebar/Action Lists Divider Colour",
        "csssel"  => ".sidebarlist li, #postaction li",
        "attr"    => "border-top-color"
    ),
    array
    (
        "name"    => "skinsblink",
        "desc"    => "Sidebar Widget Hyperlinks",
        "csssel"  => ".sidebarlist a",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skincalcaption",
        "desc"    => "Sidebar Calendar Caption Colour",
        "csssel"  => "#wp-calendar caption",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skincalheaderbg",
        "desc"    => "Sidebar Calendar Column Header Background",
        "csssel"  => "#wp-calendar thead th, #wp-calendar tfoot td.pad",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skincalheaderfg",
        "desc"    => "Sidebar Calendar Column Header Text Colour",
        "csssel"  => "#wp-calendar thead th",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skincalcellfg",
        "desc"    => "Sidebar Calendar Entries Text Colour",
        "csssel"  => "#wp-calendar tbody td",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skincalnpbg",
        "desc"    => "Sidebar Calendar Next/Prev Links Background",
        "csssel"  => "#wp-calendar #next, #wp-calendar #prev",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skincalnpfg",
        "desc"    => "Sidebar Calendar Next/Prev Links Text Colour",
        "csssel"  => "#wp-calendar #next, #wp-calendar #prev, #wp-calendar tfoot a",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skintextwdgtfg",
        "desc"    => "Sidebar Text Widget Text Colour",
        "csssel"  => ".textwidget",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skincontentbg",
        "desc"    => "Main Content Background",
        "csssel"  => "#content",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skinpostpagebg",
        "desc"    => "Post or Page Entry Background",
        "csssel"  => ".post > fieldset",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skinpostpagefg",
        "desc"    => "Post or Page Entry Text Colour",
        "csssel"  => ".entry",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skinpptitlebg",
        "desc"    => "Post, Page, Comments Title Background",
        "csssel"  => ".post .title, #comments > legend, .comment > legend, #responsebox > legend",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skinpptitlefg",
        "desc"    => "Post, Page, Comments Title Text Colour",
        "csssel"  => ".post .title, .post .title a, " .
                    "#comments > legend, .comment > legend, #responsebox > legend",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skinmetabarbg",
        "desc"    => "Post/Page/Comment Bottom Bar Background",
        "csssel"  => ".postmetadata",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skincattagbg",
        "desc"    => "Category/Tag Lists Background",
        "csssel"  => ".postcattags",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skincattagfg",
        "desc"    => "Category/Tag Lists Text/Link Colour",
        "csssel"  => ".postcattags, .postcattags a",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skin1cattagbubblebg",
        "desc"    => "Single Post Cat/Tag Bubble Background",
        "csssel"  => "#single .postcattags .capsule",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skin1cattagbubblefg",
        "desc"    => "Single Post Cat/Tag Bubble Text/Link Colour",
        "csssel"  => "#single .postcattags .capsule, #single .postcattags .capsule a",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skinbqbg",
        "desc"    => "Blockquote Background",
        "csssel"  => "blockquote",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skinbqfg",
        "desc"    => "Blockquote Text Colour",
        "csssel"  => "blockquote",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skinlistbg",
        "desc"    => "Page/Post Ordered/Unordered List Background",
        "csssel"  => ".entry UL, .entry OL",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skinlistfg",
        "desc"    => "Page/Post Ordered/Unordered Text Colour",
        "csssel"  => ".entry UL, .entry OL",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skinpost1stletterfg",
        "desc"    => "Post First Letter Colour",
        "csssel"  => ".entry > P:first-child:first-letter",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skinactionbg",
        "desc"    => "Action Bubbles (Edit, Reply, etc) Background",
        "csssel"  => ".actbubble",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skinactionfg",
        "desc"    => "Action Bubbles (Edit, Reply, etc) Text Colour",
        "csssel"  => ".actbubble, .actbubble a",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skincommentsbg",
        "desc"    => "Comments Block Background",
        "csssel"  => "#comments",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skincommentbg",
        "desc"    => "Comment Background",
        "csssel"  => "fieldset.comment, fieldset.comment .commenttext",
        "attr"    => "background-color"
    ),
    array
    (
        "name"    => "skincommentfg",
        "desc"    => "Comment Text Colour",
        "csssel"  => "fieldset.comment .commenttext",
        "attr"    => "color"
    ),
    array
    (
        "name"    => "skinresponsebg",
        "desc"    => "Response Box Background",
        "csssel"  => "#responsebox",
        "attr"    => "background-color"
    )
);
Uberspace PHP 7.4 to 8.0 migration brakes WordPress <5.3
Jan 10th, 2023 by miki

So, uberspace.de (which hosts this site at the time of writing) announced timely on 2022-10-27 that instances (aka. asteroids) using PHP 7.4 will automatically upgrade to PHP 8.0 on 2022-11-29 due to 7.4 going out of active support on 2022-11-28;

Ahoy,

You have selected PHP 7.4 as the active version on your Asteroid. Support for this version will end on November 28, 2022. For your and our security we will upgrade your account to PHP 8.0 on November 29, 2022.

Usually you will not notice anything and there is nothing else to do, because most tools and programs like WordPress and Nextcloud have been working with PHP 8.0 for a long time.
If you want to be on the safe side, please check in advance if your tools are up to date.

By the way: You can also set your PHP version yourself. You can find all the information you need about PHP in our manual: https://manual.uberspace.de/lang-php/#change-version

For questions and feedback please contact our support team:
https://uberspace.de/support/

Best regards
Boni, Janto, Kim, Leah, luto, Moritz, Nati, Nico, Noah, Pelzi, Mo, Sabrina & Jonas

This went under my radar on migration day, and due to the site still being operational I did not think it caused any issues.

However, on 2023-01-09 the site suddenly went offline and investigating logs, PHP errors were thrown in one of the main WordPress includes;

[09-Jan-2023 19:41:58] WARNING: [pool www] child 19454 said into stderr: “[09-Jan-2023 18:41:58 UTC] PHP Fatal error: Uncaught Error: Call to undefined function get_magic_quotes_gpc() in <redacted>/wp-includes/load.php:651”
[09-Jan-2023 19:41:58] WARNING: [pool www] child 19454 said into stderr: “Stack trace:”
[09-Jan-2023 19:41:58] WARNING: [pool www] child 19454 said into stderr: “#0 <redacted>/wp-settings.php(333): wp_magic_quotes()”
[09-Jan-2023 19:41:58] WARNING: [pool www] child 19454 said into stderr: “#1 <redacted>/wp-config.php(39): require_once(‘<redacted>’)”
[09-Jan-2023 19:41:58] WARNING: [pool www] child 19454 said into stderr: “#2 <redacted>/wp-load.php(37): require_once(‘<redacted>’)”
[09-Jan-2023 19:41:58] WARNING: [pool www] child 19454 said into stderr: “#3 <redacted>/xmlrpc.php(29): include(‘<redacted>/’)”
[09-Jan-2023 19:41:58] WARNING: [pool www] child 19454 said into stderr: “#4 {main}”
[09-Jan-2023 19:41:58] WARNING: [pool www] child 19454 said into stderr: ” thrown in <redacted>/wp-includes/load.php on line 651″

This is due to the PHP function get_magic_quotes_gpc(), which is already deprecated in 7.4, being completely removed in 8.0. However in WordPress before 5.3 (released 2019-11-12, see announcement or further details) this function is assumed to be present. The location throwing above is the first location in the code path hitting the use of this;

Function wp_magic_quotes() of load.php:

The quick fix to this was downgrading PHP by following the guide mentioned above, which was surprinsingly possible. However, this should only be regarded as a temporary solution as PHP out of security support is not a good solution. As the guide does not mention when PHP 7.4 is going out of support and being completely removed from uberspace, I tried pinging their support in their fediverse account, no resposnse as of ending this write-up.

»  Substance:WordPress   »  Style:Ahren Ahimsa
© 2023 Mikkel Kirkgaard Nielsen, contents CC BY-SA 4.0