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

  • Home
  • SEARCH
  • 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 721693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:54:12+00:00 2026-05-14T05:54:12+00:00

What am I doing wrong here? I’m serializing a value, storing it in a

  • 0

What am I doing wrong here? I’m serializing a value, storing it in a database (table bb_meta), retrieving it… OK so far… but then I have to unserialize it twice. Shouldn’t I be able to just unserialize once? This seems to work, but I’m wondering what point about serialization I’m missing here.

//check database to see if user has ever visited before.
$querystring = $bbdb->prepare( "SELECT `meta_value` FROM `$bbdb->meta` WHERE `object_type` = %s AND `object_id` = %s AND `meta_key` = %s LIMIT 1", $bbtype, $bb_this_thread, $bbuser );
$bb_last_visits = $bbdb->get_row($querystring, OBJECT);
//if $bb_last_visits is empty, add time() as the metavalue using bb_update_meta
    if (empty($bb_last_visits)) {
        $first_visit = time();
        echo 'serialized first visit: ' . $bb_this_visit_time_serialized = serialize(array($bb_this_thread => $first_visit));
        bb_update_meta( $bb_this_thread, $bbuser, $bb_this_visit_time_serialized, $bbtype ); //add to database, bb_meta table
        echo '$bb_last_visits was empty. Setting first visit time as ' . $bb_this_visit_time_serialized . '<br>';
        } else {
            //else, test by unserializing the data for use.
            echo 'last visit time already set: '; echo $bb_last_visits->meta_value; echo '<br>';
            //fatal error - echo 'unserialized: ' . $bb_last_visits_unserialized = unserialize($bb_last_visits[0]->meta_value); echo '<br>';
            echo 'unserialize: ' . $unserialized_visits = unserialize($bb_last_visits->meta_value); echo '<br>';
            echo 'hmm, need to unserialize again??: '; echo $unserialized_unserialized_visits = unserialize($unserialized_visits); echo '<br>';
            echo 'hey look, it\'s an array value I can finally use now. phew: ' . $unserialized_unserialized_visits[$bb_this_thread];
            }
  • 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-14T05:54:12+00:00Added an answer on May 14, 2026 at 5:54 am

    bb_update_meta() is a bbPress function, which calls a WordPress function called maybe_serialize() that “does the boring stuff for you” which apparently in this case means conditionally serializing an array.

    An unserialized array can be directly passed to this function. By doing so, I avoided the need to un-un-serialize.

    Not sure all the effort was worth the performance gain, but at least it was educational.

    Thanks @webbiedave for setting off the spark that solved this!

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

Sidebar

Related Questions

I'm not sure what I'm doing wrong here, but I have a synatx error
What am I doing wrong here? I have a .social div , but on
What am I doing wrong here? It says Database Count Failed (on the $count
Im not quite sure what I am doing wrong here, I have folloed the
What am I doing wrong here. The animation slide out the navigation, but can't
what am I doing wrong here? I have a model for an app I
I was wondering what am I doing wrong here? I have the following HTML:
What am I doing wrong here? If FilePath.ToLower().Contains(.pdf) Then Dim Replaced As String =
What am I doing wrong here? I'm not getting the randomNum value displayed when
What am I doing wrong here? $sub_data = $this->Subscriber->find('all', array( 'joins' => array( 'table'

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.