Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7554431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:20:10+00:00 2026-05-30T11:20:10+00:00

In order to gain more experience in WordPress I delved into its code base

  • 0

In order to gain more experience in WordPress I delved into its code base to study its inner working and its workflow, and I was quite astonished when I saw that:

  1. They implement register_globals (an excerpt from wp-includes/class-wp.php):

     // The query_vars property will be extracted to the GLOBALS. So care should
     // be taken when naming global variables that might interfere with the
     // WordPress environment.
     function register_globals() {
        global $wp_query;
        // Extract updated query vars back into global namespace.
        foreach ( (array) $wp_query->query_vars as $key => $value) {
            $GLOBALS[$key] = $value;
        }
    
  2. They rely on magic quotes (exerpt from wp-includes/functions.php. magic_quotes_gpc is turned off at bootstrapping, before calling this function):

    function add_magic_quotes( $array ) {
        foreach ( (array) $array as $k => $v ) {
        if ( is_array( $v ) ) {
            $array[$k] = add_magic_quotes( $v );
        } else {
                $array[$k] = addslashes( $v );
        }
    
  3. They rely on addslashes (but since 2.8.0 they introduced also mysql_real_escape_string, but the _weak_escape() function that uses addslashes() still exists in the wpdb class)
    UPDATE: I see they emulate prepared statements by using sprintf() and custom placedholders, so queries should be safe I think. Still I’m puzzled on why they don’t provide at least mysqli, after all the detection of Mysql and PHP version happens early in the bootstrapping sequence.

Now, from the year-long frequentation of SO I learned a lot of things, especially that the above three function are “deprecated” and show security issues, and are watched in horror by many.

But WP must have a reason to use them. I’d like to know from more experienced programmers if there are really security issues, or if sometimes their usage is just too clouded in rumors and false convinctions. I know that magic_quotes is an heritage from the past, and the same could be said for addslashes (at least when used for databases), but while googling before asking this I found many websites talking about using addslashes() over mysql_real_escape_string().

I’m interested in knowing a clear, detailed reason on why those badly depicted functions are used; WordPress had had many improvements over the years, addressing different aspects, and yet these functions are still used; I’m looking, therefore, to a concrete explanation over the positive aspects that somehow override the negative ones and justify the usage of those functions.

I’m not looking for opinions (I perfectly know they’re offtopic here), nor I am ranting about WordPress, I hope this is clear. I’d just like to know why many php programmers consider these functions “bad”, and yet a worldwide giant like WordPress, who’s at the 3rd version now, still uses them.

Is this for compatibility with different servers and php versions? (they check very earl for those, though).
Is there something I miss about this functions, how important they can be in an environment like wordpress (or in general)? I’m quite confused, to be honest.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:20:11+00:00Added an answer on May 30, 2026 at 11:20 am

    Wordpress Open Tickets over Time
    (WordPress Open Tickets over Time)

    Don’t rely on the WordPress codebase to do assumptions about good practice or current standards in PHP coding. I’m saying this as someone who has fiddled with wordpress development over a longer period of time.

    WordPress codebase is about 10 years old, it’s full of legacy code[1]. The program can not evolve on the code-level much because of that, so you find a lot of workarounds for problems that are already solved nowadays much better.

    Just take this story: PHP had magic quotes. WordPress developers thought it was useful. So for those hosts that did not have it configured, they added it. Ending up whith code that expects slashed input data often and at various places. The simple thing is, now they just can’t change it to proper input processing and sanitization easily because of the usage of (super)globals introducing static global state nearly everywhere.

    You can not easily refactor such code.

    Same for the database class. It has a long history, originally based on an early version of ezSQL. At that time there was not mysql_real_escape_string and when it was introduced, the WP devs had the problem that not all installation bases support it.

    So don’t wonder about the coding practice you find inside the WordPress code. You’ll learn how things could have been done years ago and with more or less outdated PHP versions. It’s not that long ago that WordPress switched to PHP 5 for example.

    • Backwards compatibility.
    • Target a large amount of (technically more or less outdated) hosts.
    • Don’t break what works with defects.

    This might not be your list of priorities (hopefully), projects differ here a lot. But having a legacy code-base alone is a burden regardless how project priorities are set. WordPress is only one example.


    [1] see Milestones of WordPress: Early Project Timeline (ca. 2000 to 2005))

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Order by descending is not working on LINQ to Entity In the following Query
I am thinking about learning assembly language in order to gain expertise in reverse
I recently changed my XAML in order to gain the capability to right-justify menu
order by in query is taking to much time in MySQL. SHOW PROFILES shows
In order to fully use LinqToSql in an ASP.net 3.5 application, it is necessary
In order to perform a case-sensitive search/replace on a table in a SQL Server
In order to know how many times a pattern exists in current buffer, I
In order to debug an asp.net web app I have to have IE Script
In order to improve my open source project, I need testers. I have created
In order to create an arbitrary precision floating point / drop in replacement for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.