[wp-hackers] Force a new ABSPATH when moving WordPress?

Kurt Payne kpayne+wordpress+hackers at gmail.com
Wed Mar 21 20:44:45 UTC 2012


Hi,

For #2, you can do something like this:

First, set eaccelerator.allowed_admin_path in php.ini (or .user.ini if
you're on php 5.3+) to include your the path to your migration script.

Second, in your migration script, call eaccelerator_clear().  The docs
for this function say:

"Remove all unused scripts and data from shared memory and disk cache,
this means all data that isn't used in the current requests"

That last part is important.  Make sure you're not using anything in
your migration script that you want cleared.

If you're really stuck, you can use a separate script to clear the
cache.  Use a script like this:

if ($_SERVER['PHP_AUTH_USER'] == 'login' && $_SERVER['PHP_AUTH_PW'] ==
'password') {
	eaccelerator_clear();
	die("Cleared cache");
}
die("Authentication failure");

Then have your migration script use curl to request your cache
clearing script.  It's not pretty, but I hope it gets you moving in
the right direction!

--Kurt


On Wed, Mar 21, 2012 at 1:19 PM, onlyunusedname
<onlyunusedname at gmail.com> wrote:
> Excellent.  Thanks, Otto.  There is eAccelerator running on this server and
> clearing its cache is just the trick.
>
> Just out of curiosity:  If one wanted to write a script that did everything
> in a more environment agnostic fashion, would that be possible?
>
> In other words, this script would run once after a URI change and it would:
>
> 1) Change the relevant database entries from $old_url to $new_url.
>
> 2)  [Magically solve a cached ABSPATH problem in a reasonably environment
> agnostic fashion]
>
> 3) Redirect to $new_url  (Site successfully moved.)
>
>
> Is step 2 as preposterous as I am making it sound, or can you imagine a
> feasable-ish answer?
>
> Thanks in any event.  You helped me a ton.
>
>
>
> On Wed, Mar 21, 2012 at 3:54 PM, Otto <otto at ottodestruct.com> wrote:
>
>> Most likely, you're running some sort of PHP accelerator, which keeps
>> the "compiled" PHP files in memory instead of re-reading them every
>> time. Thus, a change to the PHP files requires you to restart the
>> server to get the old versions out of RAM.
>>
>> Look into what PHP accelerator you're running, and see if it has any
>> way to flush the cached data.
>>
>> -Otto
>>
>>
>>
>> On Wed, Mar 21, 2012 at 2:04 PM, onlyunusedname
>> <onlyunusedname at gmail.com> wrote:
>> > I have a quick question that may be more PHP than WordPress.
>> >
>> > Whenever I move a small WordPress site database inclusive (and by move, I
>> > mean change its path and URI), I usually just change all the references
>> to
>> > the domain in the database with a search and replace.
>> >
>> > This seems to work for my needs, but the problem I run into every time is
>> > that wp-config.php retains the old ABSPATH constant.  So the site won't
>> > load at all at first.  My solution to this has always been to restart
>> > Apache.  After I do that wp-config.php will re-define ABSPATH correctly
>> and
>> > everything works fine
>> >
>> > Is there a way I can force this to occur without restarting my server?
>> > _______________________________________________
>> > wp-hackers mailing list
>> > wp-hackers at lists.automattic.com
>> > http://lists.automattic.com/mailman/listinfo/wp-hackers
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list