Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Installation on WordPress 3.8 #14

Open
showards opened this issue Jan 24, 2014 · 5 comments
Open

Installation on WordPress 3.8 #14

showards opened this issue Jan 24, 2014 · 5 comments
Assignees

Comments

@showards
Copy link

First, I would like to thank both you and Mr. Maunder for an excellent product. However, it doesn't seem to want to work on a fresh install of WP 3.8.1 :) I used it years ago and remember having to make one or two small changes to the way the blog prefix was chosen to get it to work, but that was so long ago...

I recently started working on sites again and wanted to use DeployMint in an upcoming project because it's one of those "must haves" for staging projects.

I'll give a quick rundown of the things I've done:

  1. Cloned WordPress from github, and checked out the 3.8-branch (https://github.com/WordPress/WordPress)
  2. Verified permalinks worked as noted in the WP Codex article, http://codex.wordpress.org/Create_A_Network
  3. Turned on MultiSite, installed the network by subdomain, and verified the wildcard DNS worked.
  4. Created a subdomain/blog site called "dev", so its URL ended up being http://dev.example.com/
  5. Created two distinct posts: one on the "dev" URL, and one for the main URL.
  6. Cloned the fork of DeployMint (https://github.com/ammmze/DeployMint.git)
  7. Clicked on "Network Admin" under "My Sites," then to "Plugins." Under Plugins, it offered "Network Activate," rather than "Activate.") Then I clicked on "DeployMint" in the menu to configure it.
  8. Configured the path to data directory (everything else had been found and auto-completed), setup a temporary database, and checked "disable backup." Then clicked "Save."

The following errors appeared in the webserver's error log. (I had literally clicked on "Network Activate," then on "DeployMint" (in the menu), then filled in the config and clicked "Save." Before clicking anything else, I checked the error log:

[Thu Jan 23 21:42:07 2014] [warn] [client 192.168.90.100] mod_fcgid: stderr: WordPress database error Table 'example.dep_options' doesn't exist for query SELECT name, val FROM dep_options made by require('wp-admin/plugins.php'), activate_plugin, include_once('/plugins/DeployMint/deploymint.php'), DeployMintMultiSite->setup, DeployMintAbstract->setup, DeployMintAbstract->getOptions, referer: http://example.com/wp-admin/network/plugins.php
[Thu Jan 23 21:42:07 2014] [warn] [client 192.168.90.100] mod_fcgid: stderr: WordPress database error Table 'example.dep_options' doesn't exist for query SELECT name, val FROM dep_options made by require('wp-admin/plugins.php'), activate_plugin, include_once('/plugins/DeployMint/deploymint.php'), DeployMintMultiSite->setup, DeployMintAbstract->allOptionsSet, DeployMintAbstract->getOptions, referer: http://example.com/wp-admin/network/plugins.php

There are more errors after this, as I believe this one solves itself eventually. (Perhaps it re-checks if the table exists when a project is created or something.)

I click on "Manage Projects," and create a new one by just filling out the name of the project. (No additional tables, no git origin.)

In the error log were more errors:

[Thu Jan 23 21:59:58 2014] [warn] [client 192.168.90.100] mod_fcgid: stderr: PHP Warning:  Missing argument 1 for DeployMintMultiSite::getTablePrefix(), called in /home/example/public_html/wp-content/plugins/DeployMint/DeployMintAbstract.php on line 1665 and defined in /home/example/public_html/wp-content/plugins/DeployMint/DeployMintMultiSite.php on line 62, referer: http://example.com/wp-admin/network/admin.php?page=deploymint
[Thu Jan 23 22:01:35 2014] [warn] [client 192.168.90.100] mod_fcgid: stderr: PHP Warning:  Missing argument 1 for DeployMintMultiSite::getTablePrefix(), called in /home/example/public_html/wp-content/plugins/DeployMint/DeployMintAbstract.php on line 1665 and defined in /home/example/public_html/wp-content/plugins/DeployMint/DeployMintMultiSite.php on line 62, referer: http://example.com/wp-admin/network/admin.php?page=deploymint
[Thu Jan 23 22:01:37 2014] [warn] [client 192.168.90.100] mod_fcgid: stderr: WordPress database error Unknown column 'wp_blogs.blog_name' in 'field list' for query SELECT wp_blogs.blog_id AS blog_id, wp_blogs.domain AS domain, wp_blogs.path AS path, wp_blogs.blog_name AS name FROM dep_members, wp_blogs WHERE dep_members.deleted=0 AND dep_members.project_id=1 AND dep_members.blog_id = wp_blogs.blog_id made by do_action('wp_ajax_deploymint_reloadProjects'), call_user_func_array, DeployMintAbstract->actionReloadProjects, DeployMintAbstract->getProjectBlogs, referer: http://example.com/wp-admin/network/admin.php?page=deploymint/projects
[Thu Jan 23 22:01:37 2014] [warn] [client 192.168.90.100] mod_fcgid: stderr: WordPress database error Unknown column 'wp_blogs.blog_name' in 'field list' for query SELECT wp_blogs.blog_id AS blog_id, wp_blogs.domain AS domain, wp_blogs.path AS path, wp_blogs.blog_name AS name FROM dep_members, wp_blogs WHERE dep_members.deleted=0 AND dep_members.project_id=1 AND dep_members.blog_id = wp_blogs.blog_id made by do_action('wp_ajax_deploymint_reloadProjects'), call_user_func_array, DeployMintAbstract->actionReloadProjects, DeployMintAbstract->getBlogsNotInProject, DeployMintAbstract->getProjectBlogs, referer: http://example.com/wp-admin/network/admin.php?page=deploymint/projects

The blog names (where to add a blog to a project), under the newly created project, are blank. The drop-down is there, with the appropriate number of blogs created in system, but it does not give a domain or a name or any identifying information for each blog selection option.

I will continue to tinker with it and see if I can get it to work...

@showards
Copy link
Author

I tried Lucasno's fork of this project, and it seemed to work out of the box on WP3.8.1, except for one tiny change:

--- a/DeployMintMultiSite.php
+++ b/DeployMintMultiSite.php
@@ -100,7 +100,7 @@ class DeployMintMultiSite extends DeployMintAbstract

     protected function getTablesToDeploy($projectId=0, $prefix='')
     {
-        $tables = $parent->getTablesToDeploy($projectId, $prefix);
+       $tables = parent::getTablesToDeploy($projectId, $prefix);

         $t = array();

@@ -116,4 +116,4 @@ class DeployMintMultiSite extends DeployMintAbstract

         return $tables;
     }
-}
\ No newline at end of file
+}

