What directory is state.php?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dev77
    Senior Member
    • Feb 2018
    • 142

    #1

    What directory is state.php?

    What directory is state.php ? Is this a new file in 9.3? I ask because I have a C++ program that checks the website looking for "string sub = "Latest Release EspoCRM";" and compare the resulting string ( "<h2>Latest Release EspoCRM 9.3.0 (February 05, 2026)</h2>" in https://www.espocrm.com/download/ and compare it to what I have saved previously to see if there is a new release. Has worked for many, many years since the website has not been changed. Maybe there is a better way to do it, but this has worked (and will until the website is changed.)

    I also get a notification from github as a failsafe... should the Espo site change.

    I'll happily give anyone the C++ code if they wish to have it.
  • ThomasB
    Senior Member
    • Mar 2022
    • 182

    #2
    Yuri wrote this in the release annoucement:

    If after upgrade via CLI you receive a message that a new version is available and the current version number is not displayed, it's normal. You can run upgrade again and it will tell that you are on the latest version.

    This happens because we moved the version number from config.php to state.php but the upgrade command code, which is already in memory, reads from the config.php.

    Comment

    • yuri
      EspoCRM product developer
      • Mar 2014
      • 9639

      #3
      As stated in the issue, it's data/state.php file. The website has nothing to do w/ this. Rather than scrapping the website, it's better to poll the GitHub API endpoint for the latest version. It's open.

      Comment

    • dev77
      Senior Member
      • Feb 2018
      • 142

      #4
      Thanks for the help... but (believe it or not) I have no idea how to " poll the GitHub API endpoint for the latest version." If you can give me a simple pointer on how to do this... I'll do it. Maybe there is a link somewhere that explains the methodology (I have a github account).

      Do you want me to 'scrape" the link above? I know how to do that. If there is a way to obtain the latest version without the code I'm using to scrape the website, I'd love to do it that way... which is obviously the way it SHOULD be done.

      UPDATE, UPDATE: I googled and this works:

      curl -s "https://api.github.com/repos/espocrm/espocrm/releases/latest" | jq -r ".tag_name"

      9.3.0

      Is there a better way?
      Last edited by dev77; 02-05-2026, 05:40 PM.

      Comment


      • yuri
        yuri commented
        Editing a comment
        The link above is the API endpoint. You can fetch data from it. We do it internally too.
    • dev77
      Senior Member
      • Feb 2018
      • 142

      #5
      "You can fetch data from it. "

      I need to learn how to do that... and I will. If you have any bash or C++ code that does it, please share. :-)

      I think this is how to do it?

      response=$(curl -s "https://api.github.com/repos/espocrm/espocrm/releases/latest" | jq -r ".tag_name")

      UPDATE: In c++

      string command_string = "curl -s https://api.github.com/repos/espocrm...eleases/latest | jq -r .tag_name > /usr/home/xxxx/cpp_bak/cpp_bak_files/zzzgrep1.txt";

      system(command_string.c_str());

      (To get the new version into a variable via curl is more complex in C++ ... and this works just fine)
      Last edited by dev77; 02-05-2026, 11:56 PM.

      Comment

      • dev77
        Senior Member
        • Feb 2018
        • 142

        #6
        Having done the update to 9.3.0 I saw the new state.php file.

        I keep the current version number in one of my own files. I guess I could grep this file to pull it out.

        When will state.php be updated? When we do an update... or is there code in EspoCRM that will go out and pull it i each time we login?

        The reason I ask is that the GitHub site:

        A separate file where the following config parameters are stored: appTimestamp cacheTimestamp version latestVersion latestExtensionVersions currencyRates File: data/state.php.


        say that state.php will have:
        • appTimestamp
        • cacheTimestamp
        • version
        • latestVersion
        • latestExtensionVersions
        • currencyRates
        ​but all I see in the file is:

        <?php
        return [
        'cacheTimestamp' => 1770349409,
        'microtimeState' => 1770349409.291298,
        'currencyRates' => [
        'USD' => 1.0
        ],
        'appTimestamp' => 1770349408,
        'version' => '9.3.0'
        ];

        ... I don't see "latest version". Will this be added later on?

        Comment

        • yuri
          EspoCRM product developer
          • Mar 2014
          • 9639

          #7
          This parameter not for users and it does not guarantee a value. It's updated by cron time to time. After the next version check run by your instance, it will be updated.

          Comment

          • dev77
            Senior Member
            • Feb 2018
            • 142

            #8
            OK, since state.php is not guaranteed to be stable I'll continue to use my own file that holds the version of my install. Each might I (now) poll the GitHub 'endpoint' (above) to see if there is a new version out there and report it to me in my morning report (via email) from the nightly run .... created by several hundred lines of C++ code... which I'll be happy to share... once I redact any personal links. (Over the years I've also written this in bash, python, and rust... but I find C++ easier for me to use... based on 45 years of programming in C--like languages (like php)... and I truly hated Rust!!!):

            =============

            Code:
            Sent on Fri Feb 6 04:06:06 2026: by C++ script on Pair VPS.
            Jobs run in Mountain time (+1 hr.) but reported in Pacific time.
            
            Files to be done:
            
            address
            artfromamy
            espo_version
            espodb
            esposite
            linode
            scripts
            
            1-- 02-06-2026 04:04:01 START
            2-- 02-06-2026 04:04:04 address backup DONE
            3-- 02-06-2026 04:04:31 artfromamy-site backup DONE
            4-- 02-06-2026 04:04:35 artfromamy-sql backup DONE
            5-- 02-06-2026 04:04:35 new espo_version NOT FOUND (<-------- if there were a new one it would say : x.x.x)
            6-- 02-06-2026 04:04:47 espodb-sql backup DONE
            7-- 02-06-2026 04:06:02 esposite backup DONE
            8-- 02-06-2026 04:06:03 linode backup DONE
            9-- 02-06-2026 04:06:06 scripts backup DONE
            
            Note:
            
            # To create switch file entry:
            [URL]https://xxxxxx/switch4/index.php[/URL]
            
            # For user crontab - pair:
            crontab -e
            crontab -l
            
            # For root crontab - not used:
            sudo nano /etc/crontab
            
            # To update ESPO to a new version:
            SSH into Pair VPS
            cd /usr/home/xxxxxx/cpp_bak/cpp_bak_files
            Run: ./espo-prod-new-ver.sh
            Note: Espo backup: [URL]https://xxxxxxxxm/espocrm2[/URL].
            
            # To backup any site or file:
            Go to: [URL]https://xxxxxxxx/switch4/index.php[/URL]
            Enter the job/backups you want to run
            The backup will be uploaded to rsync.net that night.
            
            # To run from command line:
            /usr/home/xxxxx/cpp_bak/build/cpp_backup
            ( > /usr/home/ancnet1/cpp_bak/zzoutput.txt
            
            # EspoCRM download page:
            [URL]https://www.espocrm.com/download/[/URL]
            
            -- End --

            Comment

            Working...