开发者

P4PHP API - How to save p4 client with -f flag?

开发者 https://www.devze.com 2023-03-27 16:56 出处:网络
I\'m using the P4PHP API to build a GUI that allows users to mass create/update client specs. This works great as long as a client is unlocked, but for locked clients the API isn\'t picking up the -f

I'm using the P4PHP API to build a GUI that allows users to mass create/update client specs. This works great as long as a client is unlocked, but for locked clients the API isn't picking up the -f flag (or at least I don't think it is). I get the below error message when trying to save a locked client. This is weird because I have a Python script that does pretty much the same thing using the Python p4 API and it uses the same line to save a client, but it does pick up the -f flag. I'm not sure what to do here.

[Error]: Locked client 'php_test_client' owned by 'owner1'; use -f to force update.

Here is my php code:

$p4 = new P4();   //instantiate p4 object
$p4->port = 'perforce:1666';   //set p4 port
$p4->user = $pUser;  //set p4 user
try{
    $p4->connect();
    $p4->run_login($pPass);   //login with provided p4 pass
    $client = $p4->fetch_client($cNameSub);
    echo "client fetched: " . $cNameSub ."\n";
    $client['Client']= $cNameSub;
    $client['Description']= $cDescrSub;
    $client['Owner']= $cOwnerSub;
    $client['Host']= $cHostSub;
    $client['Root']= $cRootSub;
    $client['View']= $cViewArraySub;
    $client['Options']= $cOptSub;

    $p4->save_client($client,"-f");
    $p4->disconnect();开发者_运维知识库

    echo "client" . $cNameSub . " created successfully \n\n";
} catch (P4_Exception $e) {
     // output errors
    echo $e->getMessage() . "\n";
     foreach ($p4->errors as $error) {
          echo "Error: $error\n";
     }
     //TODO: log errors in db
}

I've also tried saving the client with the following lines, but it doesn't work either:

//try1
$p4->input = $client;
$p4->run("client", "-f");
//try2
$p4->run("client", "-f", $client);
//try3
$p4->input = $client;
$p4->run_client("-f");


You need the -i flag also!

This works:

$p4->input = $client;
$p4->run_client("-i","-f");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号