regenerate wordpress version.php - wordpress

Don't ask me how but I just did a huge mistake, and I need to regenerate the version.php file in wordpress.
Do you know if there is a way do to that, or another way to get the current wp version without this file ?
Thanks a lot.

Download a new version of Wordpress
and take the original version.php file
(is this)
<?php
/**
* The WordPress version string
*
* #global string $wp_version
*/
$wp_version = '3.8.1';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
*
* #global int $wp_db_version
*/
$wp_db_version = 26691;
/**
* Holds the TinyMCE version
*
* #global string $tinymce_version
*/
$tinymce_version = '359-20131026';
/**
* Holds the required PHP version
*
* #global string $required_php_version
*/
$required_php_version = '5.2.4';
/**
* Holds the required MySQL version
*
* #global string $required_mysql_version
*/
$required_mysql_version = '5.0';

Related

Swagger annotation for query parameters for file upload

I am trying to make an api documentation for my symfony based api and I would like to add info about the upload endpoint for my api. I am using nelmioapidocbundle. Can anyone please provide a link to the documentation where I can find it? or better if there is an example. Thank you.
/**
* #Route("/products/{id}/images", methods={"POST"})
*
* #SWG\Parameter(
* name="file",
* in="body",
* type="file",
* ---- Im not sure what to put here to make this work
* )
*
* #SWG\Response(
* response=201,
* description="File is uploaded."
* )
* )
*/
public function uploadImages(Request $request, FileUploadService $fileUploadService) {}
For anyone who might encounter this. this formData in value fixed the problem:
* #SWG\Parameter(
* name="file",
* in="formData", <----
* required=true,
* type="file",
* description="product image"

Symfony unique integer fields in entity

I have entity with uniq field, inviteCode. And when I create new entity I want set automatic some random code, but this code must be different from exist in db, what do you thing, what practices about that you know ?
/**
* #ORM\Table(name="users")
* #ORM\Entity
* #ORM\HasLifecycleCallbacks
* #AssertBridge\UniqueEntity(
* groups={"registration"},
* fields="inviteCode",
* errorPath="not valid",
* message="This inviteCode is already in use."
* )
*/
class User extends AbstractUser implements UserInterface
{
/**
* #ORM\Column(type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\Column(type="string", length=500, unique=true)
* #Annotation\SerializedName("_invite_code")
*/
private $inviteCode;
I found something like that
private function calculateReference($number)
{
$multipliers = array(7,3,1);
$length = strlen($number);
$numberArr = str_split($number);
$sum = 0;
for ($i = $length - 1; $i >= 0; --$i)
{
$sum += $numberArr[$i] * $multipliers[($length - 1 - $i) % 3];
}
return $number.(10 - $sum % 10) % 10;
}
first get max id from table then call function calculateReference with id and then setInviteCode.
But I believe doctrine have something exist for this issue or maybe somebody have good example for this
Someone provided a great answer here https://stackoverflow.com/a/13917309/4173130.
But like he said at the end, you don't need doctrine for such a simple feature. Generating the code in the constructor is an efficient, simple and clear solution.
You can use a UUID library like ramsey/uuid. Then you would be able to generate any random code with Uuid::uuid4();.
Another solution is to use random_bytes() with base64_encode : base64_encode(random_bytes(32)).
Please don't try to create a new function to generate random values. Most of time it is not secure, see https://www.owasp.org/index.php/Insecure_Randomness.
Why not using a uuid? It is included in php as a core function and i believe it suits your needs.
Check in the official documentation here

Missing file doc comment?

I used drupal coder module to check my code and always get missing file doc as an error.
I used the following file doc comment but still showing error. Can you please guide me what am i doing wrong.
Edit:
<?php
/**
* #file
* Description
*/
/**
* Implements hook_menu().
*
* Description
*
* #return array An array of menu items
*/
function hook_menu() {
//My code
}
Typical first 15 lines of a file:
<?php
/**
* #file
* Description of what this module (or file) is doing.
*/
/**
* Implements hook_help().
*/
function yourmodule_help($path, $arg) {
// or any other hook...
}
Don't forget to also comment the first function of you file with /** or else coder will believe that your #file comment is your first function's comment.

deactivate_plugins function not working for me at all

So I'm using the WordPress Plugin boilerplate and trying to remove a lite version of my plugin before going ahead with the activation of my new one. But for some reason this code simply does not execute. I have included an example below of what I am trying to do:
class Wp_Content_Calendar_Activator {
/**
* Short Description. (use period)
*
* Long Description.
*
* #since 1.0.0
*/
public static function activate() {
if( is_plugin_active('hello.php') ){
deactivate_plugins('hello.php');
}
}
}

Symfony 2 - FOSCommentBundle : add attachment feature

I need to add functionality to attach a file to a comment. The upload of the image would automatically when the user drops the file into the form (in the same way that you attach a file with gmail). My question is how do I do to find the file that was previously sent to the server when the comment is submitted and to delete the comment if the document is never submitted.
Do any of you have already done something similar?
Here's the association I have between my classes Comment and Document.
class Comment extends BaseComment
{
/** ... */
/**
* #ORM\ManyToMany(targetEntity="Document", cascade={"persist","remove"})
* #ORM\JoinTable(name="fls_comment_and_documents",
* joinColumns={#ORM\JoinColumn(name="comment_id", referencedColumnName="id")},
* inverseJoinColumns={#ORM\JoinColumn(name="document_id", referencedColumnName="id", unique=true)}
* )
*
* #var ArrayCollection $documents
*/
protected $documents;
/** ... */
}
Thanks in advance !

Resources