@ammmze
Copy link
Owner

ammmze commented Jan 24, 2014

Ah ha...good find. I will see if I can get lucasno's changes pulled in and
include your fix. I've never really tested this with wpmu at my company we
are using it on single site instances.

Thanks for your support
On Jan 24, 2014 2:47 AM, "showards" [email protected] wrote:

I tried Lucasno's fork of this project, and it seemed to work out of the
box on WP3.8.1, except for one tiny change:

--- a/DeployMintMultiSite.php
+++ b/DeployMintMultiSite.php
@@ -100,7 +100,7 @@ class DeployMintMultiSite extends DeployMintAbstract

 protected function getTablesToDeploy($projectId=0, $prefix='')
 {
  •    $tables = $parent->getTablesToDeploy($projectId, $prefix);
    
  •   $tables = parent::getTablesToDeploy($projectId, $prefix);
    
     $t = array();
    

@@ -116,4 +116,4 @@ class DeployMintMultiSite extends DeployMintAbstract

     return $tables;
 }

-}
\ No newline at end of file
+}


Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-33209691
.

ghost pushed a commit that referenced this issue Jan 24, 2014
@ghost ghost assigned ammmze Jan 24, 2014
@showards
Copy link
Author

I was a bit premature in stating Lucanso's fork worked pretty much out of the box. I apologize for posting the issue here, but I don't see a place to do it on the fork's page. (The errors also affected this version.)

It appears in 3.8 that the 'usermeta' table is not copied to each of the multisite/network installed blogs. Multisite websites can be snapshotted, but the deployment feature does not work. The database complains about a nonexistent "wp_X_usermeta" table in the temporary database. I was able to create the wp_X_usermeta table in the temporary database, then the deployment worked ... mostly (I'll get to that.)

The main WP database is named "example" and the temporary database is named "deploymint_example."

USE example;
SHOW CREATE TABLE wp_usermeta;
USE deploymint_example;
CREATE TABLE `wp_2_usermeta` (
  `umeta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `meta_key` varchar(255) DEFAULT NULL,
  `meta_value` longtext,
  PRIMARY KEY (`umeta_id`),
  KEY `user_id` (`user_id`),
  KEY `meta_key` (`meta_key`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8;

Once that had been done, the "Deploy Snapshot" feature worked, almost.

In WP3.8, the blogs.dir directory has been eliminated. Instead, the "wp-content/uploads/sites/SITENUMBER/" structure is used, which can be worked around by a symbolic link or two from the WP install directory:

ln -s wp-content/uploads/sites/1/2014/ wp-content/uploads/2014
ln -s wp-content/uploads/sites/ wp-content/blogs.dir

After the symbolic links were put into place, it seemed to work. Note on the first symbolic link: it may just be my install, but apparently the first blog on a multisite/network install uses the typical wp-content path as normal (domain.com/wp-content/2014/01/blah.jpg), but each site in the network uses wp-content/uploads/sites/SITENUMBER/2014/01/blah.jpg path for storage.

Err.. not "sitenumber," but $blogId

I'll have to explain this a little better another way...

I haven't spent a whole lot of time looking at the script; just enough to recognize potential path errors and webserver error logs. I will continue looking at it.

As a note, removing the usermeta table from $wpTables did not work, as there is also a check in the getTablesToDeploy() function which quashes activity on the usermeta (and "user") tables... Sigh

[Edit: I'm sorry for changing this report a lot, perhaps I'll just try a base install of Network/MultiSite, and see where files are stored for both the main site and the subsites.]

@showards
Copy link
Author

After some testing, I've figured out that the main site's uploaded media is stored simply in year/month folders in wp-content. With the default install of 3.8.1 and only multisite enabled, media uploaded to the main site appeared elsewhere than media uploaded to the subsite.

The main site's (blogId = 1) media upload path was: ~/public_html/wp-content/uploads/2014/01/blah.jpg

The sub-site's media upload path was: ~/public_html/wp-content/uploads/sites/2/2014/01/blah2.jpg

No more ~/public_html/wp-content/blogs.dir or ~/public_html/wp-content/uploads/sites/1/, unless symlinks are used. The paths for rsync and git should be looked at. If need be, try using symlinks to recreate the paths of 3.8.1 to the older version...

@showards
Copy link
Author

Sorry for the blabbing.

Okay, so I got lucanso's script working, as far as I can tell, in its entirety. (Snapshots and Deployments work flawlessly each and every time.)

The first step was to prepare the multisite install for backward compatibility. This can take place either before any content or media is uploaded, or afterward. If the uploads/sites/ directory already exists because media has been uploaded, then remove that step from the process below:

cd ~/public_html/wp-content
mkdir -p uploads/sites
ln -s uploads/sites/ blogs.dir
cd uploads/sites
ln -s ../ 1

The second step, which has already been committed here: 01becff

Then the third step, which was commenting a piece of code that tries to copy stuff to a sub-site's version of the usermeta table. I just quickly put an if-statement around the offending code to only execute if WP is in single-site mode. It doesn't seem like that would be the best course of action simply because in multisite deployments, I would think stuff can change in the usermeta table. Hmm...

--- a/DeployMintAbstract.php
+++ b/DeployMintAbstract.php
@@ -1148,13 +1148,15 @@ abstract class DeployMintAbstract implements DeployMintInterface
             if (mysql_error($dbh)) {
                 throw new Exception("A database error occured: " . substr(mysql_error($dbh), 0, 200));
             }
-
-            // Update wp_usermeta.meta_key replacing source prefix with destination prefix
-            mysql_query("UPDATE {$sourceTablePrefix}usermeta SET meta_key=REPLACE(meta_key, '$sourceTablePrefix', '$destTablePrefix')
-                WHERE meta_key LIKE '{$sourceTablePrefix}%'", $dbh);
-            if (mysql_error($dbh)) {
-                throw new Exception("A database error occured: " . substr(mysql_error($dbh), 0, 200));
-            }
+
+           if (!is_multisite()) {
+               // Update wp_usermeta.meta_key replacing source prefix with destination prefix
+               mysql_query("UPDATE {$sourceTablePrefix}usermeta SET meta_key=REPLACE(meta_key, '$sourceTablePrefix', '$destTablePrefix')
+                   WHERE meta_key LIKE '{$sourceTablePrefix}%'", $dbh);
+               if (mysql_error($dbh)) {
+                   throw new Exception("A database error occured: " . substr(mysql_error($dbh), 0, 200));
+               }
+           }

             mysql_query("UPDATE {$temporaryDatabase}.{$sourceTablePrefix}options SET option_name='{$destTablePrefix}user_roles' WHERE option_name='{$sourceTablePrefix}user_roles'",
             if (mysql_error($dbh)) {
@@ -1667,4 +1669,4 @@ abstract class DeployMintAbstract implements DeployMintInterface
             return $prefix . $value;
         }, $this->wpTables);
     }
-}
\ No newline at end of file

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